Search in sources :

Example 6 with Report

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

the class JaxbParseTest method testFilter.

@Test
public void testFilter() throws Throwable {
    Report report = parseXml("filter.xml");
    dumpXml(report);
    Calendar minDate = Calendar.getInstance();
    minDate.setTime(report.getFilter().getDateRange().getMinDate());
    Assert.assertEquals(2008, minDate.get(Calendar.YEAR));
    Assert.assertEquals(11, minDate.get(Calendar.MONTH));
    Assert.assertEquals(1, minDate.get(Calendar.DATE));
    Assert.assertTrue(report.getFilter().isRestricted(DimensionType.Indicator));
    Assert.assertTrue(report.getFilter().getRestrictions(DimensionType.Indicator).contains(21));
}
Also used : Report(org.activityinfo.shared.report.model.Report) Calendar(java.util.Calendar) Test(org.junit.Test)

Example 7 with Report

use of org.activityinfo.shared.report.model.Report 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 8 with Report

use of org.activityinfo.shared.report.model.Report 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 9 with Report

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

the class ReportGeneratorTest method testFileName.

@Test
public void testFileName() {
    // Input user
    User user = new User();
    user.setLocale("en");
    // Input test data: report model + parameter
    Report report = new Report();
    report.setFileName("Report ${DATE_RANGE} of Activities");
    // Input test data: parameter values
    DateUtil dateUtil = new DateUtilCalendarImpl();
    DateRange dateRange = dateUtil.monthRange(2009, 1);
    // class under test
    ReportGenerator generator = new ReportGenerator(null, null, null, null, null);
    generator.generate(user, report, null, dateRange);
    // VERIFY correct file name
    Assert.assertEquals("Report Jan 2009 of Activities", report.getContent().getFileName());
}
Also used : DateRange(org.activityinfo.shared.report.model.DateRange) User(org.activityinfo.server.database.hibernate.entity.User) Report(org.activityinfo.shared.report.model.Report) DateUtil(org.activityinfo.shared.util.date.DateUtil) DateUtilCalendarImpl(org.activityinfo.server.util.date.DateUtilCalendarImpl) Test(org.junit.Test)

Example 10 with Report

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

the class ItextReportRendererTest method iconTest.

@Test
public void iconTest() throws IOException {
    IconMapMarker marker1 = new IconMapMarker();
    marker1.setIcon(MapIcon.fromEnum(Icon.Default));
    marker1.setLat(-2.45);
    marker1.setLng(28.8);
    marker1.setX(100);
    marker1.setY(100);
    TileBaseMap baseMap = new TileBaseMap();
    baseMap.setTileUrlPattern("//www.activityinfo.org/resources/tile/nordkivu.cd/{z}/{x}/{y}.png");
    IconMapLayer layer3 = new IconMapLayer();
    layer3.setIcon(MapIcon.Icon.Default.name());
    layer3.getIndicatorIds().add(101);
    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);
    map.addLayer(layer3);
    ReportContent content = new ReportContent();
    content.setFilterDescriptions(Collections.EMPTY_LIST);
    Report report = new Report();
    report.setContent(content);
    report.addElement(map);
    renderToPdf(report, "iconMarker.pdf");
    renderToHtml(report, "iconMarker.html");
    renderToRtf(report, "iconMarker.rtf");
    renderToPpt(map, "iconMarker.ppt");
    renderToImage(map, "iconMarker.png");
}
Also used : MapReportElement(org.activityinfo.shared.report.model.MapReportElement) 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) IconMapLayer(org.activityinfo.shared.report.model.layers.IconMapLayer) MapContent(org.activityinfo.shared.report.content.MapContent) Report(org.activityinfo.shared.report.model.Report) IconMapMarker(org.activityinfo.shared.report.content.IconMapMarker) TileBaseMap(org.activityinfo.shared.map.TileBaseMap) Extents(org.activityinfo.shared.util.mapping.Extents) Test(org.junit.Test)

Aggregations

Report (org.activityinfo.shared.report.model.Report)37 Test (org.junit.Test)22 MapReportElement (org.activityinfo.shared.report.model.MapReportElement)11 ReportContent (org.activityinfo.shared.report.content.ReportContent)9 PivotTableReportElement (org.activityinfo.shared.report.model.PivotTableReportElement)9 PivotChartReportElement (org.activityinfo.shared.report.model.PivotChartReportElement)8 FileOutputStream (java.io.FileOutputStream)5 DummyPivotTableData (org.activityinfo.server.report.DummyPivotTableData)4 TileBaseMap (org.activityinfo.shared.map.TileBaseMap)4 TableElement (org.activityinfo.shared.report.model.TableElement)4 TextReportElement (org.activityinfo.shared.report.model.TextReportElement)4 IOException (java.io.IOException)3 JAXBContext (javax.xml.bind.JAXBContext)3 Unmarshaller (javax.xml.bind.Unmarshaller)3 ReportDefinition (org.activityinfo.server.database.hibernate.entity.ReportDefinition)3 BubbleMapMarker (org.activityinfo.shared.report.content.BubbleMapMarker)3 IconMapMarker (org.activityinfo.shared.report.content.IconMapMarker)3 MapContent (org.activityinfo.shared.report.content.MapContent)3 MapMarker (org.activityinfo.shared.report.content.MapMarker)3 PivotContent (org.activityinfo.shared.report.content.PivotContent)3