use of org.hisp.dhis.interpretation.Interpretation in project dhis2-core by dhis2.
the class InterpretationController method writeReportTableInterpretation.
// -------------------------------------------------------------------------
// Intepretation create
// -------------------------------------------------------------------------
@RequestMapping(value = "/reportTable/{uid}", method = RequestMethod.POST, consumes = { "text/html", "text/plain" })
public void writeReportTableInterpretation(@PathVariable("uid") String reportTableUid, @RequestParam(value = "pe", required = false) String isoPeriod, @RequestParam(value = "ou", required = false) String orgUnitUid, @RequestBody String text, HttpServletResponse response, HttpServletRequest request) throws WebMessageException {
ReportTable reportTable = idObjectManager.get(ReportTable.class, reportTableUid);
if (reportTable == null) {
throw new WebMessageException(WebMessageUtils.conflict("Report table does not exist or is not accessible: " + reportTableUid));
}
Period period = PeriodType.getPeriodFromIsoString(isoPeriod);
OrganisationUnit orgUnit = getUserOrganisationUnit(orgUnitUid, reportTable, currentUserService.getCurrentUser());
createIntepretation(new Interpretation(reportTable, period, orgUnit, text), request, response);
}
use of org.hisp.dhis.interpretation.Interpretation in project dhis2-core by dhis2.
the class DefaultInterpretationService method addInterpretationComment.
@Override
public InterpretationComment addInterpretationComment(String uid, String text) {
Interpretation interpretation = getInterpretation(uid);
User user = currentUserService.getCurrentUser();
InterpretationComment comment = new InterpretationComment(text);
comment.setLastUpdated(new Date());
comment.setUid(CodeGenerator.generateUid());
if (user != null) {
comment.setUser(user);
}
interpretation.addComment(comment);
interpretationStore.update(interpretation);
return comment;
}
use of org.hisp.dhis.interpretation.Interpretation in project dhis2-core by dhis2.
the class CurrentUserController method getInboxInterpretations.
@RequestMapping(value = "/inbox/interpretations", produces = { "application/json", "text/*" })
public void getInboxInterpretations(HttpServletResponse response) throws Exception {
User user = currentUserService.getCurrentUser();
if (user == null) {
throw new NotAuthenticatedException();
}
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
List<Interpretation> interpretations = new ArrayList<>(interpretationService.getInterpretations(0, MAX_OBJECTS));
for (Interpretation interpretation : interpretations) {
interpretation.setAccess(aclService.getAccess(interpretation, user));
}
renderService.toJson(response.getOutputStream(), interpretations);
}
use of org.hisp.dhis.interpretation.Interpretation in project dhis2-core by dhis2.
the class CurrentUserController method getInbox.
@RequestMapping(value = "/inbox", produces = { "application/json", "text/*" })
public void getInbox(HttpServletResponse response) throws Exception {
User user = currentUserService.getCurrentUser();
if (user == null) {
throw new NotAuthenticatedException();
}
Inbox inbox = new Inbox();
inbox.setMessageConversations(new ArrayList<>(messageService.getMessageConversations(0, MAX_OBJECTS)));
inbox.setInterpretations(new ArrayList<>(interpretationService.getInterpretations(0, MAX_OBJECTS)));
for (org.hisp.dhis.message.MessageConversation messageConversation : inbox.getMessageConversations()) {
messageConversation.setAccess(aclService.getAccess(messageConversation, user));
}
for (Interpretation interpretation : inbox.getInterpretations()) {
interpretation.setAccess(aclService.getAccess(interpretation, user));
}
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
renderService.toJson(response.getOutputStream(), inbox);
}
use of org.hisp.dhis.interpretation.Interpretation in project dhis2-core by dhis2.
the class GetInterpretations method execute.
// -------------------------------------------------------------------------
// Action Implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
List<Interpretation> tempInterpretations = interpretationService.getInterpretations();
List<Interpretation> finalInterpretations = new ArrayList<>();
Iterator<Interpretation> i = tempInterpretations.iterator();
while (i.hasNext()) {
Interpretation currentInterpretation = i.next();
if (currentInterpretation.getType() == AnalyticsFavoriteType.CHART) {
finalInterpretations.add(currentInterpretation);
}
}
Collections.sort(finalInterpretations, this);
setInterpretations(finalInterpretations);
return SUCCESS;
}
Aggregations