Package com.google.api.ads.dfp.v201306

Examples of com.google.api.ads.dfp.v201306.ActivityGroupPage


      // Get DfpUser from "~/dfp.properties".
      DfpUser user = new DfpUser();

      // Get the UserTeamAssociationService.
      UserTeamAssociationServiceInterface userTeamAssociationService =
          user.getService(DfpService.V201306.USER_TEAM_ASSOCIATION_SERVICE);

      // 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.
      UserTeamAssociationPage page =
          userTeamAssociationService.getUserTeamAssociationsByStatement(filterStatement);

      if (page.getResults() != null) {
        UserTeamAssociation[] userTeamAssociations = page.getResults();

        // Update each local user team association to read only access.
        for (UserTeamAssociation userTeamAssociation : userTeamAssociations) {
          userTeamAssociation.setOverriddenTeamAccessType(TeamAccessType.READ_ONLY);
        }

        // Update the user team associations on the server.
        userTeamAssociations =
            userTeamAssociationService.updateUserTeamAssociations(userTeamAssociations);

        if (userTeamAssociations != null) {
          for (UserTeamAssociation userTeamAssociation : userTeamAssociations) {
            System.out.println("User team association between user with ID \""
                + userTeamAssociation.getUserId() + "\" and team with ID \""
View Full Code Here


      // Get DfpUser from "~/dfp.properties".
      DfpUser user = new DfpUser();

      // Get the UserTeamAssociationService.
      UserTeamAssociationServiceInterface userTeamAssociationService =
          user.getService(DfpService.V201306.USER_TEAM_ASSOCIATION_SERVICE);

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

      // 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.
      UserTeamAssociationPage page =
          userTeamAssociationService.getUserTeamAssociationsByStatement(filterStatement);

      // Display results.
      if (page.getResults() != null) {
        int i = page.getStartIndex();
        for (UserTeamAssociation userTeamAssociation : page.getResults()) {
View Full Code Here

      // Get DfpUser from "~/dfp.properties".
      DfpUser user = new DfpUser();

      // Get the UserTeamAssociationService.
      UserTeamAssociationServiceInterface userTeamAssociationService =
          user.getService(DfpService.V201306.USER_TEAM_ASSOCIATION_SERVICE);

      // Set the users and team to add them to.
      Long teamId = Long.parseLong("INSERT_TEAM_ID_HERE");
      Long[] userIds = new Long[] {Long.parseLong("INSERT_USER_ID_HERE")};

      // Create an array to store local user team association objects.
      UserTeamAssociation[] userTeamAssociations = new UserTeamAssociation[userIds.length];

      // For each user, associate it with the given team.
      int i = 0;
      for (Long userId : userIds) {
        UserTeamAssociation userTeamAssociation = new UserTeamAssociation();
        userTeamAssociation.setUserId(userId);
        userTeamAssociation.setTeamId(teamId);
        userTeamAssociations[i++] = userTeamAssociation;
      }

      // Create the user team associations on the server.
      userTeamAssociations =
          userTeamAssociationService.createUserTeamAssociations(userTeamAssociations);

      if (userTeamAssociations != null) {
        for (UserTeamAssociation userTeamAssociation : userTeamAssociations) {
          System.out.println("A user team association between user with ID \""
              + userTeamAssociation.getUserId() + "\" and team with ID \""
View Full Code Here

      // Get DfpUser from "~/dfp.properties".
      DfpUser user = new DfpUser();

      // Get the UserTeamAssociationService.
      UserTeamAssociationServiceInterface userTeamAssociationService =
          user.getService(DfpService.V201306.USER_TEAM_ASSOCIATION_SERVICE);

      // 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.
        UpdateResult result =
            userTeamAssociationService.performUserTeamAssociationAction(action, filterStatement);

        // Display results.
        if (result != null && result.getNumChanges() > 0) {
          System.out.println("Number of teams that the user was removed from: "
              + result.getNumChanges());
View Full Code Here

    // Get the ActivityGroupService.
    ActivityGroupServiceInterface activityGroupService =
        user.getService(DfpService.V201308.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) {
        for (ActivityGroup activityGroup : page.getResults()) {
          activityGroupIds.add(activityGroup.getId());
        }
      }

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

    return activityGroupIds;
  }
View Full Code Here

      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);

      if (page.getResults() != null) {
        int i = page.getStartIndex();
        for (ActivityGroup activityGroup : page.getResults()) {
          System.out.printf(
              "%s) Activity group with ID \"%d\" and name \"%s\" was found.\n", i++,
              activityGroup.getId(), activityGroup.getName());
        }
      }

      System.out.println("Number of results found: " + page.getTotalResultSetSize());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

      // Get the ActivityGroupService.
      ActivityGroupServiceInterface activityGroupService =
          user.getService(DfpService.V201308.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) {
          int i = page.getStartIndex();
          for (ActivityGroup activityGroup : page.getResults()) {
            System.out.printf(
                "%s) Activity group with ID \"%d\" and name \"%s\" was found.\n", i++,
                activityGroup.getId(), activityGroup.getName());
          }
        }

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

      System.out.println("Number of results found: " + page.getTotalResultSetSize());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

    // Get the ActivityGroupService.
    ActivityGroupServiceInterface activityGroupService =
        user.getService(DfpService.V201311.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) {
        for (ActivityGroup activityGroup : page.getResults()) {
          activityGroupIds.add(activityGroup.getId());
        }
      }

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

    return activityGroupIds;
  }
View Full Code Here

      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);

      if (page.getResults() != null) {
        int i = page.getStartIndex();
        for (ActivityGroup activityGroup : page.getResults()) {
          System.out.printf(
              "%s) Activity group with ID \"%d\" and name \"%s\" was found.\n", i++,
              activityGroup.getId(), activityGroup.getName());
        }
      }

      System.out.println("Number of results found: " + page.getTotalResultSetSize());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

      // Get the ActivityGroupService.
      ActivityGroupServiceInterface activityGroupService =
          user.getService(DfpService.V201311.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) {
          int i = page.getStartIndex();
          for (ActivityGroup activityGroup : page.getResults()) {
            System.out.printf(
                "%s) Activity group with ID \"%d\" and name \"%s\" was found.\n", i++,
                activityGroup.getId(), activityGroup.getName());
          }
        }

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

      System.out.println("Number of results found: " + page.getTotalResultSetSize());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

TOP

Related Classes of com.google.api.ads.dfp.v201306.ActivityGroupPage

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.