Example usage for org.apache.commons.lang ArrayUtils toPrimitive

List of usage examples for org.apache.commons.lang ArrayUtils toPrimitive

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils toPrimitive.

Prototype

public static boolean[] toPrimitive(Boolean[] array) 

Source Link

Document

Converts an array of object Booleans to primitives.

Usage

From source file:v201208.reportservice.RunReportWithCustomFieldsExample.java

public static void main(String[] args) {
    try {//from   w  w  w.j ava2 s. c  o m
        // Log SOAP XML request and response.
        DfpServiceLogger.log();

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

        // Get the LineItemService.
        LineItemServiceInterface lineItemService = user.getService(DfpService.V201208.LINEITEM_SERVICE);

        // Set the ID of the order to get line items from.
        Long orderId = Long.parseLong("INSERT_ORDER_ID_HERE");

        // Sets defaults for page and filterStatement.
        LineItemPage page = new LineItemPage();
        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.V201208.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();

        // Create report query.
        ReportQuery reportQuery = new ReportQuery();
        reportQuery.setDateRangeType(DateRangeType.LAST_MONTH);
        reportQuery.setDimensions(new Dimension[] { Dimension.LINE_ITEM });
        reportQuery.setStatement(filterStatement);
        reportQuery.setCustomFieldIds(ArrayUtils.toPrimitive(customFieldIds.toArray(new Long[] {})));
        reportQuery.setColumns(new Column[] { Column.AD_SERVER_IMPRESSIONS });
        reportJob.setReportQuery(reportQuery);

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

        do {
            System.out.println("Report with ID '" + reportJob.getId() + "' is still running.");
            Thread.sleep(30000);
            // Get report job.
            reportJob = reportService.getReportJob(reportJob.getId());
        } while (reportJob.getReportJobStatus() == ReportJobStatus.IN_PROGRESS);

        if (reportJob.getReportJobStatus() == ReportJobStatus.FAILED) {
            System.out.println("Report job with ID '" + reportJob.getId() + "' failed to finish successfully.");
        } else {
            System.out.println("Report job with ID '" + reportJob.getId() + "' completed successfully.");
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:v201211.reportservice.RunReportWithCustomFieldsExample.java

public static void main(String[] args) {
    try {/*from w ww . j  av a 2 s  .  c  o m*/
        // Log SOAP XML request and response.
        DfpServiceLogger.log();

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

        // Get the LineItemService.
        LineItemServiceInterface lineItemService = user.getService(DfpService.V201211.LINEITEM_SERVICE);

        // Set the ID of the order to get line items from.
        Long orderId = Long.parseLong("INSERT_ORDER_ID_HERE");

        // Sets defaults for page and filterStatement.
        LineItemPage page = new LineItemPage();
        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.V201211.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();

        // Create report query.
        ReportQuery reportQuery = new ReportQuery();
        reportQuery.setDateRangeType(DateRangeType.LAST_MONTH);
        reportQuery.setDimensions(new Dimension[] { Dimension.LINE_ITEM });
        reportQuery.setStatement(filterStatement);
        reportQuery.setCustomFieldIds(ArrayUtils.toPrimitive(customFieldIds.toArray(new Long[] {})));
        reportQuery.setColumns(new Column[] { Column.AD_SERVER_IMPRESSIONS });
        reportJob.setReportQuery(reportQuery);

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

        do {
            System.out.println("Report with ID '" + reportJob.getId() + "' is still running.");
            Thread.sleep(30000);
            // Get report job.
            reportJob = reportService.getReportJob(reportJob.getId());
        } while (reportJob.getReportJobStatus() == ReportJobStatus.IN_PROGRESS);

        if (reportJob.getReportJobStatus() == ReportJobStatus.FAILED) {
            System.out.println("Report job with ID '" + reportJob.getId() + "' failed to finish successfully.");
        } else {
            System.out.println("Report job with ID '" + reportJob.getId() + "' completed successfully.");
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:v201302.reportservice.RunReportWithCustomFieldsExample.java

public static void main(String[] args) {
    try {//w ww. j  a v a2 s  .  c  om
        // Log SOAP XML request and response.
        DfpServiceLogger.log();

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

        // Get the LineItemService.
        LineItemServiceInterface lineItemService = user.getService(DfpService.V201302.LINEITEM_SERVICE);

        // Set the ID of the order to get line items from.
        Long orderId = Long.parseLong("INSERT_ORDER_ID_HERE");

        // Sets defaults for page and filterStatement.
        LineItemPage page = new LineItemPage();
        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.V201302.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();

        // Create report query.
        ReportQuery reportQuery = new ReportQuery();
        reportQuery.setDateRangeType(DateRangeType.LAST_MONTH);
        reportQuery.setDimensions(new Dimension[] { Dimension.LINE_ITEM_ID, Dimension.LINE_ITEM_NAME });
        reportQuery.setStatement(filterStatement);
        reportQuery.setCustomFieldIds(ArrayUtils.toPrimitive(customFieldIds.toArray(new Long[] {})));
        reportQuery.setColumns(new Column[] { Column.AD_SERVER_IMPRESSIONS });
        reportJob.setReportQuery(reportQuery);

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

        do {
            System.out.println("Report with ID '" + reportJob.getId() + "' is still running.");
            Thread.sleep(30000);
            // Get report job.
            reportJob = reportService.getReportJob(reportJob.getId());
        } while (reportJob.getReportJobStatus() == ReportJobStatus.IN_PROGRESS);

        if (reportJob.getReportJobStatus() == ReportJobStatus.FAILED) {
            System.out.println("Report job with ID '" + reportJob.getId() + "' failed to finish successfully.");
        } else {
            System.out.println("Report job with ID '" + reportJob.getId() + "' completed successfully.");
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:v201306.reportservice.RunReportWithCustomFieldsExample.java

public static void main(String[] args) {
    try {/* w w w.j av  a  2 s. c o  m*/
        // Log SOAP XML request and response.
        DfpServiceLogger.log();

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

        // Get the LineItemService.
        LineItemServiceInterface lineItemService = user.getService(DfpService.V201306.LINEITEM_SERVICE);

        // Set the ID of the order to get line items from.
        Long orderId = Long.parseLong("INSERT_ORDER_ID_HERE");

        // Sets defaults for page and filterStatement.
        LineItemPage page = new LineItemPage();
        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();

        // Create report query.
        ReportQuery reportQuery = new ReportQuery();
        reportQuery.setDateRangeType(DateRangeType.LAST_MONTH);
        reportQuery.setDimensions(new Dimension[] { Dimension.LINE_ITEM_ID, Dimension.LINE_ITEM_NAME });
        reportQuery.setStatement(filterStatement);
        reportQuery.setCustomFieldIds(ArrayUtils.toPrimitive(customFieldIds.toArray(new Long[] {})));
        reportQuery.setColumns(new Column[] { Column.AD_SERVER_IMPRESSIONS });
        reportJob.setReportQuery(reportQuery);

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

        do {
            System.out.println("Report with ID '" + reportJob.getId() + "' is still running.");
            Thread.sleep(30000);
            // Get report job.
            reportJob = reportService.getReportJob(reportJob.getId());
        } while (reportJob.getReportJobStatus() == ReportJobStatus.IN_PROGRESS);

        if (reportJob.getReportJobStatus() == ReportJobStatus.FAILED) {
            System.out.println("Report job with ID '" + reportJob.getId() + "' failed to finish successfully.");
        } else {
            System.out.println("Report job with ID '" + reportJob.getId() + "' completed successfully.");
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:v201308.reportservice.RunReportWithCustomFieldsExample.java

public static void main(String[] args) {
    try {//from w w w. j  av  a 2s .c  om
        // Log SOAP XML request and response.
        DfpServiceLogger.log();

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

        // Get the LineItemService.
        LineItemServiceInterface lineItemService = user.getService(DfpService.V201308.LINEITEM_SERVICE);

        // Set the ID of the order to get line items from.
        Long orderId = Long.parseLong("INSERT_ORDER_ID_HERE");

        // Sets defaults for page and filterStatement.
        LineItemPage page = new LineItemPage();
        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.V201308.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();

        // Create report query.
        ReportQuery reportQuery = new ReportQuery();
        reportQuery.setDateRangeType(DateRangeType.LAST_MONTH);
        reportQuery.setDimensions(new Dimension[] { Dimension.LINE_ITEM_ID, Dimension.LINE_ITEM_NAME });
        reportQuery.setStatement(filterStatement);
        reportQuery.setCustomFieldIds(ArrayUtils.toPrimitive(customFieldIds.toArray(new Long[] {})));
        reportQuery.setColumns(new Column[] { Column.AD_SERVER_IMPRESSIONS });
        reportJob.setReportQuery(reportQuery);

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

        do {
            System.out.println("Report with ID '" + reportJob.getId() + "' is still running.");
            Thread.sleep(30000);
            // Get report job.
            reportJob = reportService.getReportJob(reportJob.getId());
        } while (reportJob.getReportJobStatus() == ReportJobStatus.IN_PROGRESS);

        if (reportJob.getReportJobStatus() == ReportJobStatus.FAILED) {
            System.out.println("Report job with ID '" + reportJob.getId() + "' failed to finish successfully.");
        } else {
            System.out.println("Report job with ID '" + reportJob.getId() + "' completed successfully.");
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:v201311.reportservice.RunReportWithCustomFieldsExample.java

public static void main(String[] args) {
    try {/*from  w  ww .j av  a2  s. co  m*/
        // Log SOAP XML request and response.
        DfpServiceLogger.log();

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

        // Get the LineItemService.
        LineItemServiceInterface lineItemService = user.getService(DfpService.V201311.LINEITEM_SERVICE);

        // Set the ID of the order to get line items from.
        Long orderId = Long.parseLong("INSERT_ORDER_ID_HERE");

        // Sets defaults for page and filterStatement.
        LineItemPage page = new LineItemPage();
        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.V201311.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();

        // Create report query.
        ReportQuery reportQuery = new ReportQuery();
        reportQuery.setDateRangeType(DateRangeType.LAST_MONTH);
        reportQuery.setDimensions(new Dimension[] { Dimension.LINE_ITEM_ID, Dimension.LINE_ITEM_NAME });
        reportQuery.setStatement(filterStatement);
        reportQuery.setCustomFieldIds(ArrayUtils.toPrimitive(customFieldIds.toArray(new Long[] {})));
        reportQuery.setColumns(new Column[] { Column.AD_SERVER_IMPRESSIONS });
        reportJob.setReportQuery(reportQuery);

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

        do {
            System.out.println("Report with ID '" + reportJob.getId() + "' is still running.");
            Thread.sleep(30000);
            // Get report job.
            reportJob = reportService.getReportJob(reportJob.getId());
        } while (reportJob.getReportJobStatus() == ReportJobStatus.IN_PROGRESS);

        if (reportJob.getReportJobStatus() == ReportJobStatus.FAILED) {
            System.out.println("Report job with ID '" + reportJob.getId() + "' failed to finish successfully.");
        } else {
            System.out.println("Report job with ID '" + reportJob.getId() + "' completed successfully.");
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}