use of org.hisp.dhis.dataapproval.DataApprovalWorkflow in project dhis2-core by dhis2.
the class DataApprovalController method unacceptApproval.
@PreAuthorize("hasRole('ALL') or hasRole('F_ACCEPT_DATA_LOWER_LEVELS')")
@DeleteMapping(ACCEPTANCES_PATH)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void unacceptApproval(@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);
DataApprovalLevel dataApprovalLevel = getAndValidateApprovalLevel(organisationUnit);
CategoryOptionCombo optionCombo = getAndValidateAttributeOptionCombo(aoc);
User user = currentUserService.getCurrentUser();
List<DataApproval> dataApprovalList = getApprovalsAsList(dataApprovalLevel, workflow, period, organisationUnit, optionCombo, false, new Date(), user);
dataApprovalService.unacceptData(dataApprovalList);
}
use of org.hisp.dhis.dataapproval.DataApprovalWorkflow in project dhis2-core by dhis2.
the class UserControllerUtils method getUserDataApprovalWorkflows.
/**
* Gets the data approval workflows a user can see, including the workflow
* levels accessible to the user and the actions (if any) they can take at
* those levels to approve (and accept if configured) data.
*
* @param user the user
* @throws Exception if an error occurs
*/
public RootNode getUserDataApprovalWorkflows(User user) throws Exception {
CollectionNode collectionNode = new CollectionNode("dataApprovalWorkflows", true);
for (DataApprovalWorkflow workflow : dataApprovalService.getAllWorkflows()) {
if (!aclService.canRead(user, workflow)) {
continue;
}
ComplexNode workflowNode = new ComplexNode("dataApprovalWorkflow");
workflowNode.addChild(new SimpleNode("name", workflow.getName()));
workflowNode.addChild(new SimpleNode("id", workflow.getUid()));
workflowNode.addChild(getWorkflowLevelNodes(user, workflow));
collectionNode.addChild(workflowNode);
}
collectionNode.getUnorderedChildren().sort(Comparator.comparing(c -> (String) ((SimpleNode) c.getUnorderedChildren().get(0)).getValue()));
RootNode rootNode = NodeUtils.createRootNode("dataApprovalWorkflows");
rootNode.addChild(collectionNode);
return rootNode;
}
Aggregations