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

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


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

      // Get the CreativeTemplateService.
      CreativeTemplateServiceInterface creativeTemplateService =
          user.getService(DfpService.V201208.CREATIVE_TEMPLATE_SERVICE);

      // Set the ID of the creative template to get.
      Long creativeTemplateId = Long.parseLong("INSERT_CREATIVE_TEMPLATE_ID_HERE");

      // Get the creative template.
      CreativeTemplate creativeTemplate =
          creativeTemplateService.getCreativeTemplate(creativeTemplateId);

      if (creativeTemplate != null) {
        System.out.println("Creative template with ID \"" + creativeTemplate.getId()
             + "\", name \"" + creativeTemplate.getName()
             + "\", and type \"" + creativeTemplate.getType() + "\" was found.");
View Full Code Here


   */
  private static String getCustomCriteriaSetString(CustomCriteriaNode root, int level) {
    StringBuilder sb = new StringBuilder();
    sb.append(StringUtils.repeat("\t", level));
    if (root instanceof CustomCriteria) {
      CustomCriteria customCriteria = (CustomCriteria) root;
      sb.append(String.format("Custom criteria: operator: [%s] key: [%s] values: [%s]\n",
          customCriteria.getOperator(), customCriteria.getKeyId(),
          StringUtils.join(ArrayUtils.toObject(customCriteria.getValueIds()), ",")));
      return sb.toString();
    } else if (root instanceof CustomCriteriaSet){
      CustomCriteriaSet customCriteriaSet = (CustomCriteriaSet) root;
      sb.append(String.format("Custom criteria set: operator: [%s] children: \n",
          customCriteriaSet.getLogicalOperator()));
View Full Code Here

      Long[] customCriteriaIds3 =
        new Long[] {Long.parseLong("INSERT_CUSTOM_TARGETING_KEY_ID_HERE"),
            Long.parseLong("INSERT_CUSTOM_TARGETING_VALUE_ID_HERE")};

      // Create custom criteria.
      CustomCriteria customCriteria1 = new CustomCriteria();
      customCriteria1.setKeyId(customCriteriaIds1[0]);
      customCriteria1.setValueIds(new long[] {customCriteriaIds1[1]});
      customCriteria1.setOperator(CustomCriteriaComparisonOperator.IS);

      CustomCriteria customCriteria2 = new CustomCriteria();
      customCriteria2.setKeyId(customCriteriaIds2[0]);
      customCriteria2.setValueIds(new long[] {customCriteriaIds2[1]});
      customCriteria2.setOperator(CustomCriteriaComparisonOperator.IS_NOT);

      CustomCriteria customCriteria3 = new CustomCriteria();
      customCriteria3.setKeyId(customCriteriaIds3[0]);
      customCriteria3.setValueIds(new long[] {customCriteriaIds3[1]});
      customCriteria3.setOperator(CustomCriteriaComparisonOperator.IS);

      // Create the custom criteria set that will resemble:
      //
      // (customCriteria1.key == customCriteria1.value OR
      //     (customCriteria2.key != customCriteria2.value AND
View Full Code Here

          Long.parseLong("INSERT_CONTENT_CUSTOM_TARGETING_KEY_ID_HERE");
      Long contentCustomTargetingValueId =
          Long.parseLong("INSERT_CONTENT_CUSTOM_TARGETING_VALUE_ID_HERE");

      // Create custom criteria for the content metadata targeting.
      CustomCriteria contentCustomCriteria = new CustomCriteria();
      contentCustomCriteria.setKeyId(contentCustomTargetingKeyId);
      contentCustomCriteria.setValueIds(new long[] {contentCustomTargetingValueId});
      contentCustomCriteria.setOperator(CustomCriteriaComparisonOperator.IS);

      // Create custom criteria set.
      CustomCriteriaSet customCriteriaSet = new CustomCriteriaSet();
      customCriteriaSet.setChildren(new CustomCriteriaNode[] {contentCustomCriteria});
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

   * @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 {
        throw new IllegalArgumentException("Unexpected Value type ["
            + value.getClass() + "]");
      }
    }
View Full Code Here

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

TOP

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

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.