Package com.google.api.ads.dfp.lib.utils.v201302

Examples of com.google.api.ads.dfp.lib.utils.v201302.StatementBuilder


     
      // Create a statement to only select active third party slots.
      String statementText = "WHERE status = :status AND "
          + "companyId = :companyId LIMIT 500";
      Statement filterStatement =
          new StatementBuilder("")
            .putValue("status", ThirdPartySlotStatus.ACTIVE.toString())
            .putValue("companyId", companyId)
            .toStatement();

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


          user.getService(DfpService.V201302.THIRD_PARTY_SLOT_SERVICE);

      // Sets defaults for page and filterStatement.
      ThirdPartySlotPage page = new ThirdPartySlotPage();
      Statement filterStatement =
          new StatementBuilder("WHERE status = :status LIMIT 500 ").putValue("status",
              ThirdPartySlotStatus.ARCHIVED.toString()).toStatement();

      // Get third party slots by statement.
      page = thirdPartySlotService.getThirdPartySlotsByStatement(filterStatement);
View Full Code Here

      int resultSetSize = 0;
      List<Row> allRows = new ArrayList<Row>();
      ResultSet resultSet;
     
      do {
        StatementBuilder statementBuilder =
            new StatementBuilder(selectStatement + " OFFSET " + offset);
       
        // Get all cities.
        resultSet = pqlService.select(statementBuilder.toStatement());

        // Collect all cities from each page.
        allRows.addAll(Arrays.asList(resultSet.getRows()));
       
        // Display results.
View Full Code Here

      // Get content browse custom targeting key ID.
      long contentBrowseCustomTargetingKeyId =
          networkService.getCurrentNetwork().getContentBrowseCustomTargetingKeyId();

      // Create a statement to select the categories matching the name comedy.
      Statement categoryFilterStatement = new StatementBuilder(
          "WHERE customTargetingKeyId = :contentBrowseCustomTargetingKeyId " +
          " and name = :category LIMIT 1")
          .putValue("contentBrowseCustomTargetingKeyId", contentBrowseCustomTargetingKeyId)
          .putValue("category", "comedy").toStatement();
View Full Code Here

      // Get the CustomTargetingService.
      CustomTargetingServiceInterface customTargetingService =
          user.getService(DfpService.V201302.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

          user.getService(DfpService.V201302.COMPANY_SERVICE);

      // Create a statement to only select companies that are advertisers sorted
      // by name.
      Statement filterStatement =
          new StatementBuilder("WHERE type = :type ORDER BY name LIMIT 500")
              .putValue("type", CompanyType.ADVERTISER.toString()).toStatement();

      // Get companies by statement.
      CompanyPage page = companyService.getCompaniesByStatement(filterStatement);
View Full Code Here

      // Get the effective root ad unit ID of the network.
      String effectiveRootAdUnitId = networkService.getCurrentNetwork().getEffectiveRootAdUnitId();

      // Create a statement to select the children of the effective root ad
      // unit.
      Statement filterStatement = new StatementBuilder("WHERE parentId = :id LIMIT 500")
          .putValue("id", effectiveRootAdUnitId).toStatement();

      // Get ad units by statement.
      AdUnitPage page = inventoryService.getAdUnitsByStatement(filterStatement);
View Full Code Here

      ActivityGroupServiceInterface activityGroupService =
          user.getService(DfpService.V201302.ACTIVITY_GROUP_SERVICE);

      // Create a statement to only select active activity groups.
      Statement filterStatement =
          new StatementBuilder("WHERE status = :status LIMIT 500")
              .putValue("status", ActivityGroupStatus.ACTIVE.toString()).toStatement();

      // Get activity groups by statement.
      ActivityGroupPage page = activityGroupService.getActivityGroupsByStatement(filterStatement);
View Full Code Here

      CompanyServiceInterface companyService =
          user.getService(DfpService.V201302.COMPANY_SERVICE);

      // Create a statement to only select companies that are advertisers.
      Statement filterStatement =
          new StatementBuilder("WHERE type = :type LIMIT 500")
              .putValue("type", CompanyType.ADVERTISER.toString()).toStatement();

      // Get the companies by statement.
      CompanyPage page =
          companyService.getCompaniesByStatement(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

TOP

Related Classes of com.google.api.ads.dfp.lib.utils.v201302.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.