use of org.hisp.dhis.mapping.Map in project dhis2-core by dhis2.
the class MapController method putJsonObject.
@Override
@RequestMapping(value = "/{uid}", method = RequestMethod.PUT, consumes = "application/json")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void putJsonObject(@PathVariable String uid, HttpServletRequest request, HttpServletResponse response) throws Exception {
Map map = mappingService.getMap(uid);
if (map == null) {
throw new WebMessageException(WebMessageUtils.notFound("Map does not exist: " + uid));
}
MetadataImportParams params = importService.getParamsFromMap(contextService.getParameterValuesMap());
Map newMap = deserializeJsonEntity(request, response);
newMap.setUid(uid);
mergeService.merge(new MergeParams<>(newMap, map).setMergeMode(params.getMergeMode()));
mappingService.updateMap(map);
}
use of org.hisp.dhis.mapping.Map in project dhis2-core by dhis2.
the class MapController method postJsonObject.
//--------------------------------------------------------------------------
// CRUD
//--------------------------------------------------------------------------
@Override
@RequestMapping(method = RequestMethod.POST, consumes = "application/json")
@ResponseStatus(HttpStatus.CREATED)
public void postJsonObject(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map map = deserializeJsonEntity(request, response);
map.getTranslations().clear();
mappingService.addMap(map);
response.addHeader("Location", MapSchemaDescriptor.API_ENDPOINT + "/" + map.getUid());
webMessageService.send(WebMessageUtils.created("Map created"), response, request);
}
use of org.hisp.dhis.mapping.Map in project dhis2-core by dhis2.
the class AclServiceTest method testCanUpdatePrivateMap.
@Test
void testCanUpdatePrivateMap() {
User user = createAdminUser("F_DATAELEMENT_PRIVATE_ADD");
Map map = new Map();
map.setAutoFields();
map.setCreatedBy(user);
map.getSharing().setOwner(user);
map.setPublicAccess(AccessStringHelper.DEFAULT);
assertTrue(aclService.canUpdate(user, 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) throws IOException {
Map map = super.deserializeJsonEntity(request);
mergeMap(map);
return map;
}
use of org.hisp.dhis.mapping.Map in project dhis2-core by dhis2.
the class MapController method getMapData.
// --------------------------------------------------------------------------
// Get data
// --------------------------------------------------------------------------
@GetMapping(value = { "/{uid}/data", "/{uid}/data.png" })
public void getMapData(@PathVariable String uid, @RequestParam(value = "date", required = false) Date date, @RequestParam(value = "ou", required = false) String ou, @RequestParam(required = false) Integer width, @RequestParam(required = false) Integer height, @RequestParam(value = "attachment", required = false) boolean attachment, HttpServletResponse response) throws Exception {
Map map = mappingService.getMapNoAcl(uid);
if (map == null) {
throw new WebMessageException(notFound("Map does not exist: " + uid));
}
if (width != null && width < MAP_MIN_WIDTH) {
throw new WebMessageException(conflict("Min map width is " + MAP_MIN_WIDTH + ": " + width));
}
if (height != null && height < MAP_MIN_HEIGHT) {
throw new WebMessageException(conflict("Min map height is " + MAP_MIN_HEIGHT + ": " + height));
}
OrganisationUnit unit = ou != null ? organisationUnitService.getOrganisationUnit(ou) : null;
renderMapViewPng(map, date, unit, width, height, attachment, response);
}
Aggregations