Search in sources :

Example 21 with Dimension

use of org.activityinfo.legacy.shared.reports.model.Dimension 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.legacy.shared.reports.model.Dimension) DateDimension(org.activityinfo.legacy.shared.reports.model.DateDimension) PivotTableReportElement(org.activityinfo.legacy.shared.reports.model.PivotTableReportElement) DateDimension(org.activityinfo.legacy.shared.reports.model.DateDimension)

Example 22 with Dimension

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

the class ChartRendererJC method computePaints.

private Paint[] computePaints(List<PivotTableData.Axis> categories) {
    Paint[] paints = getDefaultPaints(categories.size());
    Dimension dim = categories.get(0).getDimension();
    if (dim == null) {
        return paints;
    }
    for (int i = 0; i != categories.size(); ++i) {
        CategoryProperties props = dim.getCategories().get(categories.get(i).getCategory());
        if (props != null && props.getColor() != null) {
            paints[i] = new Color(props.getColor());
        }
    }
    return paints;
}
Also used : CategoryProperties(org.activityinfo.legacy.shared.reports.model.CategoryProperties) Dimension(org.activityinfo.legacy.shared.reports.model.Dimension)

Example 23 with Dimension

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

the class PieMapMarkerTest method testPies.

@Test
public void testPies() {
    Dimension dimension = new Dimension(DimensionType.Indicator);
    dimension.setCategoryColor(101, 255);
    dimension.setCategoryColor(102, 0x00FF00);
    dimension.setCategoryColor(103, 0x0000FF);
    SiteDTO site1 = new SiteDTO();
    site1.setId(1);
    site1.setX(0d);
    site1.setY(0d);
    site1.setIndicatorValue(101, 50d);
    site1.setIndicatorValue(102, 40d);
    site1.setIndicatorValue(103, 10d);
    List<SiteDTO> sites = new ArrayList<SiteDTO>();
    sites.add(site1);
    PiechartMapLayer layer = new PiechartMapLayer();
    layer.addIndicatorId(101);
    layer.addIndicatorId(102);
    layer.addIndicatorId(103);
    // layer.getColorDimensions().add(dimension);
    MapReportElement mapElement = new MapReportElement();
    mapElement.addLayer(layer);
    MapContent content = new MapContent();
    TiledMap map = new TiledMap(640, 480, new AiLatLng(0, 0), 6);
    Map<Integer, Indicator> indicators = Maps.newHashMap();
    indicators.put(101, new Indicator());
    indicators.put(102, new Indicator());
    indicators.put(103, new Indicator());
    PiechartLayerGenerator generator = new PiechartLayerGenerator(layer, indicators);
    generator.setSites(sites);
    generator.generate(map, content);
    Assert.assertEquals(1, content.getMarkers().size());
    PieMapMarker marker = (PieMapMarker) content.getMarkers().get(0);
    Assert.assertEquals(3, marker.getSlices().size());
}
Also used : MapContent(org.activityinfo.legacy.shared.reports.content.MapContent) ArrayList(java.util.ArrayList) Dimension(org.activityinfo.legacy.shared.reports.model.Dimension) Indicator(org.activityinfo.server.database.hibernate.entity.Indicator) MapReportElement(org.activityinfo.legacy.shared.reports.model.MapReportElement) PieMapMarker(org.activityinfo.legacy.shared.reports.content.PieMapMarker) AiLatLng(org.activityinfo.model.type.geo.AiLatLng) SiteDTO(org.activityinfo.legacy.shared.model.SiteDTO) PiechartMapLayer(org.activityinfo.legacy.shared.reports.model.layers.PiechartMapLayer) Test(org.junit.Test)

Example 24 with Dimension

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

the class PivotTableGeneratorTest method testIndicatorSortOrder.

@Test
public void testIndicatorSortOrder() {
    // test input data: user
    User user = new User();
    user.setLocale("fr");
    // test input data: PivotTableElement
    PivotTableReportElement element = new PivotTableReportElement();
    Dimension indicatorDim = new Dimension(DimensionType.Indicator);
    element.addRowDimension(indicatorDim);
    // test input data: aggregated results
    List<Bucket> buckets = new ArrayList<Bucket>();
    buckets.add(newBucket(300, category(indicatorDim, 1, "Nb. menages", 3)));
    buckets.add(newBucket(400, category(indicatorDim, 2, "Nb. personnes", 1)));
    buckets.add(newBucket(600, category(indicatorDim, 3, "Nb. deplaces", 2)));
    // collaborator : PivotDAO
    DispatcherSync dispatcher = createMock(DispatcherSync.class);
    expect(dispatcher.execute(isA(PivotSites.class))).andReturn(new PivotSites.PivotResult(buckets));
    replay(dispatcher);
    // CLASS UNDER TEST!!
    PivotTableGenerator generator = new PivotTableGenerator(dispatcher);
    generator.generate(user, element, dummyFilter(), null);
    Assert.assertNotNull("element content", element.getContent());
    List<PivotTableData.Axis> rows = element.getContent().getData().getRootRow().getChildren();
    Assert.assertEquals(2, ((EntityCategory) rows.get(0).getCategory()).getId());
    Assert.assertEquals(3, ((EntityCategory) rows.get(1).getCategory()).getId());
    Assert.assertEquals(1, ((EntityCategory) rows.get(2).getCategory()).getId());
}
Also used : PivotSites(org.activityinfo.legacy.shared.command.PivotSites) User(org.activityinfo.server.database.hibernate.entity.User) Bucket(org.activityinfo.legacy.shared.command.result.Bucket) ArrayList(java.util.ArrayList) Dimension(org.activityinfo.legacy.shared.reports.model.Dimension) AdminDimension(org.activityinfo.legacy.shared.reports.model.AdminDimension) PivotTableReportElement(org.activityinfo.legacy.shared.reports.model.PivotTableReportElement) DispatcherSync(org.activityinfo.server.command.DispatcherSync) Test(org.junit.Test)

Example 25 with Dimension

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

the class ProjectTest method deleteProject.

@Test
public void deleteProject() {
    setUser(1);
    long originalDatabaseVersion = lookupDbVersion(1);
    int projectId = 2;
    execute(RequestChange.delete("Project", projectId));
    SchemaDTO schema = execute(new GetSchema());
    assertThat(schema.getProjectById(projectId), nullValue());
    // make sure it's gone from sites
    Filter filter = new Filter();
    filter.addRestriction(DimensionType.Activity, 1);
    filter.addRestriction(DimensionType.Site, 3);
    SiteResult sites = execute(new GetSites(filter));
    assertThat(sites.getData().get(0).getProject(), is(nullValue()));
    // and doesn't show up in pivoting...
    PivotSites pivot = new PivotSites();
    Dimension projectDimension = new Dimension(DimensionType.Project);
    pivot.setDimensions(projectDimension);
    pivot.setFilter(filter);
    PivotResult buckets = execute(pivot);
    assertThat(buckets.getBuckets().size(), equalTo(1));
    assertThat(buckets.getBuckets().get(0).getCategory(projectDimension), is(nullValue()));
    // make sure the version number of the database is updated
    assertThat(lookupDbVersion(1), not(equalTo(originalDatabaseVersion)));
}
Also used : SiteResult(org.activityinfo.legacy.shared.command.result.SiteResult) PivotResult(org.activityinfo.legacy.shared.command.PivotSites.PivotResult) Dimension(org.activityinfo.legacy.shared.reports.model.Dimension) SchemaDTO(org.activityinfo.legacy.shared.model.SchemaDTO) Test(org.junit.Test)

Aggregations

Dimension (org.activityinfo.legacy.shared.reports.model.Dimension)26 AttributeGroupDimension (org.activityinfo.legacy.shared.reports.model.AttributeGroupDimension)11 AdminDimension (org.activityinfo.legacy.shared.reports.model.AdminDimension)10 DateDimension (org.activityinfo.legacy.shared.reports.model.DateDimension)9 Bucket (org.activityinfo.legacy.shared.command.result.Bucket)7 Test (org.junit.Test)7 PivotSites (org.activityinfo.legacy.shared.command.PivotSites)6 PivotTableReportElement (org.activityinfo.legacy.shared.reports.model.PivotTableReportElement)5 ArrayList (java.util.ArrayList)3 Filter (org.activityinfo.legacy.shared.command.Filter)3 DimensionCategory (org.activityinfo.legacy.shared.reports.content.DimensionCategory)3 EntityCategory (org.activityinfo.legacy.shared.reports.content.EntityCategory)3 PivotTableData (org.activityinfo.legacy.shared.reports.content.PivotTableData)3 DispatcherSync (org.activityinfo.server.command.DispatcherSync)3 User (org.activityinfo.server.database.hibernate.entity.User)3 SqlResultCallback (com.bedatadriven.rebar.sql.client.SqlResultCallback)2 SqlResultSet (com.bedatadriven.rebar.sql.client.SqlResultSet)2 SqlResultSetRow (com.bedatadriven.rebar.sql.client.SqlResultSetRow)2 SqlTransaction (com.bedatadriven.rebar.sql.client.SqlTransaction)2 SiteResult (org.activityinfo.legacy.shared.command.result.SiteResult)2