Of course.  It's rough-and-ready but here it is.  The payload of the 
campaign's sitelink Ids (as Pete highlighted) is in the rhsOperands of the 
CampaignFeed's matching function.

Good luck,
Peter

private static void stringAppendCampaignFeedSitelinks(final List<String> s, 
final CampaignFeed campaignFeed) {
final Long campaignId = campaignFeed.getCampaignId();
final Long feedId = campaignFeed.getFeedId();
final CampaignFeedStatus campaignFeedStatus = campaignFeed.getStatus();
final int[] placeholderTypesArray = campaignFeed.getPlaceholderTypes(); // 
TODO: what do we do if this returns > 1 element?
final List<Integer> placeholderTypes = getList(placeholderTypesArray);
 if (placeholderTypes.size() != 1)
{
s.add("Got " + placeholderTypes.size() + " placeholder types so we don't 
know what to do with the feed.");
return;
}
 Integer placeholderType = placeholderTypes.get(0);
if (!placeholderType.equals(PLACEHOLDER_SITELINKS))
{
s.add("Received placeholder type " + placeholderType + " when was expecting 
sitelinks (" + PLACEHOLDER_SITELINKS + ")");
//return;
}

final Function matchingFunction = campaignFeed.getMatchingFunction();
final FunctionArgumentOperand[] lhsOperands = 
matchingFunction.getLhsOperand();
final FunctionArgumentOperand[] rhsOperands = 
matchingFunction.getRhsOperand();
final FunctionOperator functionOperator = matchingFunction.getOperator();
final String functionOperatorString = functionOperator.getValue();
final List<String> lhsFunctionArgumentOperandTypes = new 
ArrayList<String>();
final List<String> rhsFunctionArgumentOperandTypes = new 
ArrayList<String>();
final List<Long> rhsFeedItemIds = new ArrayList<Long>();
if (lhsOperands != null)
{
for (final FunctionArgumentOperand lhsOperand : lhsOperands)
{
final String lhsFunctionArgumentOperandType = 
lhsOperand.getFunctionArgumentOperandType();
lhsFunctionArgumentOperandTypes.add(lhsFunctionArgumentOperandType);
}
}

/*
 * This is where the payload is. Only the campaign's feed items will be in 
Rhs Operands.
 */
if (rhsOperands != null)
{
for (final FunctionArgumentOperand rhsOperand : rhsOperands)
{
final String rhsFunctionArgumentOperandType = 
rhsOperand.getFunctionArgumentOperandType();
rhsFunctionArgumentOperandTypes.add(rhsFunctionArgumentOperandType);
if (rhsFunctionArgumentOperandType.equals("ConstantOperand"))
{
ConstantOperand rhs = (ConstantOperand)rhsOperand;
if (rhs.getType() == ConstantOperandConstantType.LONG)
rhsFeedItemIds.add(rhs.getLongValue());
}
}
} 
s.add("Campaign Feed: Campaign ID " + campaignId + ", " + "Feed ID " + 
feedId + ", " + "CampaignFeedStatus " + campaignFeedStatus + ", " + 
"Placeholder Types " + placeholderTypes);
s.add("\tMatching Function: functionOperatorString [" + 
functionOperatorString + "]");
s.add("\t\tLhsFunctionArgumentOperandTypes\n " + 
PricingEngineUtils.getEasilyReadableString(lhsFunctionArgumentOperandTypes, 
4, PricingEngineUtils.DO_NOT_PRINT_LINE_NUMS));
s.add("\t\tRhsFunctionArgumentOperandTypes\n " + 
PricingEngineUtils.getEasilyReadableString(rhsFunctionArgumentOperandTypes, 
4, PricingEngineUtils.DO_NOT_PRINT_LINE_NUMS));
s.add("\t\tRhsFeedItemIds\n " + 
PricingEngineUtils.getEasilyReadableString(rhsFeedItemIds, 4, 
PricingEngineUtils.DO_NOT_PRINT_LINE_NUMS));
}


On Thursday, August 8, 2013 9:10:30 AM UTC-4, Oliver wrote:
>
> Hi Peter,
>
> We're currently trying to do the same thing (figure out which sitelinks 
> belong to the campaign). If it's ok with you, do you mind posting the java 
> code you're using to do this?
>
> Many thanks
>
> Oliver
>
>
> On Tuesday, August 6, 2013 6:25:22 PM UTC+1, Peter Kingswell wrote:
>>
>> I managed to java-ify that and indeed rhsOperands does indeed contain 
>> only the campaign's sitelinks - thanks very much!
>>
>> Peter
>>
>> On Monday, August 5, 2013 9:01:50 AM UTC-4, pete wrote:
>>>
>>> Hi Peter - does the CampaignFeedItem.matchingFunction.rhsOperand contain 
>>> an Array of long values where contextType == 
>>> RequestContextOperandContextType.FEED_ITEM_ID?
>>>  
>>> In my tests, this contains the specific feedItems mapped to a Campaign.
>>>  
>>> Here's a C# snippet where I have a list of CampaignFeed and 2 lists of 
>>> FeedItem (one defining those which I've updated and the other which have 
>>> not been updated) - specifics aside, it shows how a make the connection 
>>> between a FeedItem and a Campaign...
>>>  
>>> It's a bit rough and has been extracted from a logging routine but hope 
>>> it helps.
>>>  
>>> pete
>>>  
>>> public void Append(List<CampaignFeed> cFeeds, List<FeedItem> updItems, 
>>> List<FeedItem> noUpdItems)
>>>  {
>>>   foreach (var cf in cFeeds)
>>>   {
>>>    if (cf.matchingFunction.lhsOperand.Where((x) => 
>>> ((RequestContextOperand)x).contextType == 
>>> RequestContextOperandContextType.FEED_ITEM_ID).Count() > 0)
>>>    {
>>>     foreach (ConstantOperand rhs in cf.matchingFunction.rhsOperand)
>>>     {
>>>      if (rhs.type != ConstantOperandConstantType.LONG || rhs.longValue 
>>> == 0) continue;
>>>      long fItemId = rhs.longValue;
>>>      if (updItems.Where((x) => x.feedItemId == fItemId).Count() > 0)
>>>       appendFeedItems(cf, updItems.Where((x) => x.feedItemId == 
>>> fItemId).First(), "Success", "");
>>>      else
>>>       appendFeedItems(cf, noUpdItems.Where((x) => x.feedItemId == 
>>> fItemId).First(), "Not Required", "");
>>>     }
>>>    }
>>>   }
>>>  }
>>>
>>>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://adwordsapi.blogspot.com
http://groups.google.com/group/adwords-api
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to