Search in sources :

Example 1 with PivotContent

use of org.activityinfo.legacy.shared.reports.content.PivotContent in project activityinfo by bedatadriven.

the class PivotTableBinder method executeLoad.

@Override
protected void executeLoad(final AsyncCallback<PivotContent> callback) {
    final Filter filter = new Filter(getModel().getFilter());
    final Set<Dimension> dimensions = new HashSet<>(getModel().allDimensions());
    if (filter.equals(cachedFilter) && dimensions.equals(cachedDimensions)) {
        try {
            callback.onSuccess(generateElement());
        } catch (Exception e) {
            callback.onFailure(e);
        }
    } else {
        PivotSites query = new PivotSites(dimensions, filter);
        if (query.isTooBroad()) {
            callback.onSuccess(new PivotContent());
            return;
        }
        dispatcher.execute(query, new AsyncCallback<PivotSites.PivotResult>() {

            @Override
            public void onFailure(Throwable throwable) {
                callback.onFailure(throwable);
            }

            @Override
            public void onSuccess(PivotSites.PivotResult pivotResult) {
                cachedFilter = filter;
                cachedDimensions = dimensions;
                cachedResult = pivotResult;
                try {
                    callback.onSuccess(generateElement());
                } catch (Exception e) {
                    callback.onFailure(e);
                }
            }
        });
    }
}
Also used : PivotSites(org.activityinfo.legacy.shared.command.PivotSites) Filter(org.activityinfo.legacy.shared.command.Filter) PivotContent(org.activityinfo.legacy.shared.reports.content.PivotContent) Dimension(org.activityinfo.legacy.shared.reports.model.Dimension) HashSet(java.util.HashSet)

Example 2 with PivotContent

use of org.activityinfo.legacy.shared.reports.content.PivotContent in project activityinfo by bedatadriven.

the class PivotTableBinder method generateElement.

private PivotContent generateElement() {
    PivotTableReportElement model = (PivotTableReportElement) getModel();
    PivotTableDataBuilder builder = new PivotTableDataBuilder();
    PivotTableData data = builder.build(model.getRowDimensions(), model.getColumnDimensions(), cachedResult.getBuckets());
    PivotContent content = new PivotContent();
    content.setEffectiveFilter(cachedFilter);
    content.setData(data);
    return content;
}
Also used : PivotTableData(org.activityinfo.legacy.shared.reports.content.PivotTableData) PivotContent(org.activityinfo.legacy.shared.reports.content.PivotContent) PivotTableReportElement(org.activityinfo.legacy.shared.reports.model.PivotTableReportElement) PivotTableDataBuilder(org.activityinfo.legacy.shared.impl.pivot.PivotTableDataBuilder)

Example 3 with PivotContent

use of org.activityinfo.legacy.shared.reports.content.PivotContent in project activityinfo by bedatadriven.

the class PivotTableGenerator method generate.

@Override
public void generate(User user, PivotTableReportElement element, Filter inheritedFilter, DateRange dateRange) {
    Filter filter = GeneratorUtils.resolveElementFilter(element, dateRange);
    Filter effectiveFilter = inheritedFilter == null ? filter : new Filter(inheritedFilter, filter);
    PivotTableData data = generateData(user.getId(), user.getLocaleObject(), element, effectiveFilter, element.getRowDimensions(), element.getColumnDimensions());
    PivotContent content = new PivotContent();
    content.setEffectiveFilter(effectiveFilter);
    content.setFilterDescriptions(generateFilterDescriptions(filter, element.allDimensionTypes(), user));
    content.setData(data);
    element.setContent(content);
}
Also used : Filter(org.activityinfo.legacy.shared.command.Filter) PivotTableData(org.activityinfo.legacy.shared.reports.content.PivotTableData) PivotContent(org.activityinfo.legacy.shared.reports.content.PivotContent)

Example 4 with PivotContent

use of org.activityinfo.legacy.shared.reports.content.PivotContent in project activityinfo by bedatadriven.

the class DummyPivotTableData2 method testElement.

public PivotTableReportElement testElement() {
    PivotTableReportElement element = new PivotTableReportElement();
    element.setTitle("Foobar 1612");
    element.setRowDimensions(rowDims);
    element.setColumnDimensions(colDims);
    element.setContent(new PivotContent(table, new ArrayList<FilterDescription>()));
    return element;
}
Also used : PivotContent(org.activityinfo.legacy.shared.reports.content.PivotContent) ArrayList(java.util.ArrayList) PivotTableReportElement(org.activityinfo.legacy.shared.reports.model.PivotTableReportElement)

Aggregations

PivotContent (org.activityinfo.legacy.shared.reports.content.PivotContent)4 Filter (org.activityinfo.legacy.shared.command.Filter)2 PivotTableData (org.activityinfo.legacy.shared.reports.content.PivotTableData)2 PivotTableReportElement (org.activityinfo.legacy.shared.reports.model.PivotTableReportElement)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 PivotSites (org.activityinfo.legacy.shared.command.PivotSites)1 PivotTableDataBuilder (org.activityinfo.legacy.shared.impl.pivot.PivotTableDataBuilder)1 Dimension (org.activityinfo.legacy.shared.reports.model.Dimension)1