Search in sources :

Example 1 with TableElement

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

the class ExcelReportRenderer method render.

@Override
public void render(ReportElement element, OutputStream os) throws IOException {
    HSSFWorkbook book = new HSSFWorkbook();
    if (element instanceof Report) {
        render(book, (Report) element);
    } else if (element instanceof PivotTableReportElement) {
        pivotTableRenderer.render(book, (PivotTableReportElement) element);
    } else if (element instanceof TableElement) {
        tableRenderer.render(book, (TableElement) element);
    } else if (element instanceof PivotChartReportElement) {
        chartRenderer.render(book, (PivotChartReportElement) element);
    }
    book.write(os);
}
Also used : Report(org.activityinfo.shared.report.model.Report) PivotChartReportElement(org.activityinfo.shared.report.model.PivotChartReportElement) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook) TableElement(org.activityinfo.shared.report.model.TableElement)

Example 2 with TableElement

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

the class JaxbParseTest method testElements.

@Test
public void testElements() throws JAXBException {
    Report report = parseXml("report-elements.xml");
    dumpXml(report);
    Assert.assertEquals("element count", 7, report.getElements().size());
    Assert.assertTrue("pivotTable", report.getElements().get(0) instanceof PivotTableReportElement);
    Assert.assertTrue("pivotChart", report.getElements().get(1) instanceof PivotChartReportElement);
    Assert.assertTrue("table", report.getElements().get(2) instanceof TableElement);
    Assert.assertTrue("map", report.getElements().get(3) instanceof MapReportElement);
    Assert.assertTrue("static", report.getElements().get(4) instanceof TextReportElement);
    Assert.assertTrue("static", report.getElements().get(5) instanceof TextReportElement);
    Assert.assertTrue("static", report.getElements().get(6) instanceof ImageReportElement);
}
Also used : MapReportElement(org.activityinfo.shared.report.model.MapReportElement) ImageReportElement(org.activityinfo.shared.report.model.ImageReportElement) Report(org.activityinfo.shared.report.model.Report) PivotChartReportElement(org.activityinfo.shared.report.model.PivotChartReportElement) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement) TableElement(org.activityinfo.shared.report.model.TableElement) TextReportElement(org.activityinfo.shared.report.model.TextReportElement) Test(org.junit.Test)

Example 3 with TableElement

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

the class JaxbParseTest method testTable.

@Test
public void testTable() throws Throwable {
    Report report = parseXml("table.xml");
    dumpXml(report);
    TableElement table = report.getElement(0);
    Assert.assertEquals("column count", 8, table.getRootColumn().getChildren().size());
// Assert.assertEquals(TableColumn.SortOrder.Descending,
// table.getSortBy().get(0).getOrder());
// Assert.assertEquals(TableColumn.SortOrder.Ascending,
// table.getSortBy().get(1).getOrder());
}
Also used : Report(org.activityinfo.shared.report.model.Report) TableElement(org.activityinfo.shared.report.model.TableElement) Test(org.junit.Test)

Example 4 with TableElement

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

the class ReportsTest method testConsolideDesActivitesReport.

@Test
public void testConsolideDesActivitesReport() throws Throwable {
    // Setup test
    Report report = getReport("realworld/ConsolideDesActivites.xml");
    reportGenerator.generate(user, report, null, null);
    TableElement pivotTable = (TableElement) report.getElements().get(2);
    MapReportElement map1 = pivotTable.getMap();
    BubbleMapLayer bubbleMap = (BubbleMapLayer) map1.getLayers().get(0);
    assertTrue("Arabic numbering expected", bubbleMap.getLabelSequence() instanceof ArabicNumberSequence);
    assertEquals("MinRadius of 8 expected", bubbleMap.getMinRadius(), 8);
    assertEquals("MaxRadius of 14 expected", bubbleMap.getMaxRadius(), 14);
    assertEquals("Graduated scaling expected", bubbleMap.getScaling(), ScalingType.Graduated);
}
Also used : MapReportElement(org.activityinfo.shared.report.model.MapReportElement) ArabicNumberSequence(org.activityinfo.shared.report.model.labeling.ArabicNumberSequence) Report(org.activityinfo.shared.report.model.Report) BubbleMapLayer(org.activityinfo.shared.report.model.layers.BubbleMapLayer) TableElement(org.activityinfo.shared.report.model.TableElement) Test(org.junit.Test)

Example 5 with TableElement

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

the class TableGeneratorTest method testMap.

// 
// @Test
// public void tableWithMap() {
// 
// MapReportElement map = new MapReportElement();
// map.setBaseMapId(GoogleBaseMap.ROADMAP.getId());
// 
// BubbleMapLayer layer = new BubbleMapLayer();
// layer.addIndicator(INDICATOR_ID);
// map.addLayer(layer);
// 
// TableElement table = new TableElement();
// table.setMap(map);
// 
// TableColumn column = new TableColumn("Location", "location.name");
// table.addColumn(column);
// 
// TableColumn mapColumn = new TableColumn("Map", "map");
// table.addColumn(mapColumn);
// 
// DispatcherSync dispatcher = createDispatcher();
// TableGenerator gtor = new TableGenerator(dispatcher, new
// MapGenerator(dispatcher, null, null));
// gtor.generate(user, table, null, null);
// 
// Assert.assertNotNull("content is set", table.getContent());
// 
// TableData data = table.getContent().getData();
// List<SiteDTO> rows = data.getRows();
// Assert.assertEquals("row count", 1, rows.size());
// 
// SiteDTO row = rows.get(0);
// assertThat((String)row.get(column.getSitePropertyName()),
// equalTo("tampa bay"));
// assertThat((String)row.get("map"), equalTo("1"));
// }
@Test
public void testMap() {
    TableElement table = new TableElement();
    table.addColumn(new TableColumn("Index", "map"));
    table.addColumn(new TableColumn("Site", "location.name"));
    MapReportElement map = new MapReportElement();
    map.setBaseMapId("map1");
    CircledMapLayer layer = new BubbleMapLayer();
    layer.setLabelSequence(new ArabicNumberSequence());
    map.addLayer(layer);
    table.setMap(map);
    DispatcherSync dispatcher = createMock(DispatcherSync.class);
    expect(dispatcher.execute(isA(GetSites.class))).andReturn(new SiteResult(dummySite())).anyTimes();
    TileBaseMap baseMap1 = new TileBaseMap();
    baseMap1.setId("map1");
    baseMap1.setMinZoom(0);
    baseMap1.setMaxZoom(12);
    baseMap1.setCopyright("(C)");
    baseMap1.setName("Grand Canyon");
    baseMap1.setTileUrlPattern("http://s/test.png");
    expect(dispatcher.execute(isA(GetBaseMaps.class))).andReturn(new BaseMapResult(Collections.singletonList(baseMap1)));
    replay(dispatcher);
    TableGenerator gtor = new TableGenerator(dispatcher, new MapGenerator(dispatcher, new MockIndicatorDAO()));
    gtor.generate(user, table, null, null);
    MapContent mapContent = map.getContent();
    Assert.assertNotNull("map content", mapContent);
    Assert.assertEquals("marker count", 1, mapContent.getMarkers().size());
    Assert.assertEquals("label on marker", "1", ((BubbleMapMarker) mapContent.getMarkers().get(0)).getLabel());
    Map<Integer, String> siteLabels = mapContent.siteLabelMap();
    Assert.assertEquals("site id in map", "1", siteLabels.get(1));
    SiteDTO row = table.getContent().getData().getRows().get(0);
    Assert.assertEquals("label on row", "1", row.get("map"));
}
Also used : ArabicNumberSequence(org.activityinfo.shared.report.model.labeling.ArabicNumberSequence) MapContent(org.activityinfo.shared.report.content.MapContent) BaseMapResult(org.activityinfo.shared.command.result.BaseMapResult) BubbleMapLayer(org.activityinfo.shared.report.model.layers.BubbleMapLayer) TableColumn(org.activityinfo.shared.report.model.TableColumn) TableElement(org.activityinfo.shared.report.model.TableElement) MapReportElement(org.activityinfo.shared.report.model.MapReportElement) SiteResult(org.activityinfo.shared.command.result.SiteResult) TileBaseMap(org.activityinfo.shared.map.TileBaseMap) CircledMapLayer(org.activityinfo.shared.report.model.layers.CircledMapLayer) GetBaseMaps(org.activityinfo.shared.command.GetBaseMaps) SiteDTO(org.activityinfo.shared.dto.SiteDTO) DispatcherSync(org.activityinfo.server.command.DispatcherSync) Test(org.junit.Test)

Aggregations

TableElement (org.activityinfo.shared.report.model.TableElement)6 Test (org.junit.Test)5 Report (org.activityinfo.shared.report.model.Report)4 MapReportElement (org.activityinfo.shared.report.model.MapReportElement)3 SiteDTO (org.activityinfo.shared.dto.SiteDTO)2 PivotChartReportElement (org.activityinfo.shared.report.model.PivotChartReportElement)2 PivotTableReportElement (org.activityinfo.shared.report.model.PivotTableReportElement)2 TableColumn (org.activityinfo.shared.report.model.TableColumn)2 ArabicNumberSequence (org.activityinfo.shared.report.model.labeling.ArabicNumberSequence)2 BubbleMapLayer (org.activityinfo.shared.report.model.layers.BubbleMapLayer)2 DispatcherSync (org.activityinfo.server.command.DispatcherSync)1 GetBaseMaps (org.activityinfo.shared.command.GetBaseMaps)1 BaseMapResult (org.activityinfo.shared.command.result.BaseMapResult)1 SiteResult (org.activityinfo.shared.command.result.SiteResult)1 TileBaseMap (org.activityinfo.shared.map.TileBaseMap)1 MapContent (org.activityinfo.shared.report.content.MapContent)1 TableData (org.activityinfo.shared.report.content.TableData)1 ImageReportElement (org.activityinfo.shared.report.model.ImageReportElement)1 TextReportElement (org.activityinfo.shared.report.model.TextReportElement)1 CircledMapLayer (org.activityinfo.shared.report.model.layers.CircledMapLayer)1