use of org.kuali.rice.kew.api.action.ActionRequest in project cu-kfs by CU-CommunityApps.
the class CuProcurementCardAccountingLineAuthorizer method determineEditPermissionByFieldName.
@Override
protected boolean determineEditPermissionByFieldName(AccountingDocument accountingDocument, AccountingLine accountingLine, String fieldName, Person currentUser, Set<String> currentNodes) {
WorkflowDocument workflowDocument = accountingDocument.getDocumentHeader().getWorkflowDocument();
List<ActionRequest> actionRequests = workflowDocument.getRootActionRequests();
Set<String> nodeNames = workflowDocument.getCurrentNodeNames();
boolean isAddHocRoute = CollectionUtils.isNotEmpty(nodeNames) && nodeNames.contains(PurapWorkflowConstants.DOC_ADHOC_NODE_NAME);
if (!isAddHocRoute) {
for (ActionRequest actionRequest : actionRequests) {
isAddHocRoute = actionRequest.getActionTaken() == null && StringUtils.startsWith(actionRequest.getAnnotation(), "Ad Hoc Routed by") && StringUtils.equals(actionRequest.getPrincipalId(), currentUser.getPrincipalId());
if (isAddHocRoute) {
return false;
}
}
} else {
return false;
}
// 2. Check that the document is at AccountFullEdit route node
if (accountingDocument.getDocumentHeader() != null && accountingDocument.getDocumentHeader().getWorkflowDocument() != null) {
if (currentNodes != null && currentNodes.contains(RouteLevelNames.ACCOUNT_REVIEW_FULL_EDIT)) {
// 3. Check that the current user has the permission to edit the document, which means in this case he can edit the accounting line
if (getDocumentAuthorizer(accountingDocument).canEdit(accountingDocument, currentUser)) {
// since any user that can edit the accounting lines will be able to add/change it to any other account
return true;
}
}
}
return super.determineEditPermissionByFieldName(accountingDocument, accountingLine, fieldName, currentUser, currentNodes);
}
Aggregations