Search in sources :

Example 1 with PivotTableData

use of org.activityinfo.legacy.shared.reports.content.PivotTableData 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 2 with PivotTableData

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

the class ExcelChartRenderer method render.

@Override
public void render(Workbook book, PivotChartReportElement element) {
    /* Generate the actual pivot table data */
    element.getContent().getData();
    /* Generate the excel sheet */
    new BaseExcelRenderer<PivotChartReportElement>(book, element) {

        @Override
        public List<FilterDescription> generateFilterDescriptions() {
            return element.getContent().getFilterDescriptions();
        }

        @Override
        public void generate() {
            PivotTableData data = this.element.getContent().getData();
            List<PivotTableData.Axis> rows = data.getRootRow().getLeaves();
            List<PivotTableData.Axis> cols = data.getRootColumn().getLeaves();
            Row headerRow = sheet.createRow(rowIndex++);
            for (int i = 0; i != cols.size(); ++i) {
                Cell colHeaderCell = headerRow.createCell(i + 1);
                colHeaderCell.setCellValue(factory.createRichTextString(cols.get(i).flattenLabel()));
            }
            for (int i = 0; i != rows.size(); ++i) {
                Row row = sheet.createRow(rowIndex++);
                // header
                Cell rowHeaderCell = row.createCell(0);
                rowHeaderCell.setCellValue(factory.createRichTextString(rows.get(i).flattenLabel()));
                // values
                for (int j = 0; j != cols.size(); ++j) {
                    Cell valueCell = row.createCell(j + 1);
                    valueCell.setCellValue(rows.get(i).getCell(cols.get(j)).getValue());
                }
            }
        }
    };
}
Also used : PivotTableData(org.activityinfo.legacy.shared.reports.content.PivotTableData) FilterDescription(org.activityinfo.legacy.shared.reports.content.FilterDescription) Row(org.apache.poi.ss.usermodel.Row) Cell(org.apache.poi.ss.usermodel.Cell)

Example 3 with PivotTableData

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

the class PivotChartGenerator method generate.

@Override
public void generate(User user, PivotChartReportElement element, Filter inheritedFilter, DateRange dateRange) {
    Filter filter = GeneratorUtils.resolveElementFilter(element, dateRange);
    Filter effectiveFilter = inheritedFilter == null ? new Filter(filter, new Filter()) : new Filter(inheritedFilter, filter);
    PivotTableData data = generateData(user.getId(), user.getLocaleObject(), element, effectiveFilter, element.getCategoryDimensions(), element.getSeriesDimensions());
    ScaleUtil.Scale scale = computeScale(element, data);
    PivotChartContent content = new PivotChartContent();
    content.setXAxisTitle(composeXAxisTitle(element));
    content.setYAxisTitle(composeYAxisTitle(element));
    content.setEffectiveFilter(filter);
    content.setFilterDescriptions(generateFilterDescriptions(filter, element.allDimensionTypes(), user));
    content.setYMin(scale.getValmin());
    content.setYStep(scale.getStep());
    content.setData(data);
    element.setContent(content);
}
Also used : Filter(org.activityinfo.legacy.shared.command.Filter) PivotTableData(org.activityinfo.legacy.shared.reports.content.PivotTableData) PivotChartContent(org.activityinfo.legacy.shared.reports.content.PivotChartContent)

Example 4 with PivotTableData

use of org.activityinfo.legacy.shared.reports.content.PivotTableData 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 5 with PivotTableData

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

the class ItextPivotTableRenderer method render.

@Override
public void render(DocWriter writer, Document document, PivotTableReportElement element) throws DocumentException {
    document.add(ThemeHelper.elementTitle(element.getTitle()));
    ItextRendererHelper.addFilterDescription(document, element.getContent().getFilterDescriptions());
    ItextRendererHelper.addDateFilterDescription(document, element.getFilter().getEndDateRange());
    PivotTableData data = element.getContent().getData();
    if (data.isEmpty()) {
        document.add(new Paragraph(I18N.CONSTANTS.noData()));
    } else {
        int colDepth = data.getRootColumn().getDepth();
        List<PivotTableData.Axis> colLeaves = data.getRootColumn().getLeaves();
        int colBreadth = colLeaves.size();
        Table table = new Table(colBreadth + 1, 1);
        table.setUseVariableBorders(true);
        table.setWidth(100.0f);
        table.setWidths(calcColumnWidths(document, data, colLeaves));
        table.setBorderWidth(0);
        for (int depth = 1; depth <= colDepth; ++depth) {
            if (depth == 1) {
                Cell cell = ThemeHelper.cornerCell();
                cell.setRowspan(colDepth);
                table.addCell(cell);
            }
            List<PivotTableData.Axis> columns = data.getRootColumn().getDescendantsAtDepth(depth);
            for (PivotTableData.Axis column : columns) {
                Cell cell = ThemeHelper.columnHeaderCell(column.getLabel(), column.isLeaf());
                cell.setColspan(Math.max(1, column.getLeaves().size()));
                table.addCell(cell);
            }
        }
        table.endHeaders();
        for (PivotTableData.Axis row : data.getRootRow().getChildren()) {
            writeRow(table, row, colLeaves, 0);
        }
        document.add(table);
    }
}
Also used : PivotTableData(org.activityinfo.legacy.shared.reports.content.PivotTableData)

Aggregations

PivotTableData (org.activityinfo.legacy.shared.reports.content.PivotTableData)12 Filter (org.activityinfo.legacy.shared.command.Filter)2 Bucket (org.activityinfo.legacy.shared.command.result.Bucket)2 FilterDescription (org.activityinfo.legacy.shared.reports.content.FilterDescription)2 PivotChartContent (org.activityinfo.legacy.shared.reports.content.PivotChartContent)2 PivotContent (org.activityinfo.legacy.shared.reports.content.PivotContent)2 Dimension (org.activityinfo.legacy.shared.reports.model.Dimension)2 PivotTableReportElement (org.activityinfo.legacy.shared.reports.model.PivotTableReportElement)2 ChartModel (com.extjs.gxt.charts.client.model.ChartModel)1 XAxis (com.extjs.gxt.charts.client.model.axis.XAxis)1 YAxis (com.extjs.gxt.charts.client.model.axis.YAxis)1 GridEvent (com.extjs.gxt.ui.client.event.GridEvent)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 PivotSites (org.activityinfo.legacy.shared.command.PivotSites)1 PivotTableDataBuilder (org.activityinfo.legacy.shared.impl.pivot.PivotTableDataBuilder)1 CategoryComparator (org.activityinfo.legacy.shared.impl.pivot.order.CategoryComparator)1 DefinedCategoryComparator (org.activityinfo.legacy.shared.impl.pivot.order.DefinedCategoryComparator)1 AdminDimension (org.activityinfo.legacy.shared.reports.model.AdminDimension)1 DispatcherSync (org.activityinfo.server.command.DispatcherSync)1