Search in sources :

Example 26 with Interpretation

use of org.hisp.dhis.interpretation.Interpretation in project dhis2-core by dhis2.

the class InterpretationController method writeEventReportInterpretation.

@RequestMapping(value = "/eventReport/{uid}", method = RequestMethod.POST, consumes = { "text/html", "text/plain" })
public void writeEventReportInterpretation(@PathVariable("uid") String uid, @RequestParam(value = "ou", required = false) String orgUnitUid, @RequestBody String text, HttpServletResponse response, HttpServletRequest request) throws WebMessageException {
    EventReport eventReport = idObjectManager.get(EventReport.class, uid);
    if (eventReport == null) {
        throw new WebMessageException(WebMessageUtils.conflict("Event report does not exist or is not accessible: " + uid));
    }
    OrganisationUnit orgUnit = getUserOrganisationUnit(orgUnitUid, eventReport, currentUserService.getCurrentUser());
    createIntepretation(new Interpretation(eventReport, orgUnit, text), request, response);
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) WebMessageException(org.hisp.dhis.dxf2.webmessage.WebMessageException) Interpretation(org.hisp.dhis.interpretation.Interpretation) EventReport(org.hisp.dhis.eventreport.EventReport) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 27 with Interpretation

use of org.hisp.dhis.interpretation.Interpretation in project dhis2-core by dhis2.

the class InterpretationController method writeEventChartInterpretation.

@RequestMapping(value = "/eventChart/{uid}", method = RequestMethod.POST, consumes = { "text/html", "text/plain" })
public void writeEventChartInterpretation(@PathVariable("uid") String uid, @RequestParam(value = "ou", required = false) String orgUnitUid, @RequestBody String text, HttpServletResponse response, HttpServletRequest request) throws WebMessageException {
    EventChart eventChart = idObjectManager.get(EventChart.class, uid);
    if (eventChart == null) {
        throw new WebMessageException(WebMessageUtils.conflict("Event chart does not exist or is not accessible: " + uid));
    }
    OrganisationUnit orgUnit = getUserOrganisationUnit(orgUnitUid, eventChart, currentUserService.getCurrentUser());
    createIntepretation(new Interpretation(eventChart, orgUnit, text), request, response);
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) WebMessageException(org.hisp.dhis.dxf2.webmessage.WebMessageException) EventChart(org.hisp.dhis.eventchart.EventChart) Interpretation(org.hisp.dhis.interpretation.Interpretation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 28 with Interpretation

use of org.hisp.dhis.interpretation.Interpretation in project dhis2-core by dhis2.

the class InterpretationController method writeMapInterpretation.

@RequestMapping(value = "/map/{uid}", method = RequestMethod.POST, consumes = { "text/html", "text/plain" })
public void writeMapInterpretation(@PathVariable("uid") String uid, @RequestBody String text, HttpServletResponse response, HttpServletRequest request) throws WebMessageException {
    Map map = idObjectManager.get(Map.class, uid);
    if (map == null) {
        throw new WebMessageException(WebMessageUtils.conflict("Map does not exist or is not accessible: " + uid));
    }
    createIntepretation(new Interpretation(map, text), request, response);
}
Also used : WebMessageException(org.hisp.dhis.dxf2.webmessage.WebMessageException) Interpretation(org.hisp.dhis.interpretation.Interpretation) Map(org.hisp.dhis.mapping.Map) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 29 with Interpretation

use of org.hisp.dhis.interpretation.Interpretation in project dhis2-core by dhis2.

the class InterpretationController method writeDataSetReportInterpretation.

@PostMapping(value = "/dataSetReport/{uid}", consumes = { "text/html", "text/plain" })
@ResponseBody
public WebMessage writeDataSetReportInterpretation(@PathVariable("uid") String dataSetUid, @RequestParam("pe") String isoPeriod, @RequestParam("ou") String orgUnitUid, @RequestBody String text) {
    DataSet dataSet = idObjectManager.get(DataSet.class, dataSetUid);
    if (dataSet == null) {
        return conflict("Data set does not exist or is not accessible: " + dataSetUid);
    }
    Period period = PeriodType.getPeriodFromIsoString(isoPeriod);
    if (period == null) {
        return conflict("Period identifier not valid: " + isoPeriod);
    }
    OrganisationUnit orgUnit = idObjectManager.get(OrganisationUnit.class, orgUnitUid);
    if (orgUnit == null) {
        return conflict("Organisation unit does not exist or is not accessible: " + orgUnitUid);
    }
    return createInterpretation(new Interpretation(dataSet, period, orgUnit, text));
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) DataSet(org.hisp.dhis.dataset.DataSet) Period(org.hisp.dhis.period.Period) Interpretation(org.hisp.dhis.interpretation.Interpretation) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 30 with Interpretation

use of org.hisp.dhis.interpretation.Interpretation in project dhis2-core by dhis2.

the class InterpretationController method postComment.

// -------------------------------------------------------------------------
// Comment
// -------------------------------------------------------------------------
@PostMapping(value = "/{uid}/comments", consumes = { "text/html", "text/plain" })
@ResponseBody
public WebMessage postComment(@PathVariable("uid") String uid, @RequestBody String text, HttpServletResponse response) {
    Interpretation interpretation = interpretationService.getInterpretation(uid);
    if (interpretation == null) {
        return conflict("Interpretation does not exist: " + uid);
    }
    InterpretationComment comment = interpretationService.addInterpretationComment(uid, text);
    return created("Commented created").setLocation(InterpretationSchemaDescriptor.API_ENDPOINT + "/" + uid + "/comments/" + comment.getUid());
}
Also used : InterpretationComment(org.hisp.dhis.interpretation.InterpretationComment) Interpretation(org.hisp.dhis.interpretation.Interpretation) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

Interpretation (org.hisp.dhis.interpretation.Interpretation)33 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)13 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)12 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)11 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)9 AccessDeniedException (org.springframework.security.access.AccessDeniedException)7 InterpretationComment (org.hisp.dhis.interpretation.InterpretationComment)6 PostMapping (org.springframework.web.bind.annotation.PostMapping)6 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)6 User (org.hisp.dhis.user.User)5 EventChart (org.hisp.dhis.eventchart.EventChart)4 EventVisualization (org.hisp.dhis.eventvisualization.EventVisualization)4 EventReport (org.hisp.dhis.eventreport.EventReport)3 Period (org.hisp.dhis.period.Period)3 ArrayList (java.util.ArrayList)2 Chart (org.hisp.dhis.chart.Chart)2 DataSet (org.hisp.dhis.dataset.DataSet)2 Visualization (org.hisp.dhis.visualization.Visualization)2 NotAuthenticatedException (org.hisp.dhis.webapi.controller.exception.NotAuthenticatedException)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2