Search in sources :

Example 16 with Dimension

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

the class PivotSitesHandlerTest method testPointsInferred.

@Test
@OnDataSet("/dbunit/sites-points.db.xml")
public void testPointsInferred() {
    dimensions.add(new Dimension(DimensionType.Location));
    withPoints();
    execute();
    assertThat().forLocation(1).thereIsOneBucketWithValue(1500).at((26.8106418 + 28.37725848) / 2.0, (-4.022388142 + -1.991221064) / 2.0);
    assertThat().forLocation(2).thereIsOneBucketWithValue(3600).at(27.328491, -2.712609);
}
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) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Example 17 with Dimension

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

the class PivotSitesHandlerTest 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) DateDimension(org.activityinfo.shared.report.model.DateDimension) Test(org.junit.Test)

Example 18 with Dimension

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

the class PivotSitesHandlerTest 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 19 with Dimension

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

the class PivotSitesHandlerTest method execute.

private void execute() {
    setUser(OWNER_USER_ID);
    try {
        PivotSites pivot = new PivotSites(dimensions, filter);
        pivot.setValueType(valueType);
        pivot.setPointRequested(pointsRequested);
        buckets = execute(pivot).getBuckets();
    } catch (CommandException e) {
        throw new RuntimeException(e);
    }
    System.out.println("Buckets = [");
    for (Bucket bucket : buckets) {
        System.out.print("  { Value: " + bucket.doubleValue());
        for (Dimension dim : bucket.dimensions()) {
            DimensionCategory cat = bucket.getCategory(dim);
            System.out.print("\n    " + dim.toString() + ": ");
            System.out.print(cat.toString());
        }
        System.out.println("\n  }");
    }
    System.out.print("]\n");
}
Also used : DimensionCategory(org.activityinfo.shared.report.content.DimensionCategory) Bucket(org.activityinfo.shared.command.result.Bucket) CommandException(org.activityinfo.shared.exception.CommandException) 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 20 with Dimension

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

the class PivotSitesHandlerTest method testWeeks.

@Test
@OnDataSet("/dbunit/sites-weeks.db.xml")
public void testWeeks() {
    final Dimension weekDim = new DateDimension(DateUnit.WEEK_MON);
    dimensions.add(weekDim);
    filter.addRestriction(DimensionType.Indicator, 1);
    execute();
    assertEquals(3, buckets.size());
    assertEquals(3600, (int) findBucketByWeek(buckets, 2011, 52).doubleValue());
    assertEquals(1500, (int) findBucketByWeek(buckets, 2012, 1).doubleValue());
    assertEquals(4142, (int) findBucketByWeek(buckets, 2012, 13).doubleValue());
}
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) DateDimension(org.activityinfo.shared.report.model.DateDimension) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

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