Search in sources :

Example 6 with Interpretation

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);
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) WebMessageException(org.hisp.dhis.dxf2.webmessage.WebMessageException) ReportTable(org.hisp.dhis.reporttable.ReportTable) Period(org.hisp.dhis.period.Period) Interpretation(org.hisp.dhis.interpretation.Interpretation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with Interpretation

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;
}
Also used : User(org.hisp.dhis.user.User) InterpretationComment(org.hisp.dhis.interpretation.InterpretationComment) Interpretation(org.hisp.dhis.interpretation.Interpretation) Date(java.util.Date)

Example 8 with Interpretation

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);
}
Also used : User(org.hisp.dhis.user.User) NotAuthenticatedException(org.hisp.dhis.webapi.controller.exception.NotAuthenticatedException) ArrayList(java.util.ArrayList) Interpretation(org.hisp.dhis.interpretation.Interpretation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with Interpretation

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);
}
Also used : User(org.hisp.dhis.user.User) NotAuthenticatedException(org.hisp.dhis.webapi.controller.exception.NotAuthenticatedException) MessageConversation(org.hisp.dhis.message.MessageConversation) Interpretation(org.hisp.dhis.interpretation.Interpretation) Inbox(org.hisp.dhis.webapi.webdomain.user.Inbox) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 10 with Interpretation

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;
}
Also used : ArrayList(java.util.ArrayList) Interpretation(org.hisp.dhis.interpretation.Interpretation)

Aggregations

Interpretation (org.hisp.dhis.interpretation.Interpretation)21 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)14 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)13 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)5 User (org.hisp.dhis.user.User)5 InterpretationComment (org.hisp.dhis.interpretation.InterpretationComment)4 AccessDeniedException (org.springframework.security.access.AccessDeniedException)4 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)3 ArrayList (java.util.ArrayList)2 Chart (org.hisp.dhis.chart.Chart)2 EventChart (org.hisp.dhis.eventchart.EventChart)2 Period (org.hisp.dhis.period.Period)2 NotAuthenticatedException (org.hisp.dhis.webapi.controller.exception.NotAuthenticatedException)2 Transactional (org.springframework.transaction.annotation.Transactional)2 Date (java.util.Date)1 Query (org.hibernate.Query)1 DataSet (org.hisp.dhis.dataset.DataSet)1 EventReport (org.hisp.dhis.eventreport.EventReport)1 Map (org.hisp.dhis.mapping.Map)1 MessageConversation (org.hisp.dhis.message.MessageConversation)1