use of org.hisp.dhis.dataapproval.DataApproval in project dhis2-core by dhis2.
the class DataApprovalController method saveApprovalMultiple.
@PreAuthorize("hasRole('ALL') or hasRole('F_APPROVE_DATA') or hasRole('F_APPROVE_DATA_LOWER_LEVELS')")
@RequestMapping(value = MULTIPLE_SAVE_RESOURCE_PATH, method = RequestMethod.POST)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void saveApprovalMultiple(@RequestBody DataApprovalStateRequests dataApprovalStateRequests, HttpServletResponse response) throws WebMessageException {
List<DataApproval> dataApprovalList = new ArrayList<>();
for (DataApprovalStateRequest approvalStateRequest : dataApprovalStateRequests) {
DataApprovalWorkflow workflow = getAndValidateWorkflow(approvalStateRequest.getDs(), null);
Period period = getAndValidatePeriod(approvalStateRequest.getPe());
OrganisationUnit organisationUnit = getAndValidateOrgUnit(approvalStateRequest.getOu());
DataApprovalLevel dataApprovalLevel = getAndValidateApprovalLevel(organisationUnit);
User user = approvalStateRequest.getAb() == null ? currentUserService.getCurrentUser() : userService.getUserCredentialsByUsername(approvalStateRequest.getAb()).getUserInfo();
Date approvalDate = approvalStateRequest.getAd() == null ? new Date() : approvalStateRequest.getAd();
dataApprovalList.addAll(getApprovalsAsList(dataApprovalLevel, workflow, period, organisationUnit, false, approvalDate, user));
}
dataApprovalService.approveData(dataApprovalList);
}
Aggregations