Search in sources :

Example 1 with Builder

use of org.kuali.kfs.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(KFSConstants.CoreModuleNamespaces.WORKFLOW, 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(KFSConstants.CoreModuleNamespaces.WORKFLOW, 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;
}
Also used : HashMap(java.util.HashMap) Builder(org.kuali.kfs.kim.api.role.RoleMembership.Builder) WorkflowException(org.kuali.kfs.kew.api.exception.WorkflowException) ArrayList(java.util.ArrayList) RoleMembership(org.kuali.kfs.kim.api.role.RoleMembership) PurchasingAccountsPayableDocument(org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 WorkflowException (org.kuali.kfs.kew.api.exception.WorkflowException)1 RoleMembership (org.kuali.kfs.kim.api.role.RoleMembership)1 Builder (org.kuali.kfs.kim.api.role.RoleMembership.Builder)1 PurchasingAccountsPayableDocument (org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument)1