Search in sources :

Example 1 with DummyPivotTableData

use of org.activityinfo.server.report.DummyPivotTableData 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("build/report-tests");
        outputFile.mkdirs();
        OutputStream out = new FileOutputStream(new File(outputFile, "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.legacy.shared.reports.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 2 with DummyPivotTableData

use of org.activityinfo.server.report.DummyPivotTableData 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://www.activityinfo.org/resources/tile/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");
    renderToRtf(report, "piechart.rtf");
}
Also used : DummyPivotTableData(org.activityinfo.server.report.DummyPivotTableData) Extents(org.activityinfo.model.type.geo.Extents) TileBaseMap(org.activityinfo.legacy.shared.model.TileBaseMap) Test(org.junit.Test)

Example 3 with DummyPivotTableData

use of org.activityinfo.server.report.DummyPivotTableData 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 : DummyPivotTableData(org.activityinfo.server.report.DummyPivotTableData) Test(org.junit.Test)

Aggregations

DummyPivotTableData (org.activityinfo.server.report.DummyPivotTableData)3 Test (org.junit.Test)3 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 TileBaseMap (org.activityinfo.legacy.shared.model.TileBaseMap)1 PivotTableReportElement (org.activityinfo.legacy.shared.reports.model.PivotTableReportElement)1 Extents (org.activityinfo.model.type.geo.Extents)1 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)1 Sheet (org.apache.poi.ss.usermodel.Sheet)1