Search in sources :

Example 1 with DetailColumnInfo

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

the class SalesforceReportResultsToListConverter method addColumnHeaders.

private static void addColumnHeaders(List<List<String>> result, ArrayList<DetailColumnInfo> columnInfos) {
    final ArrayList<String> headers = new ArrayList<String>(columnInfos.size());
    for (DetailColumnInfo info : columnInfos) {
        headers.add(info.getLabel());
    }
    result.add(headers);
}
Also used : ArrayList(java.util.ArrayList) DetailColumnInfo(org.apache.camel.component.salesforce.api.dto.analytics.reports.DetailColumnInfo)

Example 2 with DetailColumnInfo

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

the class SalesforceReportResultsToListConverter method convertSummaryResults.

private static List<List<String>> convertSummaryResults(final AbstractReportResultsBase reportResults, Exchange exchange) {
    final ArrayList<List<String>> result = new ArrayList<List<String>>();
    final ReportMetadata reportMetadata = reportResults.getReportMetadata();
    final ReportExtendedMetadata reportExtendedMetadata = reportResults.getReportExtendedMetadata();
    final String[] aggregates = reportMetadata.getAggregates();
    final boolean includeDetails = reportResults.getHasDetailRows() && getOption(exchange, INCLUDE_DETAILS, Boolean.TRUE);
    final boolean includeSummary = aggregates.length > 0 && getOption(exchange, INCLUDE_SUMMARY, Boolean.TRUE);
    // column list, including grouping columns and details if required
    final ArrayList<DetailColumnInfo> columnInfos = new ArrayList<DetailColumnInfo>();
    final String[] columnNames = getResultColumns(columnInfos, reportMetadata, reportExtendedMetadata, includeDetails, includeSummary);
    // include detail headers?
    if (getOption(exchange, INCLUDE_HEADERS, Boolean.TRUE)) {
        addColumnHeaders(result, columnInfos);
    }
    // process down groups
    for (GroupingValue groupingValue : reportResults.getGroupingsDown().getGroupings()) {
        addSummaryGroupValues(result, reportResults, columnNames, groupingValue, EMPTY_STRING_LIST, includeDetails, includeSummary);
    }
    // add grand total
    if (includeSummary) {
        final ReportFactWithDetails grandTotal = reportResults.getFactMap().get("T!T");
        addSummaryValues(result, includeDetails, columnNames, EMPTY_STRING_LIST, aggregates, grandTotal.getAggregates());
    }
    return result;
}
Also used : ReportExtendedMetadata(org.apache.camel.component.salesforce.api.dto.analytics.reports.ReportExtendedMetadata) ReportFactWithDetails(org.apache.camel.component.salesforce.api.dto.analytics.reports.ReportFactWithDetails) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) GroupingValue(org.apache.camel.component.salesforce.api.dto.analytics.reports.GroupingValue) ReportMetadata(org.apache.camel.component.salesforce.api.dto.analytics.reports.ReportMetadata) DetailColumnInfo(org.apache.camel.component.salesforce.api.dto.analytics.reports.DetailColumnInfo)

Example 3 with DetailColumnInfo

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

the class SalesforceReportResultsToListConverter method convertMatrixResults.

private static List<List<String>> convertMatrixResults(final AbstractReportResultsBase reportResults, Exchange exchange) {
    final ArrayList<List<String>> result = new ArrayList<List<String>>();
    final ReportMetadata reportMetadata = reportResults.getReportMetadata();
    final ReportExtendedMetadata reportExtendedMetadata = reportResults.getReportExtendedMetadata();
    final String[] aggregates = reportMetadata.getAggregates();
    final boolean includeDetails = reportResults.getHasDetailRows() && getOption(exchange, INCLUDE_DETAILS, Boolean.TRUE);
    final boolean includeSummary = aggregates.length > 0 && getOption(exchange, INCLUDE_SUMMARY, Boolean.TRUE);
    // column list, including grouping columns and details if required
    final ArrayList<DetailColumnInfo> columnInfos = new ArrayList<DetailColumnInfo>();
    final String[] columnNames = getResultColumns(columnInfos, reportMetadata, reportExtendedMetadata, includeDetails, includeSummary);
    // include detail headers?
    if (getOption(exchange, INCLUDE_HEADERS, Boolean.TRUE)) {
        addColumnHeaders(result, columnInfos);
    }
    // process down groups
    final GroupingValue[] groupingsDown = reportResults.getGroupingsDown().getGroupings();
    for (GroupingValue groupingValue : groupingsDown) {
        addMatrixGroupValues(result, reportResults, columnNames, groupingValue, EMPTY_STRING_LIST, includeDetails, includeSummary, EMPTY_VALUE, true);
    }
    // add grand total
    if (includeSummary) {
        final Map<String, ReportFactWithDetails> factMap = reportResults.getFactMap();
        // first add summary for across groups
        final List<String> downGroupsPrefix = new ArrayList<String>(Collections.nCopies(groupingsDown.length, EMPTY_VALUE));
        for (GroupingValue acrossGrouping : reportResults.getGroupingsAcross().getGroupings()) {
            addAcrossGroupSummaryValues(result, reportMetadata, includeDetails, columnNames, factMap, downGroupsPrefix, acrossGrouping);
        }
        final ReportFactWithDetails grandTotal = factMap.get("T!T");
        addSummaryValues(result, includeDetails, columnNames, EMPTY_STRING_LIST, reportResults.getReportMetadata().getAggregates(), grandTotal.getAggregates());
    }
    return result;
}
Also used : ReportFactWithDetails(org.apache.camel.component.salesforce.api.dto.analytics.reports.ReportFactWithDetails) ArrayList(java.util.ArrayList) DetailColumnInfo(org.apache.camel.component.salesforce.api.dto.analytics.reports.DetailColumnInfo) ReportExtendedMetadata(org.apache.camel.component.salesforce.api.dto.analytics.reports.ReportExtendedMetadata) ArrayList(java.util.ArrayList) List(java.util.List) GroupingValue(org.apache.camel.component.salesforce.api.dto.analytics.reports.GroupingValue) ReportMetadata(org.apache.camel.component.salesforce.api.dto.analytics.reports.ReportMetadata)

Example 4 with DetailColumnInfo

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

the class SalesforceReportResultsToListConverter method getResultColumns.

private static String[] getResultColumns(List<DetailColumnInfo> result, ReportMetadata reportMetadata, ReportExtendedMetadata reportExtendedMetadata, boolean includeDetails, boolean includeSummary) {
    final List<String> columnNames = new ArrayList<String>();
    // add grouping columns before detail columns
    final Map<String, GroupingColumnInfo> groupingColumnInfos = reportExtendedMetadata.getGroupingColumnInfo();
    for (GroupingInfo downGroup : reportMetadata.getGroupingsDown()) {
        final String name = downGroup.getName();
        columnNames.add(name);
        result.add(groupingColumnInfos.get(name));
    }
    for (GroupingInfo acrossGroup : reportMetadata.getGroupingsAcross()) {
        final String name = acrossGroup.getName();
        columnNames.add(name);
        result.add(groupingColumnInfos.get(name));
    }
    // include details?
    if (!includeDetails) {
        // include summary columns?
        if (includeSummary) {
            final Map<String, AggregateColumnInfo> aggregateColumnInfos = reportExtendedMetadata.getAggregateColumnInfo();
            for (String aggregateColumnName : reportMetadata.getAggregates()) {
                columnNames.add(aggregateColumnName);
                result.add(aggregateColumnInfos.get(aggregateColumnName));
            }
        }
    } else {
        // add detail columns
        final Map<String, DetailColumnInfo> detailColumnInfo = reportExtendedMetadata.getDetailColumnInfo();
        for (String columnName : reportMetadata.getDetailColumns()) {
            columnNames.add(columnName);
            result.add(detailColumnInfo.get(columnName));
        }
    }
    return columnNames.toArray(new String[columnNames.size()]);
}
Also used : GroupingInfo(org.apache.camel.component.salesforce.api.dto.analytics.reports.GroupingInfo) ArrayList(java.util.ArrayList) AggregateColumnInfo(org.apache.camel.component.salesforce.api.dto.analytics.reports.AggregateColumnInfo) GroupingColumnInfo(org.apache.camel.component.salesforce.api.dto.analytics.reports.GroupingColumnInfo) DetailColumnInfo(org.apache.camel.component.salesforce.api.dto.analytics.reports.DetailColumnInfo)

Aggregations

ArrayList (java.util.ArrayList)4 DetailColumnInfo (org.apache.camel.component.salesforce.api.dto.analytics.reports.DetailColumnInfo)4 List (java.util.List)2 GroupingValue (org.apache.camel.component.salesforce.api.dto.analytics.reports.GroupingValue)2 ReportExtendedMetadata (org.apache.camel.component.salesforce.api.dto.analytics.reports.ReportExtendedMetadata)2 ReportFactWithDetails (org.apache.camel.component.salesforce.api.dto.analytics.reports.ReportFactWithDetails)2 ReportMetadata (org.apache.camel.component.salesforce.api.dto.analytics.reports.ReportMetadata)2 AggregateColumnInfo (org.apache.camel.component.salesforce.api.dto.analytics.reports.AggregateColumnInfo)1 GroupingColumnInfo (org.apache.camel.component.salesforce.api.dto.analytics.reports.GroupingColumnInfo)1 GroupingInfo (org.apache.camel.component.salesforce.api.dto.analytics.reports.GroupingInfo)1