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