Package com.google.api.ads.dfp.v201308

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


     
      // 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.
      CreativeWrapperPage page = new CreativeWrapperPage();
      int offset = 0;
      int i = 0;
      List<Long> creativeWrapperIds = new ArrayList<Long>();

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

        // Get creative wrappers by statement.
        page = creativeWrapperService.getCreativeWrappersByStatement(filterStatement);

        if (page.getResults() != null) {
          for (CreativeWrapper creativeWrapper: page.getResults()) {
            System.out.printf("%d) Creative wrapper with ID \"%s\" applying to label"
                + " \"%s\" will be deactivated.\n", i++, creativeWrapper.getId(),
                creativeWrapper.getLabelId());
            creativeWrapperIds.add(creativeWrapper.getId());
          }
        }

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

      System.out.println(
          "Number of creative wrappers to be deactivated: " + creativeWrapperIds.size());

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

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


      LineItemCreativeAssociationServiceInterface licaService =
          user.getService(DfpService.V201308.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

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

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

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

        // Get suggested ad units by statement.
        page = suggestedAdUnitService.getSuggestedAdUnitsByStatement(filterStatement);

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

      // Set the ID of the user to deactivate
      Long userId = Long.parseLong("INSERT_USER_ID_HERE");

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

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

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

        // Get users by statement.
        page = userService.getUsersByStatement(filterStatement);

        if (page.getResults() != null) {
          int i = page.getStartIndex();
          for (User userResult : page.getResults()) {
            System.out.println(i + ") User with ID \"" + userResult.getId()
                + "\", email \"" + userResult.getEmail()
                + "\", and status \"" + (userResult.getIsActive() ? "ACTIVE" : "INACTIVE")
                + "\" will be deactivated.");
            userIds.add(userResult.getId());
            i++;
          }
        }

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

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

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

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

        // Perform action.
View Full Code Here

      // Get the CreativeService.
      CreativeServiceInterface creativeService =
          user.getService(DfpService.V201308.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

      CreativeWrapperServiceInterface creativeWrapperService =
          user.getService(DfpService.V201308.CREATIVE_WRAPPER_SERVICE);

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

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

        // Get creative wrappers by statement.
        page = creativeWrapperService.getCreativeWrappersByStatement(filterStatement);

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

      CreativeSetServiceInterface creativeSetService =
          user.getService(DfpService.V201308.CREATIVE_SET_SERVICE);

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

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

        // Get creative sets by statement.
        page = creativeSetService.getCreativeSetsByStatement(filterStatement);

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

      // Get the CreativeService.
      CreativeServiceInterface creativeService =
          user.getService(DfpService.V201308.CREATIVE_SERVICE);

      // Create a statement to get all 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

      // Get UserService.
      UserServiceInterface userService =
          user.getService(DfpService.V201308.USER_SERVICE);

      // Create a statement to get all users sorted by name.
      Statement filterStatement = new Statement("ORDER BY name LIMIT 500", null);

      // Get users by statement.
      UserPage page = userService.getUsersByStatement(filterStatement);

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

TOP

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