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

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


   * @param date the DFP {@code Date} object to convert to a Java {@code Date}
   * @param timeZoneId the timezone of the date
   * @return the DFP {@code Date} object as a Java {@code Date} in the timezone
   */
  public static java.util.Date toDate(Date date, String timeZoneId) {
    return DateTimeUtils.toDate(new DateTime(date, 0, 0, 0, timeZoneId));
  }
View Full Code Here


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

    DateTime dfpDateTime = new DateTime();
    dfpDateTime.setDate(DateUtils.fromDate(date));
    dfpDateTime.setHour(calendar.get(Calendar.HOUR_OF_DAY));
    dfpDateTime.setMinute(calendar.get(Calendar.MINUTE));
    dfpDateTime.setSecond(calendar.get(Calendar.SECOND));

    return dfpDateTime;
  }
View Full Code Here

   * @param timeZoneId the timezone of the publisher
   * @return a {@code DateTime} object representing the present date in the
   *     publisher's timezone
   */
  public static DateTime today(String timeZoneId) {
    DateTime dateTime =
        fromDate(Calendar.getInstance(TimeZone.getTimeZone(timeZoneId)).getTime());
    dateTime.setHour(0);
    dateTime.setMinute(0);
    dateTime.setSecond(0);
    return dateTime;
  }
View Full Code Here

      } else if (value instanceof String) {
        return new TextValue(null, (String) value);
      } else if (value instanceof Long) {
        return new NumberValue(null, value.toString());
      } else if (value instanceof DateTime) {
        return new DateTimeValue(null, (DateTime) value);
      } else if (value instanceof Date) {
        return new DateValue(null, (Date) value);
      } else {
        throw new IllegalArgumentException("Unexpected Value type ["
            + value.getClass() + "]");
View Full Code Here

      } else if (value instanceof Long) {
        return new NumberValue(null, value.toString());
      } else if (value instanceof DateTime) {
        return new DateTimeValue(null, (DateTime) value);
      } else if (value instanceof Date) {
        return new DateValue(null, (Date) value);
      } else {
        throw new IllegalArgumentException("Unexpected Value type ["
            + value.getClass() + "]");
      }
    }
View Full Code Here

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

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

        // Perform action.
        UpdateResult result = labelService.performLabelAction(action, filterStatement);

        // Display results.
View Full Code Here

      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.
View Full Code Here

      // Get the LabelService.
      LabelServiceInterface labelService = user.getService(DfpService.V201306.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) {
          int i = page.getStartIndex();
          for (Label label : page.getResults()) {
            List<String> labelTypes = new ArrayList<String>();
            for (LabelType labelType : label.getTypes()) {
              labelTypes.add(labelType.toString());
            }
            System.out.println(i + ") Label with ID \"" + label.getId()
                + "\", name \"" + label.getName()
                + "\", and types {" + StringUtils.join(labelTypes, ",") + "} was found.");
            i++;
          }
        }

        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 DfpUser from "~/dfp.properties".
      DfpUser user = new DfpUser();

      // Get the LabelService.
      LabelServiceInterface labelService = user.getService(DfpService.V201306.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.
        UpdateResult result = labelService.performLabelAction(action, filterStatement);

        // Display results.
        if (result != null && result.getNumChanges() > 0) {
          System.out.println("Number of labels deactivated: " + result.getNumChanges());
        } else {
View Full Code Here

      return new TextValue(null, null);
    } else {
      if (value instanceof Boolean) {
        return new BooleanValue(null, (Boolean) value);
      } else if (value instanceof Double) {
        return new NumberValue(null, value.toString());
      } else if (value instanceof String) {
        return new TextValue(null, (String) value);
      } else if (value instanceof Long) {
        return new NumberValue(null, value.toString());
      } else if (value instanceof DateTime) {
        return new DateTimeValue(null, (DateTime) value);
      } else if (value instanceof Date) {
        return new DateValue(null, (Date) value);
      } else {
View Full Code Here

TOP

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

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.