Search in sources :

Example 1 with PivotChartReportElement

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);
}
Also used : PivotChartReportElement(org.activityinfo.shared.report.model.PivotChartReportElement) DateDimension(org.activityinfo.shared.report.model.DateDimension)

Example 2 with PivotChartReportElement

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();
}
Also used : JsonArray(com.google.gson.JsonArray) MapReportElement(org.activityinfo.shared.report.model.MapReportElement) JsonObject(com.google.gson.JsonObject) PivotChartReportElement(org.activityinfo.shared.report.model.PivotChartReportElement) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement) MapReportElement(org.activityinfo.shared.report.model.MapReportElement) ReportElement(org.activityinfo.shared.report.model.ReportElement) PivotChartReportElement(org.activityinfo.shared.report.model.PivotChartReportElement) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement)

Example 3 with PivotChartReportElement

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());
}
Also used : JsonElement(com.google.gson.JsonElement) PivotChartReportElement(org.activityinfo.shared.report.model.PivotChartReportElement) Test(org.junit.Test)

Example 4 with PivotChartReportElement

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);
}
Also used : PivotChartReportElement(org.activityinfo.shared.report.model.PivotChartReportElement)

Example 5 with PivotChartReportElement

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);
}
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)

Aggregations

PivotChartReportElement (org.activityinfo.shared.report.model.PivotChartReportElement)12 Report (org.activityinfo.shared.report.model.Report)6 Test (org.junit.Test)6 PivotTableReportElement (org.activityinfo.shared.report.model.PivotTableReportElement)5 MapReportElement (org.activityinfo.shared.report.model.MapReportElement)4 JsonArray (com.google.gson.JsonArray)2 JsonElement (com.google.gson.JsonElement)2 JsonObject (com.google.gson.JsonObject)2 DummyPivotTableData (org.activityinfo.server.report.DummyPivotTableData)2 PivotChartContent (org.activityinfo.shared.report.content.PivotChartContent)2 ReportContent (org.activityinfo.shared.report.content.ReportContent)2 ReportElement (org.activityinfo.shared.report.model.ReportElement)2 TableElement (org.activityinfo.shared.report.model.TableElement)2 TextReportElement (org.activityinfo.shared.report.model.TextReportElement)2 DispatcherSync (org.activityinfo.server.command.DispatcherSync)1 IndicatorDAO (org.activityinfo.server.database.hibernate.dao.IndicatorDAO)1 Indicator (org.activityinfo.server.database.hibernate.entity.Indicator)1 User (org.activityinfo.server.database.hibernate.entity.User)1 PivotChartGenerator (org.activityinfo.server.report.generator.PivotChartGenerator)1 Filter (org.activityinfo.shared.command.Filter)1