Search in sources :

Example 1 with DateDimension

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

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

the class ReportJsonFactory method encodeDimensionList.

public JsonArray encodeDimensionList(List<Dimension> dims) {
    JsonArray jsonDims = new JsonArray();
    for (int i = 0; i < dims.size(); i++) {
        JsonObject jsonDim = new JsonObject();
        DimensionType type = dims.get(i).getType();
        if (type.equals(DimensionType.Date)) {
            DateDimension dim = (DateDimension) dims.get(i);
            jsonDim.addProperty("type", dim.getType().toString());
            jsonDim.addProperty("dateUnit", dim.getUnit().toString());
            if (dim.getColor() != null) {
                jsonDim.addProperty("color", dim.getColor());
            }
            if (!dim.getCategories().isEmpty()) {
                jsonDim.add("categories", encodeCategories(dim.getCategories()));
            }
        } else if (type.equals(DimensionType.AdminLevel)) {
            AdminDimension dim = (AdminDimension) dims.get(i);
            jsonDim.addProperty("type", dim.getType().toString());
            jsonDim.addProperty("level", dim.getLevelId());
            if (dim.getColor() != null) {
                jsonDim.addProperty("color", dim.getColor());
            }
            if (!dim.getCategories().isEmpty()) {
                jsonDim.add("categories", encodeCategories(dim.getCategories()));
            }
        } else {
            Dimension dim = dims.get(i);
            jsonDim.addProperty("type", dim.getType().toString());
            if (dim.getColor() != null) {
                jsonDim.addProperty("color", dim.getColor());
            }
            if (!dim.getCategories().isEmpty()) {
                jsonDim.add("categories", encodeCategories(dim.getCategories()));
            }
        }
        jsonDims.add(jsonDim);
    }
    return jsonDims;
}
Also used : JsonArray(com.google.gson.JsonArray) DimensionType(org.activityinfo.shared.report.model.DimensionType) JsonObject(com.google.gson.JsonObject) Dimension(org.activityinfo.shared.report.model.Dimension) AdminDimension(org.activityinfo.shared.report.model.AdminDimension) DateDimension(org.activityinfo.shared.report.model.DateDimension) AdminDimension(org.activityinfo.shared.report.model.AdminDimension) DateDimension(org.activityinfo.shared.report.model.DateDimension)

Example 3 with DateDimension

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

the class PivotTableTemplate method createElement.

@Override
public void createElement(AsyncCallback<ReportElement> callback) {
    PivotTableReportElement table = new PivotTableReportElement();
    table.addColDimension(new DateDimension(DateUnit.YEAR));
    table.addColDimension(new DateDimension(DateUnit.MONTH));
    table.addRowDimension(new Dimension(DimensionType.Partner));
    callback.onSuccess(table);
}
Also used : Dimension(org.activityinfo.shared.report.model.Dimension) DateDimension(org.activityinfo.shared.report.model.DateDimension) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement) DateDimension(org.activityinfo.shared.report.model.DateDimension)

Example 4 with DateDimension

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

the class ItextReportRendererTest method manyColumns.

@Test
public void manyColumns() throws IOException {
    PivotTableData data = new PivotTableData();
    Dimension partner = new Dimension(DimensionType.Partner);
    Dimension year = new DateDimension(DateUnit.YEAR);
    EntityCategory avsi = new EntityCategory(100, "AVSI RRMP");
    Axis avsiRow = data.getRootRow().addChild(partner, avsi, avsi.getLabel(), comparator);
    for (int y = 2011; y < 2030; ++y) {
        Axis col = data.getRootColumn().addChild(year, new SimpleCategory("" + y), "" + y, comparator);
        avsiRow.setValue(col, (double) y);
    }
    PivotContent tableContent = new PivotContent(data, Lists.<FilterDescription>newArrayList());
    PivotTableReportElement table = new PivotTableReportElement();
    table.addRowDimension(partner);
    table.addColDimension(year);
    table.setContent(tableContent);
    ReportContent content = new ReportContent();
    content.setFilterDescriptions(Collections.EMPTY_LIST);
    Report report = new Report();
    report.setContent(content);
    report.addElement(table);
    renderToPdf(report, "narrowColumns.pdf");
    renderToRtf(report, "narrowColumns.rtf");
}
Also used : SimpleCategory(org.activityinfo.shared.report.content.SimpleCategory) ReportContent(org.activityinfo.shared.report.content.ReportContent) PivotTableData(org.activityinfo.shared.report.content.PivotTableData) DummyPivotTableData(org.activityinfo.server.report.DummyPivotTableData) Report(org.activityinfo.shared.report.model.Report) PivotContent(org.activityinfo.shared.report.content.PivotContent) DateDimension(org.activityinfo.shared.report.model.DateDimension) Dimension(org.activityinfo.shared.report.model.Dimension) AdminDimension(org.activityinfo.shared.report.model.AdminDimension) EntityCategory(org.activityinfo.shared.report.content.EntityCategory) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement) DateDimension(org.activityinfo.shared.report.model.DateDimension) Axis(org.activityinfo.shared.report.content.PivotTableData.Axis) Test(org.junit.Test)

Example 5 with DateDimension

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

the class ItextReportRendererTest method nestedColumns.

@Test
public void nestedColumns() throws IOException {
    Dimension province = new AdminDimension(1);
    Dimension partner = new Dimension(DimensionType.Partner);
    Dimension year = new DateDimension(DateUnit.YEAR);
    Dimension month = new DateDimension(DateUnit.MONTH);
    EntityCategory avsi = new EntityCategory(100, "AVSI RRMP");
    PivotTableData data = new PivotTableData();
    Axis sudKivu = data.getRootColumn().addChild(province, new EntityCategory(1, "Sud Kivu"), "Sud Kivu", comparator);
    Axis y2010 = sudKivu.addChild(year, new SimpleCategory("2010"), "2010", comparator);
    Axis y2011 = sudKivu.addChild(year, new SimpleCategory("2010"), "2010", comparator);
    Axis jan2010 = y2010.addChild(month, new SimpleCategory("Jan"), "Jan", comparator);
    Axis feb2010 = y2010.addChild(month, new SimpleCategory("Feb"), "Feb", comparator);
    Axis jan2011 = y2011.addChild(month, new SimpleCategory("Jan"), "Jan", comparator);
    Axis feb2011 = y2011.addChild(month, new SimpleCategory("Feb"), "Feb", comparator);
    Axis avsiRow = data.getRootRow().addChild(partner, avsi, avsi.getLabel(), comparator);
    avsiRow.setValue(jan2010, 1d);
    avsiRow.setValue(feb2010, 2d);
    avsiRow.setValue(jan2011, 3d);
    avsiRow.setValue(feb2011, 4d);
    PivotContent tableContent = new PivotContent(data, Lists.<FilterDescription>newArrayList());
    PivotTableReportElement table = new PivotTableReportElement();
    table.addRowDimension(partner);
    table.addColDimension(province);
    table.addColDimension(year);
    table.addColDimension(month);
    table.setContent(tableContent);
    ReportContent content = new ReportContent();
    content.setFilterDescriptions(Collections.EMPTY_LIST);
    Report report = new Report();
    report.setContent(content);
    report.addElement(table);
    renderToPdf(report, "nestedColumns.pdf");
    renderToRtf(report, "nestedColumns.rtf");
    renderToXls(report, "nestedColumns.xls");
}
Also used : SimpleCategory(org.activityinfo.shared.report.content.SimpleCategory) ReportContent(org.activityinfo.shared.report.content.ReportContent) PivotTableData(org.activityinfo.shared.report.content.PivotTableData) DummyPivotTableData(org.activityinfo.server.report.DummyPivotTableData) Report(org.activityinfo.shared.report.model.Report) PivotContent(org.activityinfo.shared.report.content.PivotContent) DateDimension(org.activityinfo.shared.report.model.DateDimension) Dimension(org.activityinfo.shared.report.model.Dimension) AdminDimension(org.activityinfo.shared.report.model.AdminDimension) AdminDimension(org.activityinfo.shared.report.model.AdminDimension) EntityCategory(org.activityinfo.shared.report.content.EntityCategory) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement) DateDimension(org.activityinfo.shared.report.model.DateDimension) Axis(org.activityinfo.shared.report.content.PivotTableData.Axis) Test(org.junit.Test)

Aggregations

DateDimension (org.activityinfo.shared.report.model.DateDimension)20 Test (org.junit.Test)15 Dimension (org.activityinfo.shared.report.model.Dimension)13 AdminDimension (org.activityinfo.shared.report.model.AdminDimension)12 AttributeGroupDimension (org.activityinfo.shared.report.model.AttributeGroupDimension)8 OnDataSet (org.activityinfo.server.database.OnDataSet)5 PivotTableReportElement (org.activityinfo.shared.report.model.PivotTableReportElement)3 LocalDate (com.bedatadriven.rebar.time.calendar.LocalDate)2 JsonObject (com.google.gson.JsonObject)2 DummyPivotTableData (org.activityinfo.server.report.DummyPivotTableData)2 DateUtilCalendarImpl (org.activityinfo.server.util.date.DateUtilCalendarImpl)2 EntityCategory (org.activityinfo.shared.report.content.EntityCategory)2 PivotContent (org.activityinfo.shared.report.content.PivotContent)2 PivotTableData (org.activityinfo.shared.report.content.PivotTableData)2 Axis (org.activityinfo.shared.report.content.PivotTableData.Axis)2 ReportContent (org.activityinfo.shared.report.content.ReportContent)2 SimpleCategory (org.activityinfo.shared.report.content.SimpleCategory)2 DateRange (org.activityinfo.shared.report.model.DateRange)2 Report (org.activityinfo.shared.report.model.Report)2 JsonArray (com.google.gson.JsonArray)1