use of org.activityinfo.shared.report.model.PivotChartReportElement in project activityinfo by bedatadriven.
the class ChartTemplate method createElement.
@Override
public void createElement(final AsyncCallback<ReportElement> callback) {
PivotChartReportElement chart = new PivotChartReportElement();
chart.setCategoryDimension(new DateDimension(DateUnit.YEAR));
callback.onSuccess(chart);
}
use of org.activityinfo.shared.report.model.PivotChartReportElement in project activityinfo by bedatadriven.
the class ReportJsonFactory method serialize.
@Override
public String serialize(Report report) {
JsonObject jsonReport = new JsonObject();
// write custom maker
jsonReport.addProperty("id", report.getId());
if (report.getTitle() != null) {
jsonReport.addProperty("title", report.getTitle());
}
if (report.getSheetTitle() != null) {
jsonReport.addProperty("sheetTitle", report.getSheetTitle());
}
if (report.getDescription() != null) {
jsonReport.addProperty("description", report.getDescription());
}
if (report.getFileName() != null) {
jsonReport.addProperty("fileName", report.getFileName());
}
jsonReport.add("filter", encodeFilter(report.getFilter()));
if (report.getElements() != null) {
List<ReportElement> reportElements = report.getElements();
JsonArray jsonElements = new JsonArray();
for (int i = 0; i < reportElements.size(); i++) {
ReportElement rp = report.getElement(i);
if (rp instanceof PivotTableReportElement) {
jsonElements.add(encodePivotTableReportElement((PivotTableReportElement) rp));
} else if (rp instanceof PivotChartReportElement) {
jsonElements.add(encodePivotChartReportElement((PivotChartReportElement) rp));
} else if (rp instanceof MapReportElement) {
jsonElements.add(encodeMapReportElement((MapReportElement) rp));
}
}
jsonReport.add("elements", jsonElements);
}
return jsonReport.toString();
}
use of org.activityinfo.shared.report.model.PivotChartReportElement in project activityinfo by bedatadriven.
the class ReportSerializerTest method reportChartElementTest.
@Test
public void reportChartElementTest() {
String chartJson = "{\"elementType\":\"pivotChart\",\"title\":\"Chart Element\",\"type\":\"ClusteredBar\",\"filter\":{\"restrictions\":[]},\"categoryDimensions\":[{\"type\":\"AdminLevel\",\"caption\":\"admin level\",\"level\":0}],\"seriesDimensions\":[]}";
PivotChartReportElement chartElement = report.getElement(0);
JsonElement resultJsonElement = factory.encodePivotChartReportElement(chartElement);
System.out.println(resultJsonElement.toString());
assertEquals(chartJson, resultJsonElement.toString());
PivotChartReportElement resultChart = factory.decodePivotChartReportElement((JsonObject) resultJsonElement);
assertEquals(chartElement.getTitle(), resultChart.getTitle());
assertEquals(chartElement.getContent(), resultChart.getContent());
assertEquals(chartElement.getType(), resultChart.getType());
}
use of org.activityinfo.shared.report.model.PivotChartReportElement in project activityinfo by bedatadriven.
the class ReportSerializerTest method addChartElement.
private void addChartElement(Report report) {
PivotChartReportElement chartElement = new PivotChartReportElement();
chartElement.setTitle("Chart Element");
chartElement.setCategoryDimensions(createDimensionList());
report.addElement(chartElement);
}
use of org.activityinfo.shared.report.model.PivotChartReportElement 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);
}
Aggregations