use of org.kuali.rice.kim.api.role.RoleMembership.Builder in project cu-kfs by CU-CommunityApps.
the class CuRelatedDocumentDerivedRoleTypeServiceImpl method getRoleMembersFromDerivedRole.
@Override
public List<RoleMembership> getRoleMembersFromDerivedRole(String namespaceCode, String roleName, Map<String, String> qualification) {
List<RoleMembership> members = new ArrayList<RoleMembership>();
if (qualification != null && !qualification.isEmpty()) {
if (SOURCE_DOCUMENT_ROUTER_ROLE_NAME.equals(roleName)) {
try {
PurchasingAccountsPayableDocument document = (PurchasingAccountsPayableDocument) getDocumentService().getByDocumentHeaderId(qualification.get(KFSPropertyConstants.DOCUMENT_NUMBER));
if (document != null) {
PurchasingAccountsPayableDocument sourceDocument = document.getPurApSourceDocumentIfPossible();
if (sourceDocument != null && StringUtils.isNotBlank(sourceDocument.getDocumentHeader().getWorkflowDocument().getRoutedByPrincipalId())) {
Map<String, String> roleQualifier = new HashMap<String, String>(1);
roleQualifier.put(KimConstants.AttributeConstants.DOCUMENT_NUMBER, sourceDocument.getDocumentNumber());
Builder roleMember = RoleMembership.Builder.create(null, null, sourceDocument.getDocumentHeader().getWorkflowDocument().getRoutedByPrincipalId(), KimConstants.KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE, roleQualifier);
members.add(roleMember.build());
}
}
} catch (WorkflowException e) {
throw new RuntimeException("Unable to load document in getPrincipalIdsFromApplicationRole", e);
}
} else if (SENSITIVE_RELATED_DOCUMENT_INITATOR_OR_REVIEWER_ROLE_NAME.equals(roleName)) {
// KFSUPGRADE-346
if (!qualification.containsKey(PurapKimAttributes.ACCOUNTS_PAYABLE_PURCHASING_DOCUMENT_LINK_IDENTIFIER)) {
Map<String, String> tempQualification = new HashMap<String, String>(1);
tempQualification.put(KFSPropertyConstants.DOCUMENT_NUMBER, qualification.get("documentNumber"));
for (String principalId : getRoleService().getRoleMemberPrincipalIds(KRADConstants.KUALI_RICE_WORKFLOW_NAMESPACE, RouteLogDerivedRoleTypeServiceImpl.INITIATOR_OR_REVIEWER_ROLE_NAME, tempQualification)) {
Builder roleMember = RoleMembership.Builder.create(null, null, principalId, KimConstants.KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE, tempQualification);
members.add(roleMember.build());
}
} else {
for (String documentId : getPurapService().getRelatedDocumentIds(new Integer(qualification.get(PurapKimAttributes.ACCOUNTS_PAYABLE_PURCHASING_DOCUMENT_LINK_IDENTIFIER)))) {
Map<String, String> tempQualification = new HashMap<String, String>(1);
tempQualification.put(KFSPropertyConstants.DOCUMENT_NUMBER, documentId);
for (String principalId : getRoleService().getRoleMemberPrincipalIds(KRADConstants.KUALI_RICE_WORKFLOW_NAMESPACE, RouteLogDerivedRoleTypeServiceImpl.INITIATOR_OR_REVIEWER_ROLE_NAME, tempQualification)) {
Builder roleMember = RoleMembership.Builder.create(null, null, principalId, KimConstants.KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE, tempQualification);
members.add(roleMember.build());
}
}
}
}
}
return members;
}
Aggregations