Search in sources :

Example 11 with Map

use of org.hisp.dhis.mapping.Map in project dhis2-core by dhis2.

the class InterpretationController method writeMapInterpretation.

@RequestMapping(value = "/map/{uid}", method = RequestMethod.POST, consumes = { "text/html", "text/plain" })
public void writeMapInterpretation(@PathVariable("uid") String uid, @RequestBody String text, HttpServletResponse response, HttpServletRequest request) throws WebMessageException {
    Map map = idObjectManager.get(Map.class, uid);
    if (map == null) {
        throw new WebMessageException(WebMessageUtils.conflict("Map does not exist or is not accessible: " + uid));
    }
    createIntepretation(new Interpretation(map, text), request, response);
}
Also used : WebMessageException(org.hisp.dhis.dxf2.webmessage.WebMessageException) Interpretation(org.hisp.dhis.interpretation.Interpretation) Map(org.hisp.dhis.mapping.Map) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with Map

use of org.hisp.dhis.mapping.Map in project dhis2-core by dhis2.

the class MapController method deserializeJsonEntity.

@Override
protected Map deserializeJsonEntity(HttpServletRequest request, HttpServletResponse response) throws IOException {
    Map map = super.deserializeJsonEntity(request, response);
    mergeMap(map);
    return map;
}
Also used : Map(org.hisp.dhis.mapping.Map)

Example 13 with Map

use of org.hisp.dhis.mapping.Map in project dhis2-core by dhis2.

the class GeoToolsMapGenerationService method generateMapImage.

// -------------------------------------------------------------------------
// MapGenerationService implementation
// -------------------------------------------------------------------------
@Override
public BufferedImage generateMapImage(MapView mapView) {
    Map map = new Map();
    map.getMapViews().add(mapView);
    return generateMapImage(map);
}
Also used : HashMap(java.util.HashMap) Map(org.hisp.dhis.mapping.Map)

Example 14 with Map

use of org.hisp.dhis.mapping.Map in project dhis2-core by dhis2.

the class DashboardCascadeSharingTest method testDryRunTrue.

@Test
void testDryRunTrue() {
    Map map = createMap("A");
    map.setSharing(Sharing.builder().publicAccess(DEFAULT).build());
    objectManager.save(map, false);
    Dashboard dashboard = createDashboardWithItem("A", sharingReadForUserA);
    dashboard.getItems().get(0).setMap(map);
    objectManager.save(dashboard, false);
    CascadeSharingReport report = cascadeSharingService.cascadeSharing(dashboard, CascadeSharingParameters.builder().dryRun(true).build());
    assertEquals(0, report.getErrorReports().size());
    assertEquals(1, report.getUpdateObjects().size());
    assertFalse(aclService.canRead(userA, dashboard.getItems().get(0).getMap()));
    assertFalse(aclService.canRead(userB, dashboard.getItems().get(0).getMap()));
}
Also used : Dashboard(org.hisp.dhis.dashboard.Dashboard) Map(org.hisp.dhis.mapping.Map) Test(org.junit.jupiter.api.Test)

Example 15 with Map

use of org.hisp.dhis.mapping.Map in project dhis2-core by dhis2.

the class DashboardCascadeSharingTest method testUserGroup.

@Test
void testUserGroup() {
    Map mapA = createMap("A");
    mapA.setSharing(defaultSharing());
    objectManager.save(mapA, false);
    Map mapB = createMap("A");
    mapB.setSharing(defaultSharing());
    objectManager.save(mapB, false);
    DashboardItem itemA = createDashboardItem("A");
    itemA.setMap(mapA);
    DashboardItem itemB = createDashboardItem("B");
    itemB.setMap(mapB);
    Dashboard dashboard = createDashboard("A", sharingUserGroupA);
    dashboard.getItems().add(itemB);
    dashboard.getItems().add(itemA);
    objectManager.save(dashboard, false);
    CascadeSharingReport report = cascadeSharingService.cascadeSharing(dashboard, CascadeSharingParameters.builder().build());
    assertEquals(0, report.getErrorReports().size());
    assertEquals(1, report.getUpdateObjects().size());
    assertTrue(aclService.canRead(userA, mapA));
    assertTrue(aclService.canRead(userA, mapB));
}
Also used : Dashboard(org.hisp.dhis.dashboard.Dashboard) DashboardItem(org.hisp.dhis.dashboard.DashboardItem) Map(org.hisp.dhis.mapping.Map) Test(org.junit.jupiter.api.Test)

Aggregations

Map (org.hisp.dhis.mapping.Map)19 Test (org.junit.jupiter.api.Test)10 Dashboard (org.hisp.dhis.dashboard.Dashboard)8 DashboardItem (org.hisp.dhis.dashboard.DashboardItem)3 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)3 MetadataImportParams (org.hisp.dhis.dxf2.metadata.MetadataImportParams)2 MergeParams (org.hisp.dhis.schema.MergeParams)2 HashMap (java.util.HashMap)1 DhisSpringTest (org.hisp.dhis.DhisSpringTest)1 TransactionalIntegrationTest (org.hisp.dhis.TransactionalIntegrationTest)1 DataElement (org.hisp.dhis.dataelement.DataElement)1 Interpretation (org.hisp.dhis.interpretation.Interpretation)1 MapView (org.hisp.dhis.mapping.MapView)1 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)1 User (org.hisp.dhis.user.User)1 Sharing (org.hisp.dhis.user.sharing.Sharing)1 UserAccess (org.hisp.dhis.user.sharing.UserAccess)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1