Search in sources :

Example 26 with Dimension

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

the class PivotSitesHandlerLocalTest method withPartnerAsDimension.

private void withPartnerAsDimension() {
    partnerDim = new Dimension(DimensionType.Partner);
    dimensions.add(partnerDim);
}
Also used : Dimension(org.activityinfo.shared.report.model.Dimension) AttributeGroupDimension(org.activityinfo.shared.report.model.AttributeGroupDimension) AdminDimension(org.activityinfo.shared.report.model.AdminDimension) DateDimension(org.activityinfo.shared.report.model.DateDimension)

Example 27 with Dimension

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

the class PivotSitesHandlerLocalTest method withIndicatorAsDimension.

private void withIndicatorAsDimension() {
    indicatorDim = new Dimension(DimensionType.Indicator);
    dimensions.add(indicatorDim);
}
Also used : Dimension(org.activityinfo.shared.report.model.Dimension) AttributeGroupDimension(org.activityinfo.shared.report.model.AttributeGroupDimension) AdminDimension(org.activityinfo.shared.report.model.AdminDimension) DateDimension(org.activityinfo.shared.report.model.DateDimension)

Example 28 with Dimension

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

the class PivotSitesHandlerLocalTest method testTargetPivot.

/**
 * year, quarter and month functions in SqliteDialect throw java.lang.UnsupportedOperationException
 */
@Test(expected = RuntimeException.class)
@OnDataSet("/dbunit/sites-simple-target.db.xml")
public void testTargetPivot() {
    withIndicatorAsDimension();
    dimensions.add(new DateDimension(DateUnit.YEAR));
    dimensions.add(new Dimension(DimensionType.Target));
    filter.addRestriction(DimensionType.Indicator, 1);
    filter.setDateRange(new DateRange(new LocalDate(2008, 1, 1), new LocalDate(2008, 12, 31)));
    execute();
    assertThat().thereAre(2).buckets();
}
Also used : DateRange(org.activityinfo.shared.report.model.DateRange) Dimension(org.activityinfo.shared.report.model.Dimension) AttributeGroupDimension(org.activityinfo.shared.report.model.AttributeGroupDimension) AdminDimension(org.activityinfo.shared.report.model.AdminDimension) DateDimension(org.activityinfo.shared.report.model.DateDimension) DateDimension(org.activityinfo.shared.report.model.DateDimension) LocalDate(com.bedatadriven.rebar.time.calendar.LocalDate) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Example 29 with Dimension

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

the class PivotSitesHandlerLocalTest method targetFilter.

@Test
public void targetFilter() {
    // Pivoting: PivotSites [dimensions=[Date, Partner, Date, Target,
    // Activity, Indicator],
    // filter=AdminLevel={ 141801 }, Partner={ 130 },
    // Indicator={ 747 746 745 744 749 748 739 738 743 740 119 118 3661 125
    // 124 123 122 121 }, valueType=INDICATOR]
    withPartnerAsDimension();
    // dimensions.add(new DateDimension(DateUnit.YEAR));
    dimensions.add(new Dimension(DimensionType.Target));
    dimensions.add(new Dimension(DimensionType.Activity));
    dimensions.add(new Dimension(DimensionType.Indicator));
    filter.addRestriction(DimensionType.AdminLevel, 141801);
    filter.addRestriction(DimensionType.Partner, 130);
    filter.addRestriction(DimensionType.Indicator, 1);
    execute();
}
Also used : Dimension(org.activityinfo.shared.report.model.Dimension) AttributeGroupDimension(org.activityinfo.shared.report.model.AttributeGroupDimension) AdminDimension(org.activityinfo.shared.report.model.AdminDimension) DateDimension(org.activityinfo.shared.report.model.DateDimension) Test(org.junit.Test)

Example 30 with Dimension

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

the class ReportJsonFactory method decodeDimensionList.

public List<Dimension> decodeDimensionList(JsonArray dimensions) {
    Iterator<JsonElement> it = dimensions.iterator();
    List<Dimension> dimensionsList = new ArrayList<Dimension>();
    while (it.hasNext()) {
        JsonObject dim = it.next().getAsJsonObject();
        String type = dim.get("type").getAsString();
        if (type.equals(DimensionType.Date.toString())) {
            String dateUnit = dim.get("dateUnit").getAsString();
            DateDimension dimension = new DateDimension(DateUnit.valueOf(dateUnit));
            JsonElement categories = dim.get("categories");
            if (categories != null) {
                dimension.setCategories(decodeCategories(categories));
            }
            dimensionsList.add(dimension);
        } else if (type.equals(DimensionType.AdminLevel.toString())) {
            Integer level = dim.get("level").getAsInt();
            AdminDimension dimension = new AdminDimension(level);
            JsonElement categories = dim.get("categories");
            if (categories != null) {
                dimension.setCategories(decodeCategories(categories));
            }
            dimensionsList.add(dimension);
        } else {
            Dimension dimension = new Dimension(DimensionType.valueOf(dim.get("type").getAsString()));
            JsonElement color = dim.get("color");
            if (color != null) {
                dimension.setColor(color.getAsString());
            }
            JsonElement categories = dim.get("categories");
            if (categories != null) {
                dimension.setCategories(decodeCategories(categories));
            }
            dimensionsList.add(dimension);
        }
    }
    return dimensionsList;
}
Also used : JsonElement(com.google.gson.JsonElement) ArrayList(java.util.ArrayList) 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)

Aggregations

Dimension (org.activityinfo.shared.report.model.Dimension)46 AdminDimension (org.activityinfo.shared.report.model.AdminDimension)31 AttributeGroupDimension (org.activityinfo.shared.report.model.AttributeGroupDimension)29 DateDimension (org.activityinfo.shared.report.model.DateDimension)28 Test (org.junit.Test)23 Bucket (org.activityinfo.shared.command.result.Bucket)11 OnDataSet (org.activityinfo.server.database.OnDataSet)10 PivotTableReportElement (org.activityinfo.shared.report.model.PivotTableReportElement)10 EntityCategory (org.activityinfo.shared.report.content.EntityCategory)9 ArrayList (java.util.ArrayList)6 PivotSites (org.activityinfo.shared.command.PivotSites)6 PivotTableData (org.activityinfo.shared.report.content.PivotTableData)4 Comparator (java.util.Comparator)3 DispatcherSync (org.activityinfo.server.command.DispatcherSync)3 User (org.activityinfo.server.database.hibernate.entity.User)3 DimensionCategory (org.activityinfo.shared.report.content.DimensionCategory)3 LocalDate (com.bedatadriven.rebar.time.calendar.LocalDate)2 JsonObject (com.google.gson.JsonObject)2 List (java.util.List)2 ReportChangeEvent (org.activityinfo.client.page.report.ReportChangeEvent)2