Search in sources :

Example 1 with DataValueFollowUpRequest

use of org.hisp.dhis.webapi.webdomain.DataValueFollowUpRequest in project dhis2-core by dhis2.

the class DataValueController method setDataValuesFollowUp.

@PutMapping(value = "/followups")
@ResponseStatus(value = HttpStatus.OK)
public void setDataValuesFollowUp(@RequestBody DataValuesFollowUpRequest request) {
    List<DataValueFollowUpRequest> values = request == null ? null : request.getValues();
    if (values == null || values.isEmpty() || values.stream().anyMatch(e -> e.getFollowup() == null)) {
        throw new IllegalQueryException(ErrorCode.E2033);
    }
    List<DataValue> dataValues = new ArrayList<>();
    for (DataValueFollowUpRequest e : values) {
        DataValue dataValue = dataValueValidation.getAndValidateDataValue(e);
        dataValue.setFollowup(e.getFollowup());
    }
    dataValueService.updateDataValues(dataValues);
}
Also used : ContextUtils.setNoStore(org.hisp.dhis.webapi.utils.ContextUtils.setNoStore) RequestParam(org.springframework.web.bind.annotation.RequestParam) Date(java.util.Date) ValueType(org.hisp.dhis.common.ValueType) WebMessageException(org.hisp.dhis.dxf2.webmessage.WebMessageException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequiredArgsConstructor(lombok.RequiredArgsConstructor) StringUtils(org.apache.commons.lang3.StringUtils) FileResourceStorageStatus(org.hisp.dhis.fileresource.FileResourceStorageStatus) CurrentUser(org.hisp.dhis.user.CurrentUser) Model(org.springframework.ui.Model) PutMapping(org.springframework.web.bind.annotation.PutMapping) FileResourceService(org.hisp.dhis.fileresource.FileResourceService) InputUtils(org.hisp.dhis.dxf2.util.InputUtils) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping) Status(org.hisp.dhis.feedback.Status) Period(org.hisp.dhis.period.Period) PostMapping(org.springframework.web.bind.annotation.PostMapping) HttpHeaders(org.springframework.http.HttpHeaders) List(java.util.List) FileResourceUtils(org.hisp.dhis.webapi.utils.FileResourceUtils) CategoryOptionCombo(org.hisp.dhis.category.CategoryOptionCombo) WebMessageUtils.conflict(org.hisp.dhis.dxf2.webmessage.WebMessageUtils.conflict) WebMessage(org.hisp.dhis.dxf2.webmessage.WebMessage) DhisApiVersion(org.hisp.dhis.common.DhisApiVersion) WebMessageUtils.notFound(org.hisp.dhis.dxf2.webmessage.WebMessageUtils.notFound) DataSet(org.hisp.dhis.dataset.DataSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) Controller(org.springframework.stereotype.Controller) IllegalQueryException(org.hisp.dhis.common.IllegalQueryException) ApiVersion(org.hisp.dhis.webapi.mvc.annotation.ApiVersion) ArrayList(java.util.ArrayList) DataElement(org.hisp.dhis.dataelement.DataElement) RequestBody(org.springframework.web.bind.annotation.RequestBody) HttpServletRequest(javax.servlet.http.HttpServletRequest) DataValueService(org.hisp.dhis.datavalue.DataValueService) AuthorizationException(org.jclouds.rest.AuthorizationException) WebMessageUtils.error(org.hisp.dhis.dxf2.webmessage.WebMessageUtils.error) User(org.hisp.dhis.user.User) GetMapping(org.springframework.web.bind.annotation.GetMapping) ErrorCode(org.hisp.dhis.feedback.ErrorCode) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) SystemSettingManager(org.hisp.dhis.setting.SystemSettingManager) DataValuesFollowUpRequest(org.hisp.dhis.webapi.webdomain.DataValuesFollowUpRequest) FileResourceRetentionStrategy(org.hisp.dhis.fileresource.FileResourceRetentionStrategy) FileResource(org.hisp.dhis.fileresource.FileResource) HttpServletResponse(javax.servlet.http.HttpServletResponse) IOException(java.io.IOException) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) DataValueFollowUpRequest(org.hisp.dhis.webapi.webdomain.DataValueFollowUpRequest) HttpStatus(org.springframework.http.HttpStatus) FileResourceWebMessageResponse(org.hisp.dhis.dxf2.webmessage.responses.FileResourceWebMessageResponse) DataValue(org.hisp.dhis.datavalue.DataValue) MultipartFile(org.springframework.web.multipart.MultipartFile) SettingKey(org.hisp.dhis.setting.SettingKey) FileResourceDomain(org.hisp.dhis.fileresource.FileResourceDomain) DataValueFollowUpRequest(org.hisp.dhis.webapi.webdomain.DataValueFollowUpRequest) DataValue(org.hisp.dhis.datavalue.DataValue) ArrayList(java.util.ArrayList) IllegalQueryException(org.hisp.dhis.common.IllegalQueryException) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PutMapping(org.springframework.web.bind.annotation.PutMapping)

Aggregations

IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 List (java.util.List)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 RequiredArgsConstructor (lombok.RequiredArgsConstructor)1 StringUtils (org.apache.commons.lang3.StringUtils)1 CategoryOptionCombo (org.hisp.dhis.category.CategoryOptionCombo)1 DhisApiVersion (org.hisp.dhis.common.DhisApiVersion)1 IllegalQueryException (org.hisp.dhis.common.IllegalQueryException)1 ValueType (org.hisp.dhis.common.ValueType)1 DataElement (org.hisp.dhis.dataelement.DataElement)1 DataSet (org.hisp.dhis.dataset.DataSet)1 DataValue (org.hisp.dhis.datavalue.DataValue)1 DataValueService (org.hisp.dhis.datavalue.DataValueService)1 InputUtils (org.hisp.dhis.dxf2.util.InputUtils)1 WebMessage (org.hisp.dhis.dxf2.webmessage.WebMessage)1 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)1 WebMessageUtils.conflict (org.hisp.dhis.dxf2.webmessage.WebMessageUtils.conflict)1