Search in sources :

Example 1 with ReportRow

use of org.apache.camel.component.salesforce.api.dto.analytics.reports.ReportRow in project camel by apache.

the class SalesforceReportResultsToListConverter method convertTabularResults.

private static List<List<String>> convertTabularResults(final AbstractReportResultsBase reportResults, final Exchange exchange) {
    final ArrayList<List<String>> result = new ArrayList<List<String>>();
    final ReportMetadata reportMetadata = reportResults.getReportMetadata();
    final String[] detailColumns = reportMetadata.getDetailColumns();
    final ReportExtendedMetadata reportExtendedMetadata = reportResults.getReportExtendedMetadata();
    final ReportFactWithDetails factWithDetails = reportResults.getFactMap().get("T!T");
    // include detail rows?
    final String[] aggregates = reportMetadata.getAggregates();
    if (reportResults.getHasDetailRows() && getOption(exchange, INCLUDE_DETAILS, Boolean.TRUE)) {
        final int rowLength = detailColumns.length;
        // include detail headers?
        if (getOption(exchange, INCLUDE_HEADERS, Boolean.TRUE)) {
            final List<String> headers = new ArrayList<String>(rowLength);
            result.add(headers);
            addColumnHeaders(headers, reportExtendedMetadata.getDetailColumnInfo(), detailColumns);
        }
        final ReportRow[] reportRows = factWithDetails.getRows();
        result.ensureCapacity(result.size() + reportRows.length);
        for (ReportRow reportRow : reportRows) {
            final List<String> row = new ArrayList<String>(rowLength);
            result.add(row);
            addRowValues(row, reportRow.getDataCells());
        }
        // include summary values?
        if (aggregates.length > 0 && getOption(exchange, INCLUDE_SUMMARY, Boolean.TRUE)) {
            addSummaryRows(result, detailColumns, null, aggregates, factWithDetails.getAggregates());
        }
    } else if (aggregates.length > 0) {
        final int rowLength = aggregates.length;
        // include summary headers?
        if (getOption(exchange, INCLUDE_HEADERS, Boolean.TRUE)) {
            final List<String> headers = new ArrayList<String>(rowLength);
            result.add(headers);
            addColumnHeaders(headers, reportExtendedMetadata.getAggregateColumnInfo(), aggregates);
        }
        // add summary values
        final List<String> row = new ArrayList<String>(rowLength);
        result.add(row);
        addRowValues(row, factWithDetails.getAggregates());
    }
    return result;
}
Also used : ReportRow(org.apache.camel.component.salesforce.api.dto.analytics.reports.ReportRow) ReportFactWithDetails(org.apache.camel.component.salesforce.api.dto.analytics.reports.ReportFactWithDetails) ArrayList(java.util.ArrayList) ReportExtendedMetadata(org.apache.camel.component.salesforce.api.dto.analytics.reports.ReportExtendedMetadata) ArrayList(java.util.ArrayList) List(java.util.List) ReportMetadata(org.apache.camel.component.salesforce.api.dto.analytics.reports.ReportMetadata)

Example 2 with ReportRow

use of org.apache.camel.component.salesforce.api.dto.analytics.reports.ReportRow in project camel by apache.

the class SalesforceReportResultsToListConverter method addDetailRows.

private static void addDetailRows(ArrayList<List<String>> result, List<String> newPrefix, ReportFactWithDetails factWithDetails) {
    final ReportRow[] rows = factWithDetails.getRows();
    result.ensureCapacity(result.size() + rows.length);
    for (ReportRow row : rows) {
        final ArrayList<String> rowValues = new ArrayList<String>(newPrefix);
        addRowValues(rowValues, row.getDataCells());
        result.add(rowValues);
    }
}
Also used : ReportRow(org.apache.camel.component.salesforce.api.dto.analytics.reports.ReportRow) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)2 ReportRow (org.apache.camel.component.salesforce.api.dto.analytics.reports.ReportRow)2 List (java.util.List)1 ReportExtendedMetadata (org.apache.camel.component.salesforce.api.dto.analytics.reports.ReportExtendedMetadata)1 ReportFactWithDetails (org.apache.camel.component.salesforce.api.dto.analytics.reports.ReportFactWithDetails)1 ReportMetadata (org.apache.camel.component.salesforce.api.dto.analytics.reports.ReportMetadata)1