use of org.hisp.dhis.mapping.MapView in project dhis2-core by dhis2.
the class AnalyticalObjectStoreTest method setUpTest.
@Override
public void setUpTest() {
itA = createIndicatorType('A');
idObjectManager.save(itA);
inA = createIndicator('A', itA);
inB = createIndicator('B', itA);
idObjectManager.save(inA);
idObjectManager.save(inB);
ouA = createOrganisationUnit('A');
ouB = createOrganisationUnit('B');
idObjectManager.save(ouA);
idObjectManager.save(ouB);
mvA = new MapView(MapView.LAYER_THEMATIC1);
mvB = new MapView(MapView.LAYER_THEMATIC1);
mvC = new MapView(MapView.LAYER_THEMATIC1);
mvA.addDataDimensionItem(inA);
mvA.getOrganisationUnits().add(ouA);
mvB.addDataDimensionItem(inB);
mvB.getOrganisationUnits().add(ouA);
mvC.addDataDimensionItem(inA);
mvC.getOrganisationUnits().add(ouB);
mapViewStore.save(mvA);
mapViewStore.save(mvB);
mapViewStore.save(mvC);
}
use of org.hisp.dhis.mapping.MapView in project dhis2-core by dhis2.
the class MapViewController method getMapViewData.
//--------------------------------------------------------------------------
// Get data
//--------------------------------------------------------------------------
@RequestMapping(value = { "/{uid}/data", "/{uid}/data.png" }, method = RequestMethod.GET)
public void getMapViewData(@PathVariable String uid, HttpServletResponse response) throws Exception {
MapView mapView = mappingService.getMapView(uid);
if (mapView == null) {
throw new WebMessageException(WebMessageUtils.notFound("Map view does not exist: " + uid));
}
renderMapViewPng(mapView, response);
}
use of org.hisp.dhis.mapping.MapView in project dhis2-core by dhis2.
the class MapViewController method getMapView.
@RequestMapping(value = { "/data", "/data.png" }, method = RequestMethod.GET)
public void getMapView(Model model, @RequestParam(value = "in") String indicatorUid, @RequestParam(value = "ou") String organisationUnitUid, @RequestParam(value = "level", required = false) Integer level, HttpServletResponse response) throws Exception {
if (level == null) {
OrganisationUnit unit = organisationUnitService.getOrganisationUnit(organisationUnitUid);
level = unit.getLevel();
level++;
}
MapView mapView = mappingService.getIndicatorLastYearMapView(indicatorUid, organisationUnitUid, level);
renderMapViewPng(mapView, response);
}
use of org.hisp.dhis.mapping.MapView in project dhis2-core by dhis2.
the class MapController method postProcessEntity.
//--------------------------------------------------------------------------
// Hooks
//--------------------------------------------------------------------------
@Override
public void postProcessEntity(Map map) throws Exception {
I18nFormat format = i18nManager.getI18nFormat();
Set<OrganisationUnit> roots = currentUserService.getCurrentUser().getDataViewOrganisationUnitsWithFallback();
for (MapView view : map.getMapViews()) {
view.populateAnalyticalProperties();
for (OrganisationUnit organisationUnit : view.getOrganisationUnits()) {
view.getParentGraphMap().put(organisationUnit.getUid(), organisationUnit.getParentGraph(roots));
}
if (view.getPeriods() != null && !view.getPeriods().isEmpty()) {
for (Period period : view.getPeriods()) {
period.setName(format.formatPeriod(period));
}
}
}
}
use of org.hisp.dhis.mapping.MapView in project dhis2-core by dhis2.
the class BaseAnalyticalObjectTest method testRemoveDataDimensionItem.
@Test
public void testRemoveDataDimensionItem() {
DataElement deA = new DataElement();
DataElement deB = new DataElement();
deA.setAutoFields();
deB.setAutoFields();
MapView mv = new MapView(MapView.LAYER_THEMATIC1);
mv.addDataDimensionItem(deA);
mv.addDataDimensionItem(deB);
assertEquals(2, mv.getDataDimensionItems().size());
mv.removeDataDimensionItem(deA);
assertEquals(1, mv.getDataDimensionItems().size());
assertEquals(deB, mv.getDataDimensionItems().get(0).getDataElement());
}
Aggregations