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

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


      // Create statement text to select all draft and pending orders that
      // haven't ended and aren't archived.
      String statementText =
          "WHERE status IN ('" + OrderStatus.DRAFT + "','" + OrderStatus.PENDING_APPROVAL
              + "') AND endDateTime >= :today AND isArchived = FALSE LIMIT 500";
      Statement filterStatement =
          new StatementBuilder(statementText).putValue("today",
              DATE_TIME_FORMAT.format(new Date())).toStatement();

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

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

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

        if (page.getResults() != null) {
          for (Order order : page.getResults()) {
            System.out.println(i + ") Order with ID \""
                + order.getId() + "\", name \"" + order.getName()
                + "\", and status \"" + order.getStatus()
                + "\" will be approved.");
            orderIds.add(order.getId());
            i++;
          }
        }

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

      System.out.println("Number of orders to be approved: " + orderIds.size());

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

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

        // Perform action.
View Full Code Here


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

      // Create a statement to get all custom targeting keys.
      Statement filterStatement = new Statement("LIMIT 500", null);

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

      // Set the user to set to read only access within 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();

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

      // Get the LineItemCreativeAssociationService.
      LineItemCreativeAssociationServiceInterface licaService =
          user.getService(DfpService.V201302.LINEITEMCREATIVEASSOCIATION_SERVICE);

      // Create a statement to get all LICAs.
      Statement filterStatement = new Statement("LIMIT 500", null);

      // Get LICAs by statement.
      LineItemCreativeAssociationPage page =
          licaService.getLineItemCreativeAssociationsByStatement(filterStatement);
View Full Code Here

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

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

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

        // Get activity groups by statement.
        page = activityGroupService.getActivityGroupsByStatement(filterStatement);

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

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

      // Create a statement to only select 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

      // Get the current user.
      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.
View Full Code Here

      // Set the ID of the advertiser (company) to get orders for.
      Long advertiserId = Long.parseLong("INSERT_ADVERTISER_COMPANY_ID_HERE");

      // Create a statement to only select orders for a given advertiser.
      Statement filterStatement =
        new StatementBuilder("WHERE advertiserId = :advertiserId LIMIT 500")
            .putValue("advertiserId", advertiserId).toStatement();

      // Get orders by statement.
      OrderPage page = orderService.getOrdersByStatement(filterStatement);
View Full Code Here

      Long orderId = Long.parseLong("INSERT_ORDER_ID_HERE");

      // Create a statement to only select line items from the specified order
      // that are in the approved (needs creatives) state.
      String statementText = "WHERE orderID = :orderId and status = :status LIMIT 500";
      Statement filterStatement =
          new StatementBuilder("")
              .putValue("orderId", orderId)
              .putValue("status", ComputedStatus.NEEDS_CREATIVES.toString())
              .toStatement();

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

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

        // Get line items by statement.
        page = lineItemService.getLineItemsByStatement(filterStatement);

        if (page.getResults() != null) {
          for (LineItemSummary lineItem : page.getResults()) {
            // Archived line items cannot be activated.
            if (!lineItem.getIsArchived()) {
              System.out.println(i + ") Line item with ID \""
                  + lineItem.getId() + "\", belonging to order ID \""
                  + lineItem.getOrderId() + "\", and name \"" + lineItem.getName()
                  + "\" will be activated.");
              lineItemIds.add(lineItem.getId());
              i++;
            }
          }
        }

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

      System.out.println("Number of line items to be activated: " + lineItemIds.size());

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

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

        // Perform action.
View Full Code Here

      PlacementServiceInterface placementService =
          user.getService(DfpService.V201302.PLACEMENT_SERVICE);

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

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

        // Get ad units by filter.
        page = placementService.getPlacementsByStatement(filterStatement);

        if (page.getResults() != null) {
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.