use of org.hisp.dhis.dataapproval.DataApprovalPermissions in project dhis2-core by dhis2.
the class DataApprovalController method getApprovalPermissions.
// -------------------------------------------------------------------------
// Get
// -------------------------------------------------------------------------
@GetMapping(value = APPROVALS_PATH, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@ResponseStatus(HttpStatus.OK)
public DataApprovalPermissions getApprovalPermissions(@RequestParam(required = false) String ds, @RequestParam(required = false) String wf, @RequestParam String pe, @RequestParam String ou, @RequestParam(required = false) String aoc) throws WebMessageException {
DataApprovalWorkflow workflow = getAndValidateWorkflow(ds, wf);
Period period = getAndValidatePeriod(pe);
OrganisationUnit organisationUnit = getAndValidateOrgUnit(ou);
CategoryOptionCombo optionCombo = getAndValidateAttributeOptionCombo(aoc);
DataApprovalStatus status = dataApprovalService.getDataApprovalStatus(workflow, period, organisationUnit, optionCombo);
DataApprovalPermissions permissions = status.getPermissions();
permissions.setState(status.getState().toString());
return status.getPermissions();
}
use of org.hisp.dhis.dataapproval.DataApprovalPermissions in project dhis2-core by dhis2.
the class DataApprovalController method getApprovalPermissions.
// -------------------------------------------------------------------------
// Get
// -------------------------------------------------------------------------
@RequestMapping(value = APPROVALS_PATH, method = RequestMethod.GET, produces = ContextUtils.CONTENT_TYPE_JSON)
public void getApprovalPermissions(@RequestParam(required = false) String ds, @RequestParam(required = false) String wf, @RequestParam String pe, @RequestParam String ou, HttpServletResponse response) throws IOException, WebMessageException {
DataApprovalWorkflow workflow = getAndValidateWorkflow(ds, wf);
Period period = getAndValidatePeriod(pe);
OrganisationUnit organisationUnit = getAndValidateOrgUnit(ou);
DataElementCategoryOptionCombo optionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
DataApprovalStatus status = dataApprovalService.getDataApprovalStatusAndPermissions(workflow, period, organisationUnit, optionCombo);
DataApprovalPermissions permissions = status.getPermissions();
permissions.setState(status.getState().toString());
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
renderService.toJson(response.getOutputStream(), status.getPermissions());
}
use of org.hisp.dhis.dataapproval.DataApprovalPermissions in project dhis2-core by dhis2.
the class DataApprovalController method getDataApprovalStateResponse.
private DataApprovalStateResponse getDataApprovalStateResponse(DataSet dataSet, OrganisationUnit organisationUnit, Period period) {
CategoryOptionCombo optionCombo = categoryService.getDefaultCategoryOptionCombo();
DataApprovalStatus status = dataApprovalService.getDataApprovalStatus(dataSet.getWorkflow(), period, organisationUnit, optionCombo);
DataApprovalPermissions permissions = status.getPermissions();
return DataApprovalStateResponse.builder().dataSet(dataSet).organisationUnit(organisationUnit).period(period).state(status.getState().toString()).createdDate(status.getCreated()).createdByUsername(status.getCreator() == null ? null : status.getCreator().getUsername()).permissions(permissions).build();
}
Aggregations