Search in sources :

Example 6 with Indicator

use of org.activityinfo.server.database.hibernate.entity.Indicator 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 7 with Indicator

use of org.activityinfo.server.database.hibernate.entity.Indicator in project activityinfo by bedatadriven.

the class EmptyChartsTest method generate.

@Test
public void generate() {
    PivotChartReportElement element = new PivotChartReportElement(Type.StackedBar);
    element.setIndicator(1);
    element.addCategoryDimension(new Dimension(DimensionType.Partner));
    element.addSeriesDimension(new Dimension(DimensionType.Database));
    DispatcherSync dispatcher = createMock(DispatcherSync.class);
    expect(dispatcher.execute(isA(PivotSites.class))).andReturn(new PivotSites.PivotResult(Collections.EMPTY_LIST));
    expect(dispatcher.execute(isA(GetDimensionLabels.class))).andReturn(new GetDimensionLabels.DimensionLabels(Collections.EMPTY_MAP));
    replay(dispatcher);
    IndicatorDAO indicatorDAO = createMock(IndicatorDAO.class);
    expect(indicatorDAO.findById(eq(1))).andReturn(new Indicator());
    replay(indicatorDAO);
    PivotChartGenerator generator = new PivotChartGenerator(dispatcher, indicatorDAO);
    generator.generate(new User(), element, new Filter(), new DateRange());
}
Also used : IndicatorDAO(org.activityinfo.server.database.hibernate.dao.IndicatorDAO) GetDimensionLabels(org.activityinfo.legacy.shared.command.GetDimensionLabels) User(org.activityinfo.server.database.hibernate.entity.User) Dimension(org.activityinfo.legacy.shared.reports.model.Dimension) Indicator(org.activityinfo.server.database.hibernate.entity.Indicator) PivotSites(org.activityinfo.legacy.shared.command.PivotSites) DateRange(org.activityinfo.legacy.shared.reports.model.DateRange) Filter(org.activityinfo.legacy.shared.command.Filter) PivotChartGenerator(org.activityinfo.server.report.generator.PivotChartGenerator) PivotChartReportElement(org.activityinfo.legacy.shared.reports.model.PivotChartReportElement) DispatcherSync(org.activityinfo.server.command.DispatcherSync) Test(org.junit.Test)

Aggregations

Indicator (org.activityinfo.server.database.hibernate.entity.Indicator)7 Filter (org.activityinfo.legacy.shared.command.Filter)3 MapContent (org.activityinfo.legacy.shared.reports.content.MapContent)3 AiLatLng (org.activityinfo.model.type.geo.AiLatLng)3 Test (org.junit.Test)3 SiteDTO (org.activityinfo.legacy.shared.model.SiteDTO)2 PieMapMarker (org.activityinfo.legacy.shared.reports.content.PieMapMarker)2 Dimension (org.activityinfo.legacy.shared.reports.model.Dimension)2 PiechartMapLayer (org.activityinfo.legacy.shared.reports.model.layers.PiechartMapLayer)2 ArrayList (java.util.ArrayList)1 DimensionType (org.activityinfo.legacy.shared.command.DimensionType)1 GetDimensionLabels (org.activityinfo.legacy.shared.command.GetDimensionLabels)1 GetSites (org.activityinfo.legacy.shared.command.GetSites)1 PivotSites (org.activityinfo.legacy.shared.command.PivotSites)1 BaseMap (org.activityinfo.legacy.shared.model.BaseMap)1 IndicatorDTO (org.activityinfo.legacy.shared.model.IndicatorDTO)1 TileBaseMap (org.activityinfo.legacy.shared.model.TileBaseMap)1 GoogleBaseMap (org.activityinfo.legacy.shared.reports.content.GoogleBaseMap)1 DateRange (org.activityinfo.legacy.shared.reports.model.DateRange)1 MapReportElement (org.activityinfo.legacy.shared.reports.model.MapReportElement)1