Package com.google.api.ads.dfp.v201208

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


      // Get the LabelService.
      LabelServiceInterface labelService = user.getService(DfpService.V201208.LABEL_SERVICE);

      // Create statement text to select active labels.
      String statementText = "WHERE isActive = :isActive LIMIT 500";
      Statement filterStatement =
          new StatementBuilder("").putValue("isActive", true).toStatement();

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

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

        // Get labels by statement.
        page = labelService.getLabelsByStatement(filterStatement);

        if (page.getResults() != null) {
          int i = page.getStartIndex();
          for (Label label : page.getResults()) {
            System.out.println(i + ") Label with ID \"" + label.getId()
                + "\" and name \"" + label.getName()
                + "\" will be deactivated.");
            labelIds.add(label.getId());
            i++;
          }
        }

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

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

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

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

        // Perform action.
View Full Code Here


      // Set the ID of the ad unit to add to the teams.
      String adUnitId = "INSERT_AD_UNIT_ID_HERE";

      // Create a statement to select first 5 teams that aren't built-in.
      Statement filterStatement = new StatementBuilder("WHERE id > 0 LIMIT 5").toStatement();

      // Get the teams by statement.
      TeamPage page = teamService.getTeamsByStatement(filterStatement);

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

      CompanyServiceInterface companyService =
          user.getService(DfpService.V201208.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

      CreativeSetServiceInterface creativeSetService =
          user.getService(DfpService.V201208.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 LineItemCreativeAssociationService.
      LineItemCreativeAssociationServiceInterface licaService =
          user.getService(DfpService.V201208.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

      // Get the LabelService.
      LabelServiceInterface labelService = user.getService(DfpService.V201208.LABEL_SERVICE);

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

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

        // Get labels by statement.
        page = labelService.getLabelsByStatement(filterStatement);

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

      // Get the CompanyService.
      CompanyServiceInterface companyService =
          user.getService(DfpService.V201208.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 =
View Full Code Here

      InventoryServiceInterface inventoryService =
          user.getService(DfpService.V201208.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

          user.getService(DfpService.V201208.CUSTOM_FIELD_SERVICE);

      // Create statement to select only custom fields that apply to line items.
      String statementText =
          "WHERE entityType = :entityType LIMIT 500";
      Statement filterStatement =
          new StatementBuilder(statementText)
              .putValue("entityType", CustomFieldEntityType.LINE_ITEM.toString())
              .toStatement();

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

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

        // Get custom fields by statement.
        page = customFieldService.getCustomFieldsByStatement(filterStatement);

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

      // Set the ID of the master creative to get creative sets for.
      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

TOP

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