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

Examples of com.google.api.ads.dfp.lib.utils.v201306.ReportUtils


      // haven't ended and aren't archived.
      String statementText =
          "WHERE status IN ('" + OrderStatus.DRAFT + "','" + OrderStatus.PENDING_APPROVAL
              + "') AND endDateTime >= :today AND isArchived = FALSE LIMIT 500";
      Statement filterStatement =
          new StatementBuilder(statementText).putValue("today",
              DATE_TIME_FORMAT.format(new Date())).toStatement();

      // Set defaults for page and offset.
      OrderPage page = new OrderPage();
      int offset = 0;
View Full Code Here


      int offset = 0;

      // Create a statement to only select line items from a given order.
      String filterText = "WHERE orderId = :orderId LIMIT 500";
      Statement filterStatement =
          new StatementBuilder(filterText).putValue("orderId", orderId).toStatement();

      // Collect all line item custom field IDs for an order.
      Set<Long> customFieldIds = new HashSet<Long>();
      do {
        filterStatement.setQuery(filterText + " OFFSET " + offset);

        // Get line items by statement.
        page = lineItemService.getLineItemsByStatement(filterStatement);

        // Get custom field IDs from the line items of an order.
        if (page.getResults() != null) {
          for (LineItem lineItem : page.getResults()) {
            if (lineItem.getCustomFieldValues() != null) {
              for (BaseCustomFieldValue customFieldValue : lineItem.getCustomFieldValues()) {
                customFieldIds.add(customFieldValue.getCustomFieldId());
              }
            }
          }
        }

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

      // Get the ReportService.
      ReportServiceInterface reportService = user.getService(DfpService.V201306.REPORT_SERVICE);

      // Create statement to filter for an order.
      filterStatement =
          new StatementBuilder("WHERE ORDER_ID = :orderId").putValue("orderId", orderId)
              .toStatement();

      // Create report job.
      ReportJob reportJob = new ReportJob();
View Full Code Here

      Long orderId = Long.parseLong("INSERT_ORDER_ID_HERE");

      // Create statement to filter for an order.
      Statement filterStatement =
          new StatementBuilder("WHERE ORDER_ID = :id").putValue("id", orderId).toStatement();

      // Create report job.
      ReportJob reportJob = new ReportJob();

      // Create report query.
View Full Code Here

      Long orderId = Long.parseLong("INSERT_ORDER_ID_HERE");

      // Create a statement to only select line items that need creatives from a
      // given order.
      Statement filterStatement =
          new StatementBuilder("WHERE orderId = :orderId AND status = :status LIMIT 500")
              .putValue("orderId", orderId)
              .putValue("status", ComputedStatus.NEEDS_CREATIVES.toString())
              .toStatement();

      // Get line items by statement.
View Full Code Here

      PlacementServiceInterface placementService =
          user.getService(DfpService.V201306.PLACEMENT_SERVICE);

      // Create a statement to only select active placements.
      Statement filterStatement =
        new StatementBuilder("WHERE status = :status LIMIT 500")
            .putValue("status", InventoryStatus.ACTIVE.toString()).toStatement();

      // Get placements by statement.
      PlacementPage page = placementService.getPlacementsByStatement(filterStatement);
View Full Code Here

          user.getService(DfpService.V201306.PLACEMENT_SERVICE);

      // Create statement text to select active placements.
      String statementText = "WHERE status = :status LIMIT 500";
      Statement filterStatement =
          new StatementBuilder("")
              .putValue("status", InventoryStatus.ACTIVE.toString())
              .toStatement();

      // Set defaults for page and offset.
      PlacementPage page = new PlacementPage();
View Full Code Here

    System.out.println("Running report job.");

    // Run report job.
    long reportJobId = reportService.runReportJob(reportJob).getId();

    final ReportUtils reportUtils = new ReportUtils(reportService, reportJobId);

    // Change to your file location.
    final String gzCsvPath = "/path/to/filename.csv.gz";

    // Change to use synchronous or asynchronous downloading.
    boolean useSynchronous = true;

    if (useSynchronous) {
      // Download gzipped CSV synchronously.
      try {
        System.out.println("Waiting for report to finish.");
        if (reportUtils.waitForReportReady()) {
          System.out.print("Downloading report to " + gzCsvPath + "...");
          reportUtils.downloadReport(ExportFormat.CSV_DUMP, gzCsvPath);
          System.out.println("done.");
        } else {
          System.out.println("The report failed to schedule.");
        }
      } catch (IOException e) {
        System.out.println("Report did not download for reason: " + e.getMessage());
        e.printStackTrace();
      }
    } else {
      // Download gzipped CSV asynchronously.
      Thread reportThread = reportUtils.whenReportReady(new ReportCallback() {
        public void onSuccess() {
          try {
            System.out.print("Downloading report to " + gzCsvPath + "...");
            reportUtils.downloadReport(ExportFormat.CSV_DUMP, gzCsvPath);
            System.out.println("done.");
          } catch (IOException e) {
            System.out.println("Report did not download for reason: " + e.getMessage());
            e.printStackTrace();
          }
View Full Code Here

    System.out.println("Running report job.");

    // Run report job.
    long reportJobId = reportService.runReportJob(reportJob).getId();

    final ReportUtils reportUtils = new ReportUtils(reportService, reportJobId);

    // Change to use synchronous or asynchronous downloading.
    boolean useSynchronous = true;

    if (useSynchronous) {
      // Get CSV synchronously.
      try {
        System.out.println("Waiting for report to finish.");
        if (reportUtils.waitForReportReady()) {
          System.out.println("Retrieving CSV...");
          String csvString = reportUtils.getReport(ExportFormat.CSV_DUMP);

          // Get CSV as list of string arrays.
          List<String[]> csv = CsvUtils.getCsvDataArray(new StringReader(csvString), true);

          // Output the csv.
          System.out.println(csvString);
        } else {
          System.out.println("The report failed to schedule.");
        }
      } catch (IOException e) {
        System.out.println("Report did not download for reason: " + e.getMessage());
        e.printStackTrace();
      }
    } else {
      // Get XML asynchronously.
      Thread reportThread = reportUtils.whenReportReady(new ReportCallback() {
        public void onSuccess() {
          try {
            System.out.println("Retrieving CSV...");
            String csvString = reportUtils.getReport(ExportFormat.CSV_DUMP);

            // Get CSV as list of string arrays.
            List<String[]> csv = CsvUtils.getCsvDataArray(new StringReader(csvString), true);

            // Output the csv.
View Full Code Here

    System.out.println("Running report job.");

    // Run report job.
    long reportJobId = reportService.runReportJob(reportJob).getId();

    final ReportUtils reportUtils = new ReportUtils(reportService, reportJobId);

    // Change to your file location.
    final String gzCsvPath = "/path/to/filename.csv.gz";

    // Change to use synchronous or asynchronous downloading.
    boolean useSynchronous = true;

    if (useSynchronous) {
      // Download gzipped CSV synchronously.
      try {
        System.out.println("Waiting for report to finish.");
        if (reportUtils.waitForReportReady()) {
          System.out.print("Downloading report to " + gzCsvPath + "...");
          reportUtils.downloadReport(ExportFormat.CSV_DUMP, gzCsvPath);
          System.out.println("done.");
        } else {
          System.out.println("The report failed to schedule.");
        }
      } catch (IOException e) {
        System.out.println("Report did not download for reason: " + e.getMessage());
        e.printStackTrace();
      }
    } else {
      // Download gzipped CSV asynchronously.
      Thread reportThread = reportUtils.whenReportReady(new ReportCallback() {
        public void onSuccess() {
          try {
            System.out.print("Downloading report to " + gzCsvPath + "...");
            reportUtils.downloadReport(ExportFormat.CSV_DUMP, gzCsvPath);
            System.out.println("done.");
          } catch (IOException e) {
            System.out.println("Report did not download for reason: " + e.getMessage());
            e.printStackTrace();
          }
View Full Code Here

    System.out.println("Running report job.");

    // Run report job.
    long reportJobId = reportService.runReportJob(reportJob).getId();

    final ReportUtils reportUtils = new ReportUtils(reportService, reportJobId);

    // Change to use synchronous or asynchronous downloading.
    boolean useSynchronous = true;

    if (useSynchronous) {
      // Get CSV synchronously.
      try {
        System.out.println("Waiting for report to finish.");
        if (reportUtils.waitForReportReady()) {
          System.out.println("Retrieving CSV...");
          String csvString = reportUtils.getReport(ExportFormat.CSV_DUMP);

          // Get CSV as list of string arrays.
          List<String[]> csv = CsvUtils.getCsvDataArray(new StringReader(csvString), true);

          // Output the csv.
          System.out.println(csvString);
        } else {
          System.out.println("The report failed to schedule.");
        }
      } catch (IOException e) {
        System.out.println("Report did not download for reason: " + e.getMessage());
        e.printStackTrace();
      }
    } else {
      // Get XML asynchronously.
      Thread reportThread = reportUtils.whenReportReady(new ReportCallback() {
        public void onSuccess() {
          try {
            System.out.println("Retrieving CSV...");
            String csvString = reportUtils.getReport(ExportFormat.CSV_DUMP);

            // Get CSV as list of string arrays.
            List<String[]> csv = CsvUtils.getCsvDataArray(new StringReader(csvString), true);

            // Output the csv.
View Full Code Here

TOP

Related Classes of com.google.api.ads.dfp.lib.utils.v201306.ReportUtils

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.