Search in sources :

Example 6 with ReportContent

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

the class ItextReportRendererTest method nestedColumns.

@Test
public void nestedColumns() throws IOException {
    Dimension province = new AdminDimension(1);
    Dimension partner = new Dimension(DimensionType.Partner);
    Dimension year = new DateDimension(DateUnit.YEAR);
    Dimension month = new DateDimension(DateUnit.MONTH);
    EntityCategory avsi = new EntityCategory(100, "AVSI RRMP");
    PivotTableData data = new PivotTableData();
    Axis sudKivu = data.getRootColumn().addChild(province, new EntityCategory(1, "Sud Kivu"), "Sud Kivu", comparator);
    Axis y2010 = sudKivu.addChild(year, new SimpleCategory("2010"), "2010", comparator);
    Axis y2011 = sudKivu.addChild(year, new SimpleCategory("2010"), "2010", comparator);
    Axis jan2010 = y2010.addChild(month, new SimpleCategory("Jan"), "Jan", comparator);
    Axis feb2010 = y2010.addChild(month, new SimpleCategory("Feb"), "Feb", comparator);
    Axis jan2011 = y2011.addChild(month, new SimpleCategory("Jan"), "Jan", comparator);
    Axis feb2011 = y2011.addChild(month, new SimpleCategory("Feb"), "Feb", comparator);
    Axis avsiRow = data.getRootRow().addChild(partner, avsi, avsi.getLabel(), comparator);
    avsiRow.setValue(jan2010, 1d);
    avsiRow.setValue(feb2010, 2d);
    avsiRow.setValue(jan2011, 3d);
    avsiRow.setValue(feb2011, 4d);
    PivotContent tableContent = new PivotContent(data, Lists.<FilterDescription>newArrayList());
    PivotTableReportElement table = new PivotTableReportElement();
    table.addRowDimension(partner);
    table.addColDimension(province);
    table.addColDimension(year);
    table.addColDimension(month);
    table.setContent(tableContent);
    ReportContent content = new ReportContent();
    content.setFilterDescriptions(Collections.EMPTY_LIST);
    Report report = new Report();
    report.setContent(content);
    report.addElement(table);
    renderToPdf(report, "nestedColumns.pdf");
    renderToRtf(report, "nestedColumns.rtf");
    renderToXls(report, "nestedColumns.xls");
}
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) 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)

Example 7 with ReportContent

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

the class ItextReportRendererTest method pageNumbers.

@Test
public void pageNumbers() throws IOException {
    ReportContent content = new ReportContent();
    content.setFilterDescriptions(Collections.EMPTY_LIST);
    Report report = new Report();
    report.setContent(content);
    for (int i = 0; i != 1000; ++i) {
        TextReportElement element = new TextReportElement();
        element.setText("Quick brown fox, texte français");
        element.setContent(new NullContent());
        report.addElement(element);
    }
    renderToPdf(report, "pagenumbers.pdf");
}
Also used : ReportContent(org.activityinfo.shared.report.content.ReportContent) Report(org.activityinfo.shared.report.model.Report) NullContent(org.activityinfo.shared.report.content.NullContent) TextReportElement(org.activityinfo.shared.report.model.TextReportElement) Test(org.junit.Test)

Example 8 with ReportContent

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

the class ReportGenerator method generateReport.

private void generateReport(User user, Report report, Filter inheritedFilter, DateRange dateRange) {
    GeneratorUtils.resolveElementFilter(report, dateRange);
    Filter effectiveFilter = GeneratorUtils.resolveEffectiveFilter(report, inheritedFilter, dateRange);
    for (ReportElement element : report.getElements()) {
        generateElement(user, element, effectiveFilter, dateRange);
    }
    ReportContent content = new ReportContent();
    content.setFileName(generateFileName(report, dateRange, user));
    content.setFilterDescriptions(generateFilterDescriptions(effectiveFilter, Collections.<DimensionType>emptySet(), user));
    report.setContent(content);
}
Also used : DimensionType(org.activityinfo.shared.report.model.DimensionType) ReportContent(org.activityinfo.shared.report.content.ReportContent) Filter(org.activityinfo.shared.command.Filter) PivotChartReportElement(org.activityinfo.shared.report.model.PivotChartReportElement) TextReportElement(org.activityinfo.shared.report.model.TextReportElement) MapReportElement(org.activityinfo.shared.report.model.MapReportElement) ReportElement(org.activityinfo.shared.report.model.ReportElement) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement)

Example 9 with ReportContent

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

the class ItextReportRendererTest method legendTest.

@Test
public void legendTest() throws IOException {
    BubbleMapMarker marker1 = new BubbleMapMarker();
    marker1.setLat(-2.45);
    marker1.setLng(28.8);
    marker1.setX(100);
    marker1.setY(100);
    marker1.setRadius(25);
    marker1.setValue(300);
    TileBaseMap baseMap = new TileBaseMap();
    baseMap.setTileUrlPattern("//www.activityinfo.org/resources/tile/nordkivu.cd/{z}/{x}/{y}.png");
    BubbleMapLayer layer1 = new BubbleMapLayer();
    layer1.addIndicatorId(101);
    layer1.setMinRadius(10);
    layer1.setMaxRadius(10);
    BubbleLayerLegend legend1 = new BubbleLayerLegend();
    legend1.setDefinition(layer1);
    legend1.setMinValue(1000);
    legend1.setMaxValue(3000);
    BubbleMapLayer layer2 = new BubbleMapLayer();
    layer2.addIndicatorId(102);
    layer2.addIndicatorId(103);
    layer2.setMinRadius(10);
    layer2.setMaxRadius(25);
    BubbleLayerLegend legend2 = new BubbleLayerLegend();
    legend2.setDefinition(layer2);
    legend2.setMinValue(600);
    legend2.setMaxValue(999);
    IconMapLayer layer3 = new IconMapLayer();
    layer3.setIcon(MapIcon.Icon.Default.name());
    layer3.getIndicatorIds().add(101);
    IconLayerLegend legend3 = new IconLayerLegend();
    legend3.setDefinition(layer3);
    List<PieChartLegend> pieChartLegends = Lists.newArrayList();
    List<PiechartMapLayer> pieChartLayers = Lists.newArrayList();
    int[] indicatorIds = new int[] { 101, 102, 103 };
    for (int sliceCount = 1; sliceCount < 10; ++sliceCount) {
        PiechartMapLayer pieChartLayer = new PiechartMapLayer();
        for (int i = 0; i != sliceCount; ++i) {
            pieChartLayer.addIndicatorId(indicatorIds[i % indicatorIds.length]);
        }
        pieChartLayer.setMinRadius(25);
        pieChartLayer.setMaxRadius(25);
        PieChartLegend pieChartLegend = new PieChartLegend();
        pieChartLegend.setDefinition(pieChartLayer);
        pieChartLayers.add(pieChartLayer);
        pieChartLegends.add(pieChartLegend);
    }
    IndicatorDTO indicator101 = new IndicatorDTO();
    indicator101.setId(101);
    indicator101.setName("Nombre de salles de classe fonctionnelles (construites, rehabilitees, equipees) " + "pour l'education formelle et non formelle.");
    IndicatorDTO indicator102 = new IndicatorDTO();
    indicator102.setId(102);
    indicator102.setName("Nombre d'enfants ayant beneficie de kits scolaires, recreatifs et didactiques");
    IndicatorDTO indicator103 = new IndicatorDTO();
    indicator103.setId(103);
    indicator103.setName("Pourcentage des ménages qui utilsent la moustiquaire rationnellement");
    MapContent mapContent = new MapContent();
    mapContent.setFilterDescriptions(Collections.EMPTY_LIST);
    mapContent.setBaseMap(baseMap);
    mapContent.setZoomLevel(8);
    mapContent.setCenter(new Extents(-2.2, -2.1, 28.85, 28.9).center());
    mapContent.setMarkers(Arrays.asList((MapMarker) marker1));
    mapContent.getIndicators().addAll(Arrays.asList(indicator101, indicator102, indicator103));
    mapContent.addLegend(legend1);
    mapContent.addLegend(legend2);
    mapContent.addLegend(legend3);
    mapContent.getLegends().addAll(pieChartLegends);
    MapReportElement map = new MapReportElement();
    map.setTitle("My Map");
    map.setContent(mapContent);
    map.addLayer(layer1);
    map.addLayer(layer2);
    map.addLayer(layer3);
    map.getLayers().addAll(pieChartLayers);
    ReportContent content = new ReportContent();
    content.setFilterDescriptions(Collections.EMPTY_LIST);
    Report report = new Report();
    report.setContent(content);
    report.addElement(map);
    renderToPdf(report, "legend.pdf");
    renderToHtml(report, "legend.html");
    renderToRtf(report, "legend.rtf");
    renderToPpt(map, "legend.ppt");
}
Also used : ReportContent(org.activityinfo.shared.report.content.ReportContent) BubbleLayerLegend(org.activityinfo.shared.report.content.BubbleLayerLegend) MapMarker(org.activityinfo.shared.report.content.MapMarker) IconMapMarker(org.activityinfo.shared.report.content.IconMapMarker) BubbleMapMarker(org.activityinfo.shared.report.content.BubbleMapMarker) IconMapLayer(org.activityinfo.shared.report.model.layers.IconMapLayer) MapContent(org.activityinfo.shared.report.content.MapContent) Report(org.activityinfo.shared.report.model.Report) BubbleMapMarker(org.activityinfo.shared.report.content.BubbleMapMarker) BubbleMapLayer(org.activityinfo.shared.report.model.layers.BubbleMapLayer) Extents(org.activityinfo.shared.util.mapping.Extents) MapReportElement(org.activityinfo.shared.report.model.MapReportElement) IndicatorDTO(org.activityinfo.shared.dto.IndicatorDTO) PieChartLegend(org.activityinfo.shared.report.content.PieChartLegend) TileBaseMap(org.activityinfo.shared.map.TileBaseMap) PiechartMapLayer(org.activityinfo.shared.report.model.layers.PiechartMapLayer) IconLayerLegend(org.activityinfo.shared.report.content.IconLayerLegend) Test(org.junit.Test)

Example 10 with ReportContent

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

the class ItextReportRendererTest method chartTest.

@Test
public void chartTest() throws IOException {
    DummyPivotTableData data = new DummyPivotTableData();
    PivotChartContent chartContent = new PivotChartContent();
    chartContent.setData(data.table);
    chartContent.setYMin(0);
    chartContent.setYStep(100);
    chartContent.setFilterDescriptions(Collections.EMPTY_LIST);
    PivotChartReportElement chart = new PivotChartReportElement(Type.Pie);
    chart.setTitle("My Pie Chart");
    chart.setCategoryDimensions(data.colDims);
    chart.setSeriesDimensions(data.rowDims);
    chart.setContent(chartContent);
    ReportContent content = new ReportContent();
    content.setFilterDescriptions(Collections.EMPTY_LIST);
    Report report = new Report();
    report.setContent(content);
    report.addElement(chart);
    renderToPdf(report, "chartTest.pdf");
    renderToRtf(report, "chartTest.rtf");
}
Also used : ReportContent(org.activityinfo.shared.report.content.ReportContent) Report(org.activityinfo.shared.report.model.Report) DummyPivotTableData(org.activityinfo.server.report.DummyPivotTableData) PivotChartReportElement(org.activityinfo.shared.report.model.PivotChartReportElement) PivotChartContent(org.activityinfo.shared.report.content.PivotChartContent) Test(org.junit.Test)

Aggregations

ReportContent (org.activityinfo.shared.report.content.ReportContent)10 Report (org.activityinfo.shared.report.model.Report)9 Test (org.junit.Test)8 MapReportElement (org.activityinfo.shared.report.model.MapReportElement)5 DummyPivotTableData (org.activityinfo.server.report.DummyPivotTableData)4 TileBaseMap (org.activityinfo.shared.map.TileBaseMap)4 BubbleMapMarker (org.activityinfo.shared.report.content.BubbleMapMarker)4 IconMapMarker (org.activityinfo.shared.report.content.IconMapMarker)4 MapContent (org.activityinfo.shared.report.content.MapContent)4 MapMarker (org.activityinfo.shared.report.content.MapMarker)4 PivotTableReportElement (org.activityinfo.shared.report.model.PivotTableReportElement)4 Extents (org.activityinfo.shared.util.mapping.Extents)4 PivotContent (org.activityinfo.shared.report.content.PivotContent)3 PivotChartReportElement (org.activityinfo.shared.report.model.PivotChartReportElement)3 TextReportElement (org.activityinfo.shared.report.model.TextReportElement)3 EntityCategory (org.activityinfo.shared.report.content.EntityCategory)2 PivotChartContent (org.activityinfo.shared.report.content.PivotChartContent)2 PivotTableData (org.activityinfo.shared.report.content.PivotTableData)2 Axis (org.activityinfo.shared.report.content.PivotTableData.Axis)2 SimpleCategory (org.activityinfo.shared.report.content.SimpleCategory)2