use of org.hisp.dhis.schema.MergeParams in project dhis2-core by dhis2.
the class LegendSetController method putJsonObject.
@Override
@RequestMapping(value = "/{uid}", method = RequestMethod.PUT, consumes = "application/json")
@PreAuthorize("hasRole('F_GIS_ADMIN') or hasRole('F_LEGEND_SET_PUBLIC_ADD') or hasRole('F_LEGEND_SET_PRIVATE_ADD') or hasRole('ALL')")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void putJsonObject(@PathVariable String uid, HttpServletRequest request, HttpServletResponse response) throws Exception {
LegendSet legendSet = legendSetService.getLegendSet(uid);
if (legendSet == null) {
throw new WebMessageException(WebMessageUtils.notFound("Legend set does not exist: " + uid));
}
MetadataImportParams params = importService.getParamsFromMap(contextService.getParameterValuesMap());
LegendSet newLegendSet = renderService.fromJson(request.getInputStream(), LegendSet.class);
newLegendSet.setUser(currentUserService.getCurrentUser());
newLegendSet.setUid(legendSet.getUid());
mergeService.merge(new MergeParams<>(newLegendSet, legendSet).setMergeMode(params.getMergeMode()));
legendSetService.updateLegendSet(legendSet);
}
use of org.hisp.dhis.schema.MergeParams in project dhis2-core by dhis2.
the class DefaultDimensionService method getDimensionalObjectCopy.
@Override
public DimensionalObject getDimensionalObjectCopy(String uid, boolean filterCanRead) {
DimensionalObject dimension = idObjectManager.get(DimensionalObject.DYNAMIC_DIMENSION_CLASSES, uid);
BaseDimensionalObject copy = new BaseDimensionalObject();
mergeService.merge(new MergeParams<>(dimension, copy).setMergeMode(MergeMode.MERGE));
if (filterCanRead) {
User user = currentUserService.getCurrentUser();
List<DimensionalItemObject> items = getCanReadObjects(user, dimension.getItems());
copy.setItems(items);
}
return copy;
}
Aggregations