Search in sources :

Example 1 with DataApprovalPermissions

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();
}
Also used : DataApprovalPermissions(org.hisp.dhis.dataapproval.DataApprovalPermissions) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) Period(org.hisp.dhis.period.Period) DataApprovalWorkflow(org.hisp.dhis.dataapproval.DataApprovalWorkflow) DataApprovalStatus(org.hisp.dhis.dataapproval.DataApprovalStatus) CategoryOptionCombo(org.hisp.dhis.category.CategoryOptionCombo) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with DataApprovalPermissions

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());
}
Also used : DataApprovalPermissions(org.hisp.dhis.dataapproval.DataApprovalPermissions) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) Period(org.hisp.dhis.period.Period) DataApprovalWorkflow(org.hisp.dhis.dataapproval.DataApprovalWorkflow) DataApprovalStatus(org.hisp.dhis.dataapproval.DataApprovalStatus) DataElementCategoryOptionCombo(org.hisp.dhis.dataelement.DataElementCategoryOptionCombo) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with DataApprovalPermissions

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();
}
Also used : DataApprovalPermissions(org.hisp.dhis.dataapproval.DataApprovalPermissions) DataApprovalStatus(org.hisp.dhis.dataapproval.DataApprovalStatus) CategoryOptionCombo(org.hisp.dhis.category.CategoryOptionCombo)

Aggregations

DataApprovalPermissions (org.hisp.dhis.dataapproval.DataApprovalPermissions)3 DataApprovalStatus (org.hisp.dhis.dataapproval.DataApprovalStatus)3 CategoryOptionCombo (org.hisp.dhis.category.CategoryOptionCombo)2 DataApprovalWorkflow (org.hisp.dhis.dataapproval.DataApprovalWorkflow)2 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)2 Period (org.hisp.dhis.period.Period)2 DataElementCategoryOptionCombo (org.hisp.dhis.dataelement.DataElementCategoryOptionCombo)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)1