Search in sources :

Example 1 with FunctionOperand

use of com.google.api.ads.adwords.axis.v201809.cm.FunctionOperand in project googleads-java-lib by googleads.

the class MigrateToExtensionSettings method getFeedItemIdsForCampaign.

/**
 * Returns the list of feed item IDs that are used by a campaign through a given campaign feed.
 */
private static Set<Long> getFeedItemIdsForCampaign(CampaignFeed campaignFeed) throws RemoteException {
    Set<Long> feedItemIds = Sets.newHashSet();
    FunctionOperator functionOperator = campaignFeed.getMatchingFunction().getOperator();
    if (FunctionOperator.IN.equals(functionOperator)) {
        // Check if matchingFunction is of the form IN(FEED_ITEM_ID,{xxx,xxx}).
        // Extract feed items if applicable.
        feedItemIds.addAll(getFeedItemIdsFromArgument(campaignFeed.getMatchingFunction()));
    } else if (FunctionOperator.AND.equals(functionOperator)) {
        // Check if matchingFunction is of the form IN(FEED_ITEM_ID,{xxx,xxx}).
        // Extract feed items if applicable.
        Arrays.stream(campaignFeed.getMatchingFunction().getLhsOperand()).filter(FunctionOperand.class::isInstance).map(argument -> (FunctionOperand) argument).filter(operand -> FunctionOperator.IN.equals(operand.getValue().getOperator())).forEach(operand -> feedItemIds.addAll(getFeedItemIdsFromArgument(operand.getValue())));
    } else {
    // There are no other matching functions involving feed item IDs.
    }
    return feedItemIds;
}
Also used : Arrays(java.util.Arrays) UrlList(com.google.api.ads.adwords.axis.v201809.cm.UrlList) CampaignFeedOperation(com.google.api.ads.adwords.axis.v201809.cm.CampaignFeedOperation) CampaignExtensionSettingOperation(com.google.api.ads.adwords.axis.v201809.cm.CampaignExtensionSettingOperation) CampaignFeedServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.CampaignFeedServiceInterface) HashMultimap(com.google.common.collect.HashMultimap) OfflineCredentials(com.google.api.ads.common.lib.auth.OfflineCredentials) Map(java.util.Map) ApiException(com.google.api.ads.adwords.axis.v201809.cm.ApiException) FeedItem(com.google.api.ads.adwords.axis.v201809.cm.FeedItem) FeedPage(com.google.api.ads.adwords.axis.v201809.cm.FeedPage) OAuthException(com.google.api.ads.common.lib.exception.OAuthException) AdWordsServices(com.google.api.ads.adwords.axis.factory.AdWordsServices) Set(java.util.Set) Operator(com.google.api.ads.adwords.axis.v201809.cm.Operator) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) RemoteException(java.rmi.RemoteException) CampaignExtensionSettingServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.CampaignExtensionSettingServiceInterface) List(java.util.List) AdWordsSession(com.google.api.ads.adwords.lib.client.AdWordsSession) AdWordsServicesInterface(com.google.api.ads.adwords.lib.factory.AdWordsServicesInterface) ApiError(com.google.api.ads.adwords.axis.v201809.cm.ApiError) ValidationException(com.google.api.ads.common.lib.exception.ValidationException) FunctionOperand(com.google.api.ads.adwords.axis.v201809.cm.FunctionOperand) FunctionArgumentOperand(com.google.api.ads.adwords.axis.v201809.cm.FunctionArgumentOperand) ExtensionFeedItem(com.google.api.ads.adwords.axis.v201809.cm.ExtensionFeedItem) FunctionOperator(com.google.api.ads.adwords.axis.v201809.cm.FunctionOperator) FeedMapping(com.google.api.ads.adwords.axis.v201809.cm.FeedMapping) FeedItemAttributeValue(com.google.api.ads.adwords.axis.v201809.cm.FeedItemAttributeValue) AttributeFieldMapping(com.google.api.ads.adwords.axis.v201809.cm.AttributeFieldMapping) Multimap(com.google.common.collect.Multimap) FeedServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.FeedServiceInterface) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) FeedItemOperation(com.google.api.ads.adwords.axis.v201809.cm.FeedItemOperation) ExtensionSetting(com.google.api.ads.adwords.axis.v201809.cm.ExtensionSetting) CampaignExtensionSetting(com.google.api.ads.adwords.axis.v201809.cm.CampaignExtensionSetting) Function(com.google.api.ads.adwords.axis.v201809.cm.Function) Credential(com.google.api.client.auth.oauth2.Credential) CampaignFeed(com.google.api.ads.adwords.axis.v201809.cm.CampaignFeed) RequestContextOperandContextType(com.google.api.ads.adwords.axis.v201809.cm.RequestContextOperandContextType) FeedMappingServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.FeedMappingServiceInterface) CampaignFeedPage(com.google.api.ads.adwords.axis.v201809.cm.CampaignFeedPage) Feed(com.google.api.ads.adwords.axis.v201809.cm.Feed) ConfigurationLoadException(com.google.api.ads.common.lib.conf.ConfigurationLoadException) ExtensionSettingPlatform(com.google.api.ads.adwords.axis.v201809.cm.ExtensionSettingPlatform) FeedMappingPage(com.google.api.ads.adwords.axis.v201809.cm.FeedMappingPage) SitelinkFeedItem(com.google.api.ads.adwords.axis.v201809.cm.SitelinkFeedItem) Maps(com.google.common.collect.Maps) DEFAULT_CONFIGURATION_FILENAME(com.google.api.ads.common.lib.utils.Builder.DEFAULT_CONFIGURATION_FILENAME) RequestContextOperand(com.google.api.ads.adwords.axis.v201809.cm.RequestContextOperand) FeedItemPage(com.google.api.ads.adwords.axis.v201809.cm.FeedItemPage) ConstantOperand(com.google.api.ads.adwords.axis.v201809.cm.ConstantOperand) FeedItemServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.FeedItemServiceInterface) FeedType(com.google.api.ads.adwords.axis.v201809.cm.FeedType) Api(com.google.api.ads.common.lib.auth.OfflineCredentials.Api) FunctionOperand(com.google.api.ads.adwords.axis.v201809.cm.FunctionOperand) FunctionOperator(com.google.api.ads.adwords.axis.v201809.cm.FunctionOperator)

Aggregations

AdWordsServices (com.google.api.ads.adwords.axis.factory.AdWordsServices)1 ApiError (com.google.api.ads.adwords.axis.v201809.cm.ApiError)1 ApiException (com.google.api.ads.adwords.axis.v201809.cm.ApiException)1 AttributeFieldMapping (com.google.api.ads.adwords.axis.v201809.cm.AttributeFieldMapping)1 CampaignExtensionSetting (com.google.api.ads.adwords.axis.v201809.cm.CampaignExtensionSetting)1 CampaignExtensionSettingOperation (com.google.api.ads.adwords.axis.v201809.cm.CampaignExtensionSettingOperation)1 CampaignExtensionSettingServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.CampaignExtensionSettingServiceInterface)1 CampaignFeed (com.google.api.ads.adwords.axis.v201809.cm.CampaignFeed)1 CampaignFeedOperation (com.google.api.ads.adwords.axis.v201809.cm.CampaignFeedOperation)1 CampaignFeedPage (com.google.api.ads.adwords.axis.v201809.cm.CampaignFeedPage)1 CampaignFeedServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.CampaignFeedServiceInterface)1 ConstantOperand (com.google.api.ads.adwords.axis.v201809.cm.ConstantOperand)1 ExtensionFeedItem (com.google.api.ads.adwords.axis.v201809.cm.ExtensionFeedItem)1 ExtensionSetting (com.google.api.ads.adwords.axis.v201809.cm.ExtensionSetting)1 ExtensionSettingPlatform (com.google.api.ads.adwords.axis.v201809.cm.ExtensionSettingPlatform)1 Feed (com.google.api.ads.adwords.axis.v201809.cm.Feed)1 FeedItem (com.google.api.ads.adwords.axis.v201809.cm.FeedItem)1 FeedItemAttributeValue (com.google.api.ads.adwords.axis.v201809.cm.FeedItemAttributeValue)1 FeedItemOperation (com.google.api.ads.adwords.axis.v201809.cm.FeedItemOperation)1 FeedItemPage (com.google.api.ads.adwords.axis.v201809.cm.FeedItemPage)1