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

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


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

      // Get the UserTeamAssociationService.
      UserTeamAssociationServiceInterface userTeamAssociationService =
          user.getService(DfpService.V201208.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.V201208.USER_TEAM_ASSOCIATION_SERVICE);

      // Get the UserService.
      UserServiceInterface userService = user.getService(DfpService.V201208.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.V201208.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.V201208.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 DfpUser from "~/dfp.properties".
      DfpUser user = new DfpUser();

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

      // Set the IDs of the user and team to get the association for.
      Long userId = Long.parseLong("INSERT_USER_ID_HERE");
      Long teamId = Long.parseLong("INSERT_TEAM_ID_HERE");

      // Get the user team association.
      UserTeamAssociation userTeamAssociation =
          userTeamAssociationService.getUserTeamAssociation(teamId, userId);

      if (userTeamAssociation != null) {
        System.out.println("User team association between user with ID \""
            + userTeamAssociation.getUserId() + "\" and team with ID \""
            + userTeamAssociation.getTeamId() + "\" was found.");
View Full Code Here

   */
  public static Date fromDate(java.util.Date date) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(date);

    Date dfpDate = new Date();
    dfpDate.setYear(calendar.get(Calendar.YEAR));
    dfpDate.setMonth(calendar.get(Calendar.MONTH) + 1);
    dfpDate.setDay(calendar.get(Calendar.DAY_OF_MONTH));

    return dfpDate;
  }
View Full Code Here

   */
  public static Date fromDate(java.util.Date date) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(date);

    Date dfpDate = new Date();
    dfpDate.setYear(calendar.get(Calendar.YEAR));
    dfpDate.setMonth(calendar.get(Calendar.MONTH) + 1);
    dfpDate.setDay(calendar.get(Calendar.DAY_OF_MONTH));

    return dfpDate;
  }
View Full Code Here

   */
  public static Date fromDate(java.util.Date date) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(date);

    Date dfpDate = new Date();
    dfpDate.setYear(calendar.get(Calendar.YEAR));
    dfpDate.setMonth(calendar.get(Calendar.MONTH) + 1);
    dfpDate.setDay(calendar.get(Calendar.DAY_OF_MONTH));

    return dfpDate;
  }
View Full Code Here

   */
  public static Date fromDate(java.util.Date date) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(date);

    Date dfpDate = new Date();
    dfpDate.setYear(calendar.get(Calendar.YEAR));
    dfpDate.setMonth(calendar.get(Calendar.MONTH) + 1);
    dfpDate.setDay(calendar.get(Calendar.DAY_OF_MONTH));

    return dfpDate;
  }
View Full Code Here

   */
  public static Date fromDate(java.util.Date date) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(date);

    Date dfpDate = new Date();
    dfpDate.setYear(calendar.get(Calendar.YEAR));
    dfpDate.setMonth(calendar.get(Calendar.MONTH) + 1);
    dfpDate.setDay(calendar.get(Calendar.DAY_OF_MONTH));

    return dfpDate;
  }
View Full Code Here

TOP

Related Classes of com.google.api.ads.dfp.v201208.Date

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.