Search in sources :

Example 16 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 17 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 18 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 19 with Interpretation

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

the class HibernateInterpretationStore method getByChartId.

@Override
public Interpretation getByChartId(int id) {
    String hql = "from Interpretation i where i.chart.id = " + id;
    Query query = getSession().createQuery(hql);
    return (Interpretation) query.uniqueResult();
}
Also used : Query(org.hibernate.Query) Interpretation(org.hisp.dhis.interpretation.Interpretation)

Example 20 with Interpretation

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

the class DefaultInterpretationService method likeInterpretation.

@Transactional(isolation = Isolation.REPEATABLE_READ)
public boolean likeInterpretation(int id) {
    Interpretation interpretation = getInterpretation(id);
    if (interpretation == null) {
        return false;
    }
    User user = currentUserService.getCurrentUser();
    if (user == null) {
        return false;
    }
    return interpretation.like(user);
}
Also used : User(org.hisp.dhis.user.User) Interpretation(org.hisp.dhis.interpretation.Interpretation) Transactional(org.springframework.transaction.annotation.Transactional)

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