use of org.hisp.dhis.interpretation.Interpretation in project dhis2-core by dhis2.
the class InterpretationController method updateComment.
@PutMapping("/{uid}/comments/{cuid}")
@ResponseStatus(HttpStatus.NO_CONTENT)
@ResponseBody
public WebMessage updateComment(@PathVariable("uid") String uid, @PathVariable("cuid") String cuid, @RequestBody String content) {
Interpretation interpretation = interpretationService.getInterpretation(uid);
if (interpretation == null) {
return conflict("Interpretation does not exist: " + uid);
}
for (InterpretationComment comment : interpretation.getComments()) {
if (comment.getUid().equals(cuid)) {
if (!currentUserService.getCurrentUser().equals(comment.getCreatedBy()) && !currentUserService.currentUserIsSuper()) {
throw new AccessDeniedException("You are not allowed to update this comment.");
}
comment.setText(content);
interpretationService.updateComment(interpretation, comment);
}
}
return null;
}
use of org.hisp.dhis.interpretation.Interpretation in project dhis2-core by dhis2.
the class InterpretationController method deleteObject.
@Override
@ResponseStatus(HttpStatus.NO_CONTENT)
public WebMessage deleteObject(@PathVariable String uid, @CurrentUser User currentUser, HttpServletRequest request, HttpServletResponse response) {
Interpretation interpretation = interpretationService.getInterpretation(uid);
if (interpretation == null) {
return notFound("Interpretation does not exist: " + uid);
}
if (!currentUserService.getCurrentUser().equals(interpretation.getCreatedBy()) && !currentUserService.currentUserIsSuper()) {
throw new AccessDeniedException("You are not allowed to delete this interpretation.");
}
interpretationService.deleteInterpretation(interpretation);
return null;
}
use of org.hisp.dhis.interpretation.Interpretation in project dhis2-core by dhis2.
the class InterpretationController method writeEventReportInterpretation.
@PostMapping(value = "/eventReport/{uid}", consumes = { "text/html", "text/plain" })
@ResponseBody
@Deprecated
public WebMessage writeEventReportInterpretation(@PathVariable("uid") String uid, @RequestParam(value = "ou", required = false) String orgUnitUid, @CurrentUser User currentUser, @RequestBody String text) throws WebMessageException {
EventReport eventReport = idObjectManager.get(EventReport.class, uid);
if (eventReport == null) {
return conflict("Event report does not exist or is not accessible: " + uid);
}
final EventVisualization eventVisualization = idObjectManager.get(EventVisualization.class, eventReport.getUid());
OrganisationUnit orgUnit = getUserOrganisationUnit(orgUnitUid, eventReport, currentUser);
return createInterpretation(new Interpretation(eventVisualization, eventReport, orgUnit, text));
}
Aggregations