adWordsServices.get(session, CampaignFeedServiceInterface.class);
RequestContextOperand requestContextOperand = new RequestContextOperand();
requestContextOperand.setContextType(RequestContextOperandContextType.FEED_ITEM_ID);
Function feedItemFunction = new Function();
feedItemFunction.setLhsOperand(new FunctionArgumentOperand[] {requestContextOperand});
feedItemFunction.setOperator(FunctionOperator.IN);
List<FunctionArgumentOperand> operands = new ArrayList<FunctionArgumentOperand>();
for (long feedItemId : siteLinksData.siteLinkFeedItemIds) {
ConstantOperand constantOperand = new ConstantOperand();
constantOperand.setLongValue(feedItemId);
constantOperand.setType(ConstantOperandConstantType.LONG);
operands.add(constantOperand);
}
feedItemFunction.setRhsOperand(operands.toArray(new FunctionArgumentOperand[operands.size()]));
// Optional: to target to a platform, define a function and 'AND' it with
// the feed item ID link:
RequestContextOperand platformRequestContextOperand = new RequestContextOperand();
platformRequestContextOperand.setContextType(RequestContextOperandContextType.DEVICE_PLATFORM);
ConstantOperand platformOperand = new ConstantOperand();
platformOperand.setStringValue("Mobile");
platformOperand.setType(ConstantOperandConstantType.STRING);
Function platformFunction = new Function();
platformFunction.setLhsOperand(new FunctionArgumentOperand[] {platformRequestContextOperand});
platformFunction.setOperator(FunctionOperator.EQUALS);
platformFunction.setRhsOperand(new FunctionArgumentOperand[] {platformOperand});
// Combine the two functions using an AND operation.
FunctionOperand feedItemFunctionOperand = new FunctionOperand();
feedItemFunctionOperand.setValue(feedItemFunction);
FunctionOperand platformFunctionOperand = new FunctionOperand();
platformFunctionOperand.setValue(platformFunction);
Function combinedFunction = new Function();
combinedFunction.setOperator(FunctionOperator.AND);
combinedFunction.setLhsOperand(
new FunctionArgumentOperand[] {feedItemFunctionOperand, platformFunctionOperand});
CampaignFeed campaignFeed = new CampaignFeed();
campaignFeed.setFeedId(siteLinksData.siteLinksFeedId);
campaignFeed.setCampaignId(campaignId);