Package com.google.api.ads.adwords.axis.v201309.cm

Examples of com.google.api.ads.adwords.axis.v201309.cm.AdGroupCriterion


    FeedMappingOperation operation = new FeedMappingOperation();
    operation.setOperand(feedMapping);
    operation.setOperator(Operator.ADD);

    // Save the field mapping.
    FeedMappingReturnValue result =
        feedMappingService.mutate(new FeedMappingOperation[] {operation});
    for (FeedMapping savedFeedMapping : result.getValue()) {
      System.out.printf(
          "Feed mapping with ID %d and placeholderType %d was saved for feed with ID %d.\n",
          savedFeedMapping.getFeedMappingId(), savedFeedMapping.getPlaceholderType(),
          savedFeedMapping.getFeedId());
    }
View Full Code Here


   * @throws Exception
   */
  private static void updateFeedMapping(AdWordsServices adWordsServices, AdWordsSession session,
      Long feedId, FeedAttribute line1FeedAttribute, FeedAttribute line2FeedAttribute)
      throws Exception {
    FeedMappingServiceInterface mappingService =
        adWordsServices.get(session, FeedMappingServiceInterface.class);
    Selector selector = new Selector();
    selector.setFields(
        new String[] {"FeedId", "FeedMappingId", "PlaceholderType", "AttributeFieldMappings"});
    selector.setPredicates(new Predicate[] {
        new Predicate("FeedId", PredicateOperator.EQUALS, new String[] {feedId.toString()})});

    FeedMapping feedMapping = mappingService.get(selector).getEntries()[0];

    // Remove the existing mapping (FeedMapping is immutable).
    feedMapping = mappingService.mutate(new FeedMappingOperation[] {
        new FeedMappingOperation(Operator.REMOVE, null, feedMapping)}).getValue(0);

    // Create line 1 and line 2 attribute field mappings.
    AttributeFieldMapping line1FieldMapping = new AttributeFieldMapping();
    line1FieldMapping.setFeedAttributeId(line1FeedAttribute.getId());
    line1FieldMapping.setFieldId(PLACEHOLDER_FIELD_LINE_1_TEXT);

    AttributeFieldMapping line2FieldMapping = new AttributeFieldMapping();
    line2FieldMapping.setFeedAttributeId(line2FeedAttribute.getId());
    line2FieldMapping.setFieldId(PLACEHOLDER_FIELD_LINE_2_TEXT);

    // Combine the existing field mappings with the new mappings.
    List<AttributeFieldMapping> allFieldMappings = new ArrayList<AttributeFieldMapping>();

    // Include existing mappings.
    allFieldMappings.addAll(Arrays.asList(feedMapping.getAttributeFieldMappings()));
    // Add the new mappings for line 1 and line 2.
    allFieldMappings.add(line1FieldMapping);
    allFieldMappings.add(line2FieldMapping);

    feedMapping.setAttributeFieldMappings(allFieldMappings.toArray(new AttributeFieldMapping[0]));

    FeedMappingReturnValue mappingReturnValue = mappingService.mutate(
        new FeedMappingOperation[] {new FeedMappingOperation(Operator.ADD, null, feedMapping)});

    FeedMapping mutatedMapping = mappingReturnValue.getValue()[0];

    System.out.printf("Updated field mappings for feedId %d and feedMappingId %d to:%n",
View Full Code Here

  private static final int PLACEHOLDER_FIELD_LINE_2_TEXT = 4;

  private static void createSiteLinksFeedMapping(AdWordsServices adWordsServices,
      AdWordsSession session, SiteLinksDataHolder siteLinksData) throws Exception {
    // Get the FeedItemService.
    FeedMappingServiceInterface feedMappingService =
        adWordsServices.get(session, FeedMappingServiceInterface.class);

    // Map the FeedAttributeIds to the fieldId constants.
    AttributeFieldMapping linkTextFieldMapping = new AttributeFieldMapping();
    linkTextFieldMapping.setFeedAttributeId(siteLinksData.linkTextFeedAttributeId);
    linkTextFieldMapping.setFieldId(PLACEHOLDER_FIELD_SITELINK_LINK_TEXT);
    AttributeFieldMapping linkUrlFieldMapping = new AttributeFieldMapping();
    linkUrlFieldMapping.setFeedAttributeId(siteLinksData.linkUrlFeedAttributeId);
    linkUrlFieldMapping.setFieldId(PLACEHOLDER_FIELD_SITELINK_URL);
    AttributeFieldMapping line1FieldMapping = new AttributeFieldMapping();
    line1FieldMapping.setFeedAttributeId(siteLinksData.line1FeedAttributeId);
    line1FieldMapping.setFieldId(PLACEHOLDER_FIELD_LINE_1_TEXT);
    AttributeFieldMapping line2FieldMapping = new AttributeFieldMapping();
    line2FieldMapping.setFeedAttributeId(siteLinksData.line2FeedAttributeId);
    line2FieldMapping.setFieldId(PLACEHOLDER_FIELD_LINE_2_TEXT);


    // Create the FieldMapping and operation.
    FeedMapping feedMapping = new FeedMapping();
    feedMapping.setPlaceholderType(PLACEHOLDER_SITELINKS);
    feedMapping.setFeedId(siteLinksData.siteLinksFeedId);
    feedMapping.setAttributeFieldMappings(new AttributeFieldMapping[] {linkTextFieldMapping,
        linkUrlFieldMapping, line1FieldMapping, line2FieldMapping});
    FeedMappingOperation operation = new FeedMappingOperation();
    operation.setOperand(feedMapping);
    operation.setOperator(Operator.ADD);

    // Save the field mapping.
    FeedMappingReturnValue result =
        feedMappingService.mutate(new FeedMappingOperation[] {operation});
    for (FeedMapping savedFeedMapping : result.getValue()) {
      System.out.printf(
          "Feed mapping with ID %d and placeholderType %d was saved for feed with ID %d.\n",
          savedFeedMapping.getFeedMappingId(), savedFeedMapping.getPlaceholderType(),
          savedFeedMapping.getFeedId());
View Full Code Here

    line1Attribute.setName("Line 1 Description");
    line2Attribute.setType(FeedAttributeType.STRING);
    line2Attribute.setName("Line 2 Description");
    feed.setAttributes(new FeedAttribute[] {line1Attribute, line2Attribute});

    FeedOperation feedOperation = new FeedOperation();
    feedOperation.setOperand(feed);
    feedOperation.setOperator(Operator.SET);

    FeedServiceInterface feedService = adWordsServices.get(session, FeedServiceInterface.class);
    FeedReturnValue mutateFeedResult = feedService.mutate(new FeedOperation[] {feedOperation});

    // Get the new attributes from the mutated feed.
View Full Code Here

    siteLinksFeed.setAttributes(
        new FeedAttribute[] {textAttribute, urlAttribute, line1Attribute, line2Attribute});
    siteLinksFeed.setOrigin(FeedOrigin.USER);

    // Create operation.
    FeedOperation operation = new FeedOperation();
    operation.setOperand(siteLinksFeed);
    operation.setOperator(Operator.ADD);

    // Add the feed.
    FeedReturnValue result = feedService.mutate(new FeedOperation[] {operation});

    Feed savedFeed = result.getValue()[0];
View Full Code Here

    FeedOperation feedOperation = new FeedOperation();
    feedOperation.setOperand(feed);
    feedOperation.setOperator(Operator.SET);

    FeedServiceInterface feedService = adWordsServices.get(session, FeedServiceInterface.class);
    FeedReturnValue mutateFeedResult = feedService.mutate(new FeedOperation[] {feedOperation});

    // Get the new attributes from the mutated feed.
    Feed mutatedFeed = mutateFeedResult.getValue()[0];
    line1Attribute = mutatedFeed.getAttributes(nextAttributeIndex);
    line2Attribute = mutatedFeed.getAttributes(nextAttributeIndex + 1);
    return new FeedAttribute[] {line1Attribute, line2Attribute};
  }
View Full Code Here

    FeedOperation operation = new FeedOperation();
    operation.setOperand(siteLinksFeed);
    operation.setOperator(Operator.ADD);

    // Add the feed.
    FeedReturnValue result = feedService.mutate(new FeedOperation[] {operation});

    Feed savedFeed = result.getValue()[0];
    siteLinksData.siteLinksFeedId = savedFeed.getId();
    FeedAttribute[] savedAttributes = savedFeed.getAttributes();
    siteLinksData.linkTextFeedAttributeId = savedAttributes[0].getId();
    siteLinksData.linkUrlFeedAttributeId = savedAttributes[1].getId();
    siteLinksData.line1FeedAttributeId = savedAttributes[2].getId();
View Full Code Here

    runExample(adWordsServices, session, feedId, feedItemDescriptions);
  }

  public static void runExample(AdWordsServices adWordsServices, AdWordsSession session,
      Long feedId, Map<Long, String[]> feedItemDescriptions) throws Exception {
    FeedServiceInterface feedService = adWordsServices.get(session, FeedServiceInterface.class);
    Selector selector = new Selector();
    // Do not include "Attributes" because you do not want to pass existing
    // attributes into the subsequent mutate (SET) call.
    selector.setFields(new String[] {"Id", "Attributes"});
    selector.setPredicates(new Predicate[] {
        new Predicate("Id", PredicateOperator.EQUALS, new String[] {feedId.toString()})});
    Feed feed = feedService.get(selector).getEntries()[0];

    // Add new attributes to the feed.
    FeedAttribute[] newAttributes = addLine1And2FeedAttributes(adWordsServices, session, feed);
    FeedAttribute line1Attribute = newAttributes[0];
    FeedAttribute line2Attribute = newAttributes[1];
View Full Code Here

    FeedOperation feedOperation = new FeedOperation();
    feedOperation.setOperand(feed);
    feedOperation.setOperator(Operator.SET);

    FeedServiceInterface feedService = adWordsServices.get(session, FeedServiceInterface.class);
    FeedReturnValue mutateFeedResult = feedService.mutate(new FeedOperation[] {feedOperation});

    // Get the new attributes from the mutated feed.
    Feed mutatedFeed = mutateFeedResult.getValue()[0];
    line1Attribute = mutatedFeed.getAttributes(nextAttributeIndex);
    line2Attribute = mutatedFeed.getAttributes(nextAttributeIndex + 1);
View Full Code Here

  private static void createSiteLinksFeed(
      AdWordsServices adWordsServices, AdWordsSession session, SiteLinksDataHolder siteLinksData)
      throws Exception {
    // Get the FeedService.
    FeedServiceInterface feedService = adWordsServices.get(session, FeedServiceInterface.class);

    // Create attributes.
    FeedAttribute textAttribute = new FeedAttribute();
    textAttribute.setType(FeedAttributeType.STRING);
    textAttribute.setName("Link Text");
    FeedAttribute urlAttribute = new FeedAttribute();
    urlAttribute.setType(FeedAttributeType.URL);
    urlAttribute.setName("Link URL");
    FeedAttribute line1Attribute = new FeedAttribute();
    line1Attribute.setType(FeedAttributeType.STRING);
    line1Attribute.setName("Line 1 Description");
    FeedAttribute line2Attribute = new FeedAttribute();
    line2Attribute.setType(FeedAttributeType.STRING);
    line2Attribute.setName("Line 2 Description");

    // Create the feed.
    Feed siteLinksFeed = new Feed();
    siteLinksFeed.setName("Feed For Site Links");
    siteLinksFeed.setAttributes(
        new FeedAttribute[] {textAttribute, urlAttribute, line1Attribute, line2Attribute});
    siteLinksFeed.setOrigin(FeedOrigin.USER);

    // Create operation.
    FeedOperation operation = new FeedOperation();
    operation.setOperand(siteLinksFeed);
    operation.setOperator(Operator.ADD);

    // Add the feed.
    FeedReturnValue result = feedService.mutate(new FeedOperation[] {operation});

    Feed savedFeed = result.getValue()[0];
    siteLinksData.siteLinksFeedId = savedFeed.getId();
    FeedAttribute[] savedAttributes = savedFeed.getAttributes();
    siteLinksData.linkTextFeedAttributeId = savedAttributes[0].getId();
View Full Code Here

TOP

Related Classes of com.google.api.ads.adwords.axis.v201309.cm.AdGroupCriterion

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.