Search in sources :

Example 1 with PivotContent

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

the class SearchHandler method processFilter.

private void processFilter(final ExecutionContext context, final AsyncCallback<SearchResult> callback, final Filter resultFilter) {
    final SearchResult searchResult = new SearchResult();
    if (resultFilter.getRestrictedDimensions().size() > 0) {
        // pivot data query
        final PivotTableReportElement pivotTable = createSearchPivotTableElement();
        pivotTable.setFilter(resultFilter);
        GenerateElement<PivotContent> zmd = new GenerateElement<PivotContent>(pivotTable);
        context.execute(zmd, new AsyncCallback<PivotContent>() {

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

            @Override
            public void onSuccess(PivotContent content) {
                content.setEffectiveFilter(resultFilter);
                searchResult.setPivotTabelData(content);
                // recent sites query
                GetSites getSites = createGetSitesCommand(resultFilter);
                context.execute(getSites, new AsyncCallback<SiteResult>() {

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

                    @Override
                    public void onSuccess(SiteResult resultSites) {
                        searchResult.setRecentAdditions(resultSites.getData());
                        callback.onSuccess(searchResult);
                    }
                });
            }
        });
    } else {
        // Return empty searchresult when no filtered entities found
        callback.onSuccess(searchResult);
    }
}
Also used : SiteResult(org.activityinfo.shared.command.result.SiteResult) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) PivotContent(org.activityinfo.shared.report.content.PivotContent) GetSites(org.activityinfo.shared.command.GetSites) GenerateElement(org.activityinfo.shared.command.GenerateElement) SearchResult(org.activityinfo.shared.command.result.SearchResult) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement)

Example 2 with PivotContent

use of org.activityinfo.shared.report.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(), LocaleHelper.getLocaleObject(user), 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.shared.command.Filter) PivotTableData(org.activityinfo.shared.report.content.PivotTableData) PivotContent(org.activityinfo.shared.report.content.PivotContent)

Example 3 with PivotContent

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

the class DummyPivotTableData method Foobar1612Element.

public PivotTableReportElement Foobar1612Element() {
    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.shared.report.content.PivotContent) ArrayList(java.util.ArrayList) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement)

Example 4 with PivotContent

use of org.activityinfo.shared.report.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.shared.report.content.PivotContent) ArrayList(java.util.ArrayList) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement)

Example 5 with PivotContent

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

the class ItextReportRendererTest method manyColumns.

@Test
public void manyColumns() throws IOException {
    PivotTableData data = new PivotTableData();
    Dimension partner = new Dimension(DimensionType.Partner);
    Dimension year = new DateDimension(DateUnit.YEAR);
    EntityCategory avsi = new EntityCategory(100, "AVSI RRMP");
    Axis avsiRow = data.getRootRow().addChild(partner, avsi, avsi.getLabel(), comparator);
    for (int y = 2011; y < 2030; ++y) {
        Axis col = data.getRootColumn().addChild(year, new SimpleCategory("" + y), "" + y, comparator);
        avsiRow.setValue(col, (double) y);
    }
    PivotContent tableContent = new PivotContent(data, Lists.<FilterDescription>newArrayList());
    PivotTableReportElement table = new PivotTableReportElement();
    table.addRowDimension(partner);
    table.addColDimension(year);
    table.setContent(tableContent);
    ReportContent content = new ReportContent();
    content.setFilterDescriptions(Collections.EMPTY_LIST);
    Report report = new Report();
    report.setContent(content);
    report.addElement(table);
    renderToPdf(report, "narrowColumns.pdf");
    renderToRtf(report, "narrowColumns.rtf");
}
Also used : SimpleCategory(org.activityinfo.shared.report.content.SimpleCategory) ReportContent(org.activityinfo.shared.report.content.ReportContent) PivotTableData(org.activityinfo.shared.report.content.PivotTableData) DummyPivotTableData(org.activityinfo.server.report.DummyPivotTableData) Report(org.activityinfo.shared.report.model.Report) PivotContent(org.activityinfo.shared.report.content.PivotContent) DateDimension(org.activityinfo.shared.report.model.DateDimension) Dimension(org.activityinfo.shared.report.model.Dimension) AdminDimension(org.activityinfo.shared.report.model.AdminDimension) EntityCategory(org.activityinfo.shared.report.content.EntityCategory) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement) DateDimension(org.activityinfo.shared.report.model.DateDimension) Axis(org.activityinfo.shared.report.content.PivotTableData.Axis) Test(org.junit.Test)

Aggregations

PivotContent (org.activityinfo.shared.report.content.PivotContent)10 PivotTableReportElement (org.activityinfo.shared.report.model.PivotTableReportElement)6 PivotTableData (org.activityinfo.shared.report.content.PivotTableData)4 Report (org.activityinfo.shared.report.model.Report)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 DummyPivotTableData (org.activityinfo.server.report.DummyPivotTableData)3 ReportContent (org.activityinfo.shared.report.content.ReportContent)3 Filter (org.activityinfo.shared.command.Filter)2 SearchResult (org.activityinfo.shared.command.result.SearchResult)2 EntityCategory (org.activityinfo.shared.report.content.EntityCategory)2 Axis (org.activityinfo.shared.report.content.PivotTableData.Axis)2 SimpleCategory (org.activityinfo.shared.report.content.SimpleCategory)2 AdminDimension (org.activityinfo.shared.report.model.AdminDimension)2 DateDimension (org.activityinfo.shared.report.model.DateDimension)2 Dimension (org.activityinfo.shared.report.model.Dimension)2 MapReportElement (org.activityinfo.shared.report.model.MapReportElement)2 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 HashMap (java.util.HashMap)1 List (java.util.List)1