Package com.google.api.ads.dfp.axis.utils.v201311

Examples of com.google.api.ads.dfp.axis.utils.v201311.StatementBuilder


    // Get the LineItemService.
    LineItemServiceInterface lineItemService =
        dfpServices.get(session, LineItemServiceInterface.class);

    // Create a statement to only select line items that need creatives.
    StatementBuilder statementBuilder = new StatementBuilder()
        .where("status = :status")
        .orderBy("id ASC")
        .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
        .withBindVariableValue("status", ComputedStatus.NEEDS_CREATIVES.toString());

    // Default for total result set size.
    int totalResultSetSize = 0;

    do {
      // Get line items by statement.
      LineItemPage page =
          lineItemService.getLineItemsByStatement(statementBuilder.toStatement());

      if (page.getResults() != null) {
        totalResultSetSize = page.getTotalResultSetSize();
        int i = page.getStartIndex();
        for (LineItem lineItem : page.getResults()) {
          System.out.printf(
              "%d) Line item with ID \"%d\" and name \"%s\" was found.\n", i++,
              lineItem.getId(), lineItem.getName());
        }
      }

      statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);

    System.out.printf("Number of results found: %d\n", totalResultSetSize);
  }
View Full Code Here


      Long userId = Long.parseLong("INSERT_USER_ID_HERE");

      // Create filter text to select user team associations by the user ID.
      String statementText = "WHERE userId = :userId LIMIT 500";
      Statement filterStatement =
        new StatementBuilder("")
            .putValue("userId", userId)
            .toStatement();

      // Get user team associations by statement.
      UserTeamAssociationPage page =
View Full Code Here

      long currentUserId = userService.getCurrentUser().getId();

      // Create filter text to select user team associations by the user ID.
      String statementText = "WHERE userId = :userId LIMIT 500";
      Statement filterStatement =
        new StatementBuilder("")
            .putValue("userId", currentUserId)
            .toStatement();

      // Get user team associations by statement.
      UserTeamAssociationPage page =
View Full Code Here

      Long userId = Long.parseLong("INSERT_USER_ID_HERE");

      // Create filter text to select user team associations by the user ID.
      String statementText = "WHERE userId = :userId LIMIT 500";
      Statement filterStatement =
        new StatementBuilder("")
            .putValue("userId", userId)
            .toStatement();

      // Set defaults for page and offset.
      UserTeamAssociationPage page = new UserTeamAssociationPage();
View Full Code Here

      // Get InventoryService.
      InventoryServiceInterface inventoryService =
          user.getService(DfpService.V201308.INVENTORY_SERVICE);

      // Create statement object to only select web ad unit sizes.
      Statement filterStatement = new StatementBuilder("WHERE targetPlatform = :targetPlatform")
          .putValue("targetPlatform", TargetPlatform.WEB.toString()).toStatement();

      // Get all ad unit sizes.
      AdUnitSize[] adUnitSizes = inventoryService.getAdUnitSizesByStatement(filterStatement);
View Full Code Here

      // Get the CustomTargetingService.
      CustomTargetingServiceInterface customTargetingService =
          user.getService(DfpService.V201311.CUSTOM_TARGETING_SERVICE);

      // Create a statement to only select predefined custom targeting keys.
      Statement filterStatement = new StatementBuilder("WHERE type = :type LIMIT 500").putValue(
          "type", CustomTargetingKeyType.PREDEFINED.toString()).toStatement();

      // Get custom targeting keys by statement.
      CustomTargetingKeyPage page =
          customTargetingService.getCustomTargetingKeysByStatement(filterStatement);
View Full Code Here

      Long masterCreativeId = Long.parseLong("INSERT_MASTER_CREATIVE_ID_HERE");

      // Create statement object to only select creative sets that have the
      // given master creative.
      Statement filterStatement =
          new StatementBuilder("WHERE masterCreativeId = :masterCreativeId LIMIT 500")
              .putValue("masterCreativeId", masterCreativeId).toStatement();

      // Get creative sets by statement.
      CreativeSetPage page = creativeSetService.getCreativeSetsByStatement(filterStatement);
View Full Code Here

      long customTargetingKeyId = Long.parseLong("INSERT_CUSTOM_TARGETING_KEY_ID_HERE");

      // Create statement to only select custom values by the given custom
      // targeting key ID.
      String statementText = "WHERE customTargetingKeyId = :customTargetingKeyId";
      StatementBuilder statementBuilder = new StatementBuilder("")
          .putValue("customTargetingKeyId", customTargetingKeyId);

      // Set defaults for page and offset.
      CustomTargetingValuePage page = new CustomTargetingValuePage();
      int offset = 0;
      List<Long> customTargetingValueIds = new ArrayList<Long>();

      do {
        // Create a statement to page through custom targeting values.
        statementBuilder.setQuery(statementText + " LIMIT 500 OFFSET " + offset);

        // Get custom targeting values by statement.
        page = customTargetingService.getCustomTargetingValuesByStatement(
            statementBuilder.toStatement());

        if (page.getResults() != null) {
          for (CustomTargetingValue customTargetingValue : page.getResults()) {
            customTargetingValueIds.add(customTargetingValue.getId());
          }
        }

        offset += 500;
      } while (offset < page.getTotalResultSetSize());

      System.out.println(
          "Number of custom targeting values to be deleted: " + customTargetingValueIds.size());

      if (customTargetingValueIds.size() > 0) {
        // Modify statement for action.
        statementBuilder.setQuery("WHERE customTargetingKeyId = :customTargetingKeyId AND id IN ("
            + StringUtils.join(customTargetingValueIds, ",") + ")");

        // Create action.
        DeleteCustomTargetingValues action = new DeleteCustomTargetingValues();

        // Perform action.
        UpdateResult result = customTargetingService.performCustomTargetingValueAction(
            action, statementBuilder.toStatement());

        // Display results.
        if (result != null && result.getNumChanges() > 0) {
          System.out.println("Number of custom targeting values deleted: "
              + result.getNumChanges());
View Full Code Here

      // Create statement text to select the active creative wrappers for the
      // given label.
      String statementText =
          "WHERE status = :status AND labelId = :labelId LIMIT 500";
      Statement filterStatement =
          new StatementBuilder(statementText)
              .putValue("status", CreativeWrapperStatus.ACTIVE.toString())
              .putValue("labelId", labelId)
              .toStatement();

      // Set defaults for page and offset.
View Full Code Here

      CreativeServiceInterface creativeService =
          user.getService(DfpService.V201311.CREATIVE_SERVICE);

      // Create a statement to only select image creatives.
      Statement filterStatement =
          new StatementBuilder("WHERE creativeType = :creativeType LIMIT 500")
              .putValue("creativeType", ImageCreative.class.getSimpleName()).toStatement();

      // Get creatives by statement.
      CreativePage page = creativeService.getCreativesByStatement(filterStatement);
View Full Code Here

TOP

Related Classes of com.google.api.ads.dfp.axis.utils.v201311.StatementBuilder

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.