Search in sources :

Example 11 with PivotTableReportElement

use of org.activityinfo.shared.report.model.PivotTableReportElement in project activityinfo by bedatadriven.

the class JaxbParseTest method testMarshallElements.

@Test
public void testMarshallElements() throws Throwable {
    Report report = new Report();
    report.addElement(new PivotChartReportElement());
    report.addElement(new PivotTableReportElement());
    dumpXml(report);
}
Also used : Report(org.activityinfo.shared.report.model.Report) PivotChartReportElement(org.activityinfo.shared.report.model.PivotChartReportElement) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement) Test(org.junit.Test)

Example 12 with PivotTableReportElement

use of org.activityinfo.shared.report.model.PivotTableReportElement in project activityinfo by bedatadriven.

the class JaxbParseTest method testDimensions.

@Test
public void testDimensions() throws Throwable {
    Report report = parseXml("dimensions.xml");
    dumpXml(report);
    Assert.assertEquals("element count", 1, report.getElements().size());
    Assert.assertTrue("is pivotTable", report.getElements().get(0) instanceof PivotTableReportElement);
    PivotTableReportElement table = report.getElement(0);
    Assert.assertEquals("dimension count", 2, table.getRowDimensions().size());
    Assert.assertEquals("indicator type", DimensionType.Indicator, table.getRowDimensions().get(0).getType());
    Assert.assertTrue("admin subclass", table.getRowDimensions().get(1) instanceof AdminDimension);
    Assert.assertEquals("level is 91", 91, ((AdminDimension) table.getRowDimensions().get(1)).getLevelId());
}
Also used : Report(org.activityinfo.shared.report.model.Report) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement) AdminDimension(org.activityinfo.shared.report.model.AdminDimension) Test(org.junit.Test)

Example 13 with PivotTableReportElement

use of org.activityinfo.shared.report.model.PivotTableReportElement in project activityinfo by bedatadriven.

the class PivotTableRendererTest method test.

@Test
public void test() {
    // input test data : element + content
    DummyPivotTableData testData = new DummyPivotTableData();
    PivotTableReportElement element = testData.Foobar1612Element();
    // Destination book
    HSSFWorkbook book = new HSSFWorkbook();
    // CLASS under test
    ExcelPivotTableRenderer renderer = new ExcelPivotTableRenderer();
    renderer.render(book, element);
    // VERIFY output
    Sheet sheet = book.getSheetAt(0);
    Assert.assertEquals("title cell", element.getTitle(), sheet.getRow(0).getCell(0).getRichStringCellValue().getString());
    Assert.assertEquals("last column header", "Abri", sheet.getRow(4).getCell(5).getRichStringCellValue().getString());
    Assert.assertEquals("columns headers indentation", (short) 0, sheet.getRow(4).getCell(3).getCellStyle().getIndention());
    // Write output to disk
    try {
        File outputFile = new File("target/report-tests");
        outputFile.mkdirs();
        OutputStream out = new FileOutputStream(outputFile.getAbsoluteFile() + "/PivotTableRendererTest.xls");
        book.write(out);
        out.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) DummyPivotTableData(org.activityinfo.server.report.DummyPivotTableData) IOException(java.io.IOException) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement) Sheet(org.apache.poi.ss.usermodel.Sheet) File(java.io.File) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook) Test(org.junit.Test)

Example 14 with PivotTableReportElement

use of org.activityinfo.shared.report.model.PivotTableReportElement 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)

Example 15 with PivotTableReportElement

use of org.activityinfo.shared.report.model.PivotTableReportElement in project activityinfo by bedatadriven.

the class ItextReportRendererTest method htmlImages.

@Test
public void htmlImages() 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);
    PivotContent tableContent = new PivotContent();
    tableContent.setFilterDescriptions(Collections.EMPTY_LIST);
    tableContent.setData(data.table);
    PivotTableReportElement table = new PivotTableReportElement();
    table.setColumnDimensions(data.colDims);
    table.setRowDimensions(data.rowDims);
    table.setTitle("My Table");
    table.setContent(tableContent);
    BubbleMapMarker marker1 = new BubbleMapMarker();
    marker1.setLat(-2.45);
    marker1.setLng(28.8);
    marker1.setX(100);
    marker1.setY(100);
    marker1.setRadius(25);
    TileBaseMap baseMap = new TileBaseMap();
    baseMap.setTileUrlPattern("http://mt{s}.aimaps.net/nordkivu.cd/v1/z{z}/{x}x{y}.png");
    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));
    MapReportElement map = new MapReportElement();
    map.setTitle("My Map");
    map.setContent(mapContent);
    ReportContent content = new ReportContent();
    content.setFilterDescriptions(Collections.EMPTY_LIST);
    Report report = new Report();
    report.setContent(content);
    report.addElement(chart);
    report.addElement(table);
    report.addElement(new TextReportElement("Testing 1..2.3.. français"));
    report.addElement(map);
    renderToPdf(report, "piechart.pdf");
    renderToHtml(report, "piechart.html");
    // renderToHtmlUsingWriter(report, "piechart2.html");
    renderToRtf(report, "piechart.rtf");
}
Also used : ReportContent(org.activityinfo.shared.report.content.ReportContent) MapMarker(org.activityinfo.shared.report.content.MapMarker) IconMapMarker(org.activityinfo.shared.report.content.IconMapMarker) BubbleMapMarker(org.activityinfo.shared.report.content.BubbleMapMarker) MapContent(org.activityinfo.shared.report.content.MapContent) Report(org.activityinfo.shared.report.model.Report) DummyPivotTableData(org.activityinfo.server.report.DummyPivotTableData) BubbleMapMarker(org.activityinfo.shared.report.content.BubbleMapMarker) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement) Extents(org.activityinfo.shared.util.mapping.Extents) TextReportElement(org.activityinfo.shared.report.model.TextReportElement) MapReportElement(org.activityinfo.shared.report.model.MapReportElement) PivotContent(org.activityinfo.shared.report.content.PivotContent) TileBaseMap(org.activityinfo.shared.map.TileBaseMap) PivotChartReportElement(org.activityinfo.shared.report.model.PivotChartReportElement) PivotChartContent(org.activityinfo.shared.report.content.PivotChartContent) Test(org.junit.Test)

Aggregations

PivotTableReportElement (org.activityinfo.shared.report.model.PivotTableReportElement)23 Test (org.junit.Test)15 Dimension (org.activityinfo.shared.report.model.Dimension)10 Report (org.activityinfo.shared.report.model.Report)7 PivotContent (org.activityinfo.shared.report.content.PivotContent)6 AdminDimension (org.activityinfo.shared.report.model.AdminDimension)5 PivotChartReportElement (org.activityinfo.shared.report.model.PivotChartReportElement)5 ArrayList (java.util.ArrayList)4 DummyPivotTableData (org.activityinfo.server.report.DummyPivotTableData)4 AttributeGroupDimension (org.activityinfo.shared.report.model.AttributeGroupDimension)4 PivotTableData (org.activityinfo.shared.report.content.PivotTableData)3 ReportContent (org.activityinfo.shared.report.content.ReportContent)3 DateDimension (org.activityinfo.shared.report.model.DateDimension)3 MapReportElement (org.activityinfo.shared.report.model.MapReportElement)3 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)3 JsonArray (com.google.gson.JsonArray)2 JsonObject (com.google.gson.JsonObject)2 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2