Search in sources :

Example 1 with MapView

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);
}
Also used : MapView(org.hisp.dhis.mapping.MapView)

Example 2 with MapView

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);
}
Also used : WebMessageException(org.hisp.dhis.dxf2.webmessage.WebMessageException) MapView(org.hisp.dhis.mapping.MapView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with MapView

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);
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) MapView(org.hisp.dhis.mapping.MapView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with MapView

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));
            }
        }
    }
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) MapView(org.hisp.dhis.mapping.MapView) Period(org.hisp.dhis.period.Period) I18nFormat(org.hisp.dhis.i18n.I18nFormat)

Example 5 with MapView

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());
}
Also used : DataElement(org.hisp.dhis.dataelement.DataElement) MapView(org.hisp.dhis.mapping.MapView) Test(org.junit.Test)

Aggregations

MapView (org.hisp.dhis.mapping.MapView)7 DataElement (org.hisp.dhis.dataelement.DataElement)2 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)2 Test (org.junit.Test)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 BufferedImage (java.awt.image.BufferedImage)1 BaseAnalyticalObject (org.hisp.dhis.common.BaseAnalyticalObject)1 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)1 I18nFormat (org.hisp.dhis.i18n.I18nFormat)1 Period (org.hisp.dhis.period.Period)1