Search in sources :

Example 6 with FilterDescription

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

the class ExcelTableRenderer method render.

@Override
public void render(Workbook book, TableElement element) {
    final TableData tableData = element.getContent().getData();
    new BaseExcelTableRenderer<TableElement, TableColumn>(book, element) {

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

        @Override
        public void generate() {
            /* Generate the column headers for the table */
            initColHeaderStyles(element.getRootColumn());
            generateColumnHeaders(0, element.getRootColumn());
            int headerHeight = rowIndex;
            sheet.createFreezePane(element.getFrozenColumns(), headerHeight);
            /* Prepare the generators and indexes */
            List<TableColumn> leaves = element.getRootColumn().getLeaves();
            String[] colIndexes = new String[leaves.size()];
            for (int i = 0; i != leaves.size(); ++i) {
                colIndexes[i] = leaves.get(i).getSitePropertyName();
            }
            for (SiteDTO rowData : tableData.getRows()) {
                Row row = sheet.createRow(rowIndex++);
                for (int i = 0; i != colIndexes.length; ++i) {
                    Object value = null;
                    if (colIndexes[i] != null) {
                        value = rowData.get(colIndexes[i]);
                    }
                    Cell cell = row.createCell(i);
                    if (value instanceof Number) {
                        cell.setCellValue(((Number) value).doubleValue());
                    } else if (value instanceof Date) {
                        cell.setCellValue((Date) value);
                    } else if (value instanceof Boolean) {
                        cell.setCellValue((Boolean) value);
                    } else if (value != null) {
                        cell.setCellValue(factory.createRichTextString(value.toString()));
                    }
                }
            }
        }
    };
}
Also used : FilterDescription(org.activityinfo.shared.report.content.FilterDescription) TableColumn(org.activityinfo.shared.report.model.TableColumn) Date(java.util.Date) SiteDTO(org.activityinfo.shared.dto.SiteDTO) Row(org.apache.poi.ss.usermodel.Row) TableData(org.activityinfo.shared.report.content.TableData) Cell(org.apache.poi.ss.usermodel.Cell)

Example 7 with FilterDescription

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

the class PolygonGeneratorTest method polygonWithHole.

@Test
public void polygonWithHole() throws IOException {
    AdminMarker marker = new AdminMarker();
    marker.setAdminEntityId(1930);
    marker.setColor("#FFBBBB");
    AdminOverlay overlay = new AdminOverlay(1383);
    overlay.setOutlineColor("#FF0000");
    overlay.addPolygon(marker);
    PolygonMapLayer layer = new PolygonMapLayer();
    layer.addIndicatorId(1);
    layer.setAdminLevelId(1383);
    MapContent content = new MapContent();
    content.setZoomLevel(8);
    content.setBaseMap(GoogleBaseMap.ROADMAP);
    content.setCenter(new AiLatLng(12.60500192642215, -7.98924994468689));
    content.getAdminOverlays().add(overlay);
    content.setFilterDescriptions(new ArrayList<FilterDescription>());
    PolygonLegend.ColorClass clazz1 = new PolygonLegend.ColorClass(1, 53.6, "0000FF");
    PolygonLegend.ColorClass clazz2 = new PolygonLegend.ColorClass(600, 600, "FF0000");
    PolygonLegend legend = new PolygonLegend(layer, Lists.newArrayList(clazz1, clazz2));
    content.getLegends().add(legend);
    IndicatorDTO indicator = new IndicatorDTO();
    indicator.setId(1);
    indicator.setName("Indicator Test");
    content.getIndicators().add(indicator);
    MapReportElement map = new MapReportElement();
    map.addLayer(layer);
    map.setContent(content);
    FileOutputStream fos = new FileOutputStream("target/report-tests/polygon-hole.pdf");
    PdfReportRenderer pdfr = new PdfReportRenderer(TestGeometry.get(), "");
    pdfr.render(map, fos);
    fos.close();
}
Also used : PolygonMapLayer(org.activityinfo.shared.report.model.layers.PolygonMapLayer) MapContent(org.activityinfo.shared.report.content.MapContent) PdfReportRenderer(org.activityinfo.server.report.renderer.itext.PdfReportRenderer) FilterDescription(org.activityinfo.shared.report.content.FilterDescription) MapReportElement(org.activityinfo.shared.report.model.MapReportElement) IndicatorDTO(org.activityinfo.shared.dto.IndicatorDTO) AdminOverlay(org.activityinfo.shared.report.content.AdminOverlay) PolygonLegend(org.activityinfo.shared.report.content.PolygonLegend) AdminMarker(org.activityinfo.shared.report.content.AdminMarker) FileOutputStream(java.io.FileOutputStream) AiLatLng(org.activityinfo.shared.report.content.AiLatLng) Test(org.junit.Test)

Example 8 with FilterDescription

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

the class PivotTableRendererTest method veryLongFilter.

@Test
public void veryLongFilter() {
    // input test data : element + content
    DummyPivotTableData2 testData = new DummyPivotTableData2();
    PivotTableReportElement element = testData.testElement();
    // Filtering on 4000 indicators....
    Map<Integer, String> labelMap = Maps.newHashMap();
    for (int i = 1; i != 10000; ++i) {
        element.getFilter().addRestriction(DimensionType.Indicator, i);
        labelMap.put(i, "Very long indicator name " + i);
    }
    element.getContent().getFilterDescriptions().add(new FilterDescription(DimensionType.Indicator, labelMap));
    // Destination book
    HSSFWorkbook book = new HSSFWorkbook();
    // CLASS under test
    ExcelPivotTableRenderer renderer = new ExcelPivotTableRenderer();
    renderer.render(book, element);
}
Also used : DummyPivotTableData2(org.activityinfo.server.report.DummyPivotTableData2) FilterDescription(org.activityinfo.shared.report.content.FilterDescription) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook) Test(org.junit.Test)

Aggregations

FilterDescription (org.activityinfo.shared.report.content.FilterDescription)8 Cell (org.apache.poi.ss.usermodel.Cell)3 Row (org.apache.poi.ss.usermodel.Row)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 PivotTableData (org.activityinfo.shared.report.content.PivotTableData)2 DimensionType (org.activityinfo.shared.report.model.DimensionType)2 Test (org.junit.Test)2 FileOutputStream (java.io.FileOutputStream)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 DummyPivotTableData2 (org.activityinfo.server.report.DummyPivotTableData2)1 PdfReportRenderer (org.activityinfo.server.report.renderer.itext.PdfReportRenderer)1 Filter (org.activityinfo.shared.command.Filter)1 GetDimensionLabels (org.activityinfo.shared.command.GetDimensionLabels)1 DimensionLabels (org.activityinfo.shared.command.GetDimensionLabels.DimensionLabels)1 Search (org.activityinfo.shared.command.Search)1 SearchResult (org.activityinfo.shared.command.result.SearchResult)1 SitePointList (org.activityinfo.shared.command.result.SitePointList)1