use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.UID in project dhis2-core by dhis2.
the class DimensionController method getDimensionsForDataSet.
@RequestMapping(value = "/dataSet/{uid}", method = RequestMethod.GET)
@ResponseBody
public RootNode getDimensionsForDataSet(@PathVariable String uid, @RequestParam(value = "links", defaultValue = "true", required = false) Boolean links, Model model, HttpServletResponse response) throws WebMessageException {
WebMetadata metadata = new WebMetadata();
List<String> fields = Lists.newArrayList(contextService.getParameterValues("fields"));
DataSet dataSet = identifiableObjectManager.get(DataSet.class, uid);
if (dataSet == null) {
throw new WebMessageException(WebMessageUtils.notFound("DataSet not found for uid: " + uid));
}
if (!dataSet.hasCategoryCombo()) {
throw new WebMessageException(WebMessageUtils.conflict("Data set does not have a category combination: " + uid));
}
List<DimensionalObject> dimensions = new ArrayList<>();
dimensions.addAll(dataSet.getCategoryCombo().getCategories());
dimensions.addAll(dataSet.getCategoryOptionGroupSets());
dimensions = dimensionService.getCanReadObjects(dimensions);
for (DimensionalObject dim : dimensions) {
metadata.getDimensions().add(dimensionService.getDimensionalObjectCopy(dim.getUid(), true));
}
if (links) {
linkService.generateLinks(metadata, false);
}
RootNode rootNode = NodeUtils.createMetadata();
rootNode.addChild(fieldFilterService.filter(getEntityClass(), metadata.getDimensions(), fields));
return rootNode;
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.UID in project dhis2-core by dhis2.
the class InterpretationController method postComment.
// -------------------------------------------------------------------------
// Comment
// -------------------------------------------------------------------------
@RequestMapping(value = "/{uid}/comments", method = RequestMethod.POST, consumes = { "text/html", "text/plain" })
public void postComment(@PathVariable("uid") String uid, @RequestBody String text, HttpServletResponse response, HttpServletRequest request) throws WebMessageException {
Interpretation interpretation = interpretationService.getInterpretation(uid);
if (interpretation == null) {
throw new WebMessageException(WebMessageUtils.conflict("Interpretation does not exist: " + uid));
}
InterpretationComment comment = interpretationService.addInterpretationComment(uid, text);
String builder = InterpretationSchemaDescriptor.API_ENDPOINT + "/" + uid + "/comments/" + comment.getUid();
response.addHeader("Location", builder);
webMessageService.send(WebMessageUtils.created("Commented created"), response, request);
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.UID in project dhis2-core by dhis2.
the class InterpretationController method deleteObject.
@Override
public void deleteObject(@PathVariable String uid, HttpServletRequest request, HttpServletResponse response) throws Exception {
Interpretation interpretation = interpretationService.getInterpretation(uid);
if (interpretation == null) {
throw new WebMessageException(WebMessageUtils.notFound("Interpretation does not exist: " + uid));
}
if (!currentUserService.getCurrentUser().equals(interpretation.getUser()) && !currentUserService.currentUserIsSuper()) {
throw new AccessDeniedException("You are not allowed to delete this interpretation.");
}
interpretationService.deleteInterpretation(interpretation);
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.UID in project dhis2-core by dhis2.
the class InterpretationController method unlike.
@RequestMapping(value = "/{uid}/like", method = RequestMethod.DELETE)
public void unlike(@PathVariable("uid") String uid, HttpServletResponse response, HttpServletRequest request) throws WebMessageException {
Interpretation interpretation = interpretationService.getInterpretation(uid);
if (interpretation == null) {
throw new WebMessageException(WebMessageUtils.conflict("Interpretation does not exist: " + uid));
}
boolean like = interpretationService.unlikeInterpretation(interpretation.getId());
if (like) {
webMessageService.send(WebMessageUtils.created("Like removed from interpretation"), response, request);
} else {
webMessageService.send(WebMessageUtils.conflict("Could not remove like, user had not previously liked interpretation"), response, request);
}
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.UID in project dhis2-core by dhis2.
the class InterpretationController method writeDataSetReportInterpretation.
@RequestMapping(value = "/dataSetReport/{uid}", method = RequestMethod.POST, consumes = { "text/html", "text/plain" })
public void writeDataSetReportInterpretation(@PathVariable("uid") String dataSetUid, @RequestParam("pe") String isoPeriod, @RequestParam("ou") String orgUnitUid, @RequestBody String text, HttpServletResponse response, HttpServletRequest request) throws WebMessageException {
DataSet dataSet = idObjectManager.get(DataSet.class, dataSetUid);
if (dataSet == null) {
throw new WebMessageException(WebMessageUtils.conflict("Data set does not exist or is not accessible: " + dataSetUid));
}
Period period = PeriodType.getPeriodFromIsoString(isoPeriod);
if (period == null) {
throw new WebMessageException(WebMessageUtils.conflict("Period identifier not valid: " + isoPeriod));
}
OrganisationUnit orgUnit = idObjectManager.get(OrganisationUnit.class, orgUnitUid);
if (orgUnit == null) {
throw new WebMessageException(WebMessageUtils.conflict("Organisation unit does not exist or is not accessible: " + orgUnitUid));
}
createIntepretation(new Interpretation(dataSet, period, orgUnit, text), request, response);
}
Aggregations