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

Examples of com.google.api.ads.dfp.v201302.Statement


      LineItemCreativeAssociationServiceInterface licaService =
          user.getService(DfpService.V201302.LINEITEMCREATIVEASSOCIATION_SERVICE);

      // Sets defaults for page and filterStatement.
      LineItemCreativeAssociationPage page = new LineItemCreativeAssociationPage();
      Statement filterStatement = new Statement();
      int offset = 0;

      do {
        // Create a statement to get all LICAs.
        filterStatement.setQuery("LIMIT 500 OFFSET " + offset);

        // Get LICAs by statement.
        page = licaService.getLineItemCreativeAssociationsByStatement(filterStatement);

        if (page.getResults() != null) {
View Full Code Here


      // targeting values for.
      long customTargetingKeyId = Long.parseLong("INSERT_CUSTOM_TARGETING_KEY_ID_HERE");

      // Create a statement to only select predefined custom targeting values
      // for a given key.
      Statement filterStatement =
          new StatementBuilder("WHERE customTargetingKeyId = :customTargetingKeyId LIMIT 500")
              .putValue("customTargetingKeyId", customTargetingKeyId).toStatement();

      // Get custom targeting values by statement.
      CustomTargetingValuePage page =
View Full Code Here

      InventoryServiceInterface inventoryService =
          user.getService(DfpService.V201302.INVENTORY_SERVICE);

      // Create statement text to select active ad units.
      String statementText = "WHERE status = :status LIMIT 500";
      Statement filterStatement =
          new StatementBuilder("")
              .putValue("status", InventoryStatus.ACTIVE.toString())
              .toStatement();

      // Set defaults for page and offset.
      AdUnitPage page = new AdUnitPage();
      int offset = 0;
      List<String> adUnitIds = new ArrayList<String>();

      do {
        // Create a statement to page through active ad units.
        filterStatement.setQuery(statementText + " OFFSET " + offset);

        // Get ad units by statement.
        page = inventoryService.getAdUnitsByStatement(filterStatement);

        if (page.getResults() != null) {
          int i = page.getStartIndex();
          for (AdUnit adUnit : page.getResults()) {
            System.out.println(i + ") Ad unit with ID \"" + adUnit.getId()
                + "\", name \"" + adUnit.getName()
                + "\", and status \"" + adUnit.getStatus() + "\" will be deactivated.");
            adUnitIds.add(adUnit.getId());
            i++;
          }
        }

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

      System.out.println("Number of ad units to be deactivated: " + adUnitIds.size());

      if (adUnitIds.size() > 0) {
        // Modify statement for action.
        filterStatement.setQuery("WHERE id IN (" + StringUtils.join(adUnitIds, ",") + ")");

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

        // Perform action.
View Full Code Here

      OrderServiceInterface orderService =
          user.getService(DfpService.V201302.ORDER_SERVICE);

      // Sets defaults for page and filter.
      OrderPage page = new OrderPage();
      Statement filterStatement = new Statement();
      int offset = 0;

      do {
        // Create a statement to get all orders.
        filterStatement.setQuery("LIMIT 500 OFFSET " + offset);

        // Get orders by statement.
        page = orderService.getOrdersByStatement(filterStatement);

        if (page.getResults() != null) {
View Full Code Here

      // Set the user to remove from its teams.
      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();
      int offset = 0;

      do {
        // Create a statement to page through user team associations.
        filterStatement.setQuery(statementText + " OFFSET " + offset);

        // Get user team associations by statement.
        page = userTeamAssociationService.getUserTeamAssociationsByStatement(filterStatement);

        if (page.getResults() != null) {
          int i = page.getStartIndex();
          for (UserTeamAssociation userTeamAssociation : page.getResults()) {
            System.out.println(i + ") User team association between user with ID \""
                + userTeamAssociation.getUserId() + "\" and team with ID \""
                + userTeamAssociation.getTeamId() + "\" will be deleted.");
            i++;
          }
        }

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

      System.out.println("Number of teams that the user will be removed from: "
          + page.getTotalResultSetSize());

      if (page.getTotalResultSetSize() > 0) {
        // Modify statement for action.
        filterStatement.setQuery("WHERE userId = :userId");

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

        // Perform action.
View Full Code Here

      // Set the line item to get LICAs by.
      Long lineItemId = Long.parseLong("INSERT_LINE_ITEM_ID_HERE");

      // Create statement text to select active LICAs for a given line item.
      String statementText = "WHERE lineItemId = :lineItemId and status = :status LIMIT 500";
      Statement filterStatement =
          new StatementBuilder("").putValue("lineItemId", lineItemId).putValue("status",
              LineItemCreativeAssociationStatus.ACTIVE.toString()).toStatement();

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

      do {
        // Create a statement to page through active LICAs.
        filterStatement.setQuery(statementText + " OFFSET " + offset);

        // Get LICAs by statement.
        page = licaService.getLineItemCreativeAssociationsByStatement(filterStatement);

        if (page.getResults() != null) {
          int i = page.getStartIndex();
          for (LineItemCreativeAssociation lica : page.getResults()) {
            System.out.println(i + ") LICA with line item ID \"" + lica.getLineItemId()
                + "\", creative ID \"" + lica.getCreativeId() + "\", and status \""
                + lica.getStatus() + "\" will be deactivated.");
            creativeIds.add(lica.getCreativeId());
            i++;
          }
        }

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

      System.out.println("Number of LICAs to be deactivated: " + creativeIds.size());

      if (creativeIds.size() > 0) {
        // Modify statement for action.
        filterStatement.setQuery("WHERE lineItemId = :lineItemId and creativeId IN ("
            + StringUtils.join(creativeIds, ",") + ")");

        // Create action.
        DeactivateLineItemCreativeAssociations action =
            new DeactivateLineItemCreativeAssociations();
View Full Code Here

      // Get the PlacementService.
      PlacementServiceInterface placementService =
          user.getService(DfpService.V201302.PLACEMENT_SERVICE);

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

      // Get placements by statement.
      PlacementPage page = placementService.getPlacementsByStatement(filterStatement);
View Full Code Here

      CustomTargetingServiceInterface customTargetingService =
          user.getService(DfpService.V201302.CUSTOM_TARGETING_SERVICE);

      // Sets defaults for page and filter.
      CustomTargetingKeyPage keyPage = new CustomTargetingKeyPage();
      Statement keyFilterStatement = new Statement();
      int keyOffset = 0;

      do {
        // Create a statement to get all custom targeting keys.
        keyFilterStatement.setQuery("LIMIT 500 OFFSET " + keyOffset);

        // Get custom targeting keys by statement.
        keyPage = customTargetingService.getCustomTargetingKeysByStatement(keyFilterStatement);

        if (keyPage.getResults() != null) {
          int i = keyPage.getStartIndex();
          for (CustomTargetingKey key : keyPage.getResults()) {
            System.out.println(i + ") Custom targeting key with ID \"" + key.getId()
                + "\", name \"" + key.getName() + "\", display name \"" + key.getDisplayName()
                + "\", and type \"" + key.getType() + "\" was found.");


            // Sets defaults for page and filter.
            CustomTargetingValuePage valuePage = new CustomTargetingValuePage();
            Statement valueFilterStatement = new Statement();
            int valueOffset = 0;

            do {
              // Create a statement to get all custom targeting values for a
              // custom targeting key (required) by its ID.
              valueFilterStatement.setQuery("WHERE customTargetingKeyId = " + key.getId()
                  + " LIMIT 500 OFFSET " + valueOffset);

              // Get custom targeting values by statement.
              valuePage =
                  customTargetingService.getCustomTargetingValuesByStatement(valueFilterStatement);
View Full Code Here

      now.add(Calendar.DATE, -3);
      Date threeDaysAgo = now.getTime();

      // Create statement to only select line items for the given order that
      // have been modified in the last 3 days.
      Statement filterStatement =
          new StatementBuilder(
              "WHERE lastModifiedDateTime >= :dateTimeString AND orderId = :orderId LIMIT 500")
              .putValue("orderId", orderId)
              .putValue("dateTimeString", DATE_TIME_FORMAT.format(threeDaysAgo)).toStatement();
View Full Code Here

      SuggestedAdUnitServiceInterface suggestedAdUnitService =
          user.getService(DfpService.V201302.SUGGESTED_AD_UNIT_SERVICE);

      // Create statement to select all suggested ad units with 50 or more
      // requests.
      Statement filterStatement =
          new StatementBuilder("WHERE numRequests >= :numRequests").putValue("numRequests", 50L)
              .toStatement();

      // Get suggested ad units by statement.
      SuggestedAdUnitPage page =
View Full Code Here

TOP

Related Classes of com.google.api.ads.dfp.v201302.Statement

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.