Search in sources :

Example 1 with KimDocumentRoleQualifier

use of org.kuali.kfs.kim.bo.ui.KimDocumentRoleQualifier in project cu-kfs by CU-CommunityApps.

the class IdentityManagementRoleDocument method prepareForSave.

@Override
public void prepareForSave() {
    SequenceAccessorService sas = getSequenceAccessorService();
    String roleId;
    if (StringUtils.isBlank(getRoleId())) {
        Long nextSeq = sas.getNextAvailableSequenceNumber(KimConstants.SequenceNames.KRIM_ROLE_ID_S, this.getClass());
        roleId = nextSeq.toString();
        setRoleId(roleId);
    } else {
        roleId = getRoleId();
    }
    if (getPermissions() != null) {
        String rolePermissionId;
        for (KimDocumentRolePermission permission : getPermissions()) {
            permission.setRoleId(roleId);
            permission.setDocumentNumber(getDocumentNumber());
            if (StringUtils.isBlank(permission.getRolePermissionId())) {
                Long nextSeq = sas.getNextAvailableSequenceNumber(KimConstants.SequenceNames.KRIM_ROLE_PERM_ID_S, KimDocumentRolePermission.class);
                rolePermissionId = nextSeq.toString();
                permission.setRolePermissionId(rolePermissionId);
            }
        }
    }
    if (getResponsibilities() != null) {
        String roleResponsibilityId;
        for (KimDocumentRoleResponsibility responsibility : getResponsibilities()) {
            if (StringUtils.isBlank(responsibility.getRoleResponsibilityId())) {
                Long nextSeq = sas.getNextAvailableSequenceNumber(KimConstants.SequenceNames.KRIM_ROLE_RSP_ID_S, KimDocumentRoleResponsibility.class);
                roleResponsibilityId = nextSeq.toString();
                responsibility.setRoleResponsibilityId(roleResponsibilityId);
            }
            responsibility.setRoleId(roleId);
            if (!getResponsibilityInternalService().areActionsAtAssignmentLevelById(responsibility.getResponsibilityId())) {
                if (StringUtils.isBlank(responsibility.getRoleRspActions().get(0).getRoleResponsibilityActionId())) {
                    Long nextSeq = sas.getNextAvailableSequenceNumber(KimConstants.SequenceNames.KRIM_ROLE_RSP_ACTN_ID_S, KimDocumentRoleResponsibilityAction.class);
                    String roleResponsibilityActionId = nextSeq.toString();
                    responsibility.getRoleRspActions().get(0).setRoleResponsibilityActionId(roleResponsibilityActionId);
                }
                responsibility.getRoleRspActions().get(0).setRoleMemberId("*");
                responsibility.getRoleRspActions().get(0).setDocumentNumber(getDocumentNumber());
            }
        }
    }
    if (getModifiedMembers() != null) {
        String roleMemberId;
        String roleResponsibilityActionId;
        for (KimDocumentRoleMember member : getModifiedMembers()) {
            member.setDocumentNumber(getDocumentNumber());
            member.setRoleId(roleId);
            if (StringUtils.isBlank(member.getRoleMemberId())) {
                Long nextSeq = sas.getNextAvailableSequenceNumber(KimConstants.SequenceNames.KRIM_ROLE_MBR_ID_S, KimDocumentRoleMember.class);
                roleMemberId = nextSeq.toString();
                member.setRoleMemberId(roleMemberId);
            }
            for (KimDocumentRoleQualifier qualifier : member.getQualifiers()) {
                qualifier.setDocumentNumber(getDocumentNumber());
                qualifier.setRoleMemberId(member.getRoleMemberId());
                qualifier.setKimTypId(getKimType().getId());
            }
            for (KimDocumentRoleResponsibilityAction roleRespAction : member.getRoleRspActions()) {
                if (StringUtils.isBlank(roleRespAction.getRoleResponsibilityActionId())) {
                    Long nextSeq = sas.getNextAvailableSequenceNumber(KimConstants.SequenceNames.KRIM_ROLE_RSP_ACTN_ID_S, KimDocumentRoleResponsibilityAction.class);
                    roleResponsibilityActionId = nextSeq.toString();
                    roleRespAction.setRoleResponsibilityActionId(roleResponsibilityActionId);
                }
                roleRespAction.setRoleMemberId(member.getRoleMemberId());
                roleRespAction.setDocumentNumber(getDocumentNumber());
                if (!StringUtils.equals(roleRespAction.getRoleResponsibilityId(), "*")) {
                    for (KimDocumentRoleResponsibility responsibility : getResponsibilities()) {
                        if (StringUtils.equals(roleRespAction.getKimResponsibility().getId(), responsibility.getResponsibilityId())) {
                            roleRespAction.setRoleResponsibilityId(responsibility.getRoleResponsibilityId());
                        }
                    }
                }
            }
        }
    }
    if (getDelegationMembers() != null) {
        for (RoleDocumentDelegationMember delegationMember : getDelegationMembers()) {
            delegationMember.setDocumentNumber(getDocumentNumber());
            addDelegationMemberToDelegation(delegationMember);
        }
        for (RoleDocumentDelegation delegation : getDelegations()) {
            delegation.setDocumentNumber(getDocumentNumber());
            delegation.setKimTypeId(getKimType().getId());
            List<RoleDocumentDelegationMember> membersToRemove = new AutoPopulatingList<>(RoleDocumentDelegationMember.class);
            for (RoleDocumentDelegationMember member : delegation.getMembers()) {
                if (delegation.getDelegationId().equals(member.getDelegationId()) && delegation.getDelegationTypeCode().equals(member.getDelegationTypeCode())) {
                    for (RoleDocumentDelegationMemberQualifier qualifier : member.getQualifiers()) {
                        qualifier.setKimTypId(getKimType().getId());
                        qualifier.setDocumentNumber(getDocumentNumber());
                    }
                } else {
                    membersToRemove.add(member);
                }
            }
            if (!membersToRemove.isEmpty()) {
                for (RoleDocumentDelegationMember member : membersToRemove) {
                    delegation.getMembers().remove(member);
                }
            }
            delegation.setRoleId(roleId);
        }
    }
}
Also used : KimDocumentRolePermission(org.kuali.kfs.kim.bo.ui.KimDocumentRolePermission) KimDocumentRoleMember(org.kuali.kfs.kim.bo.ui.KimDocumentRoleMember) RoleDocumentDelegation(org.kuali.kfs.kim.bo.ui.RoleDocumentDelegation) RoleDocumentDelegationMemberQualifier(org.kuali.kfs.kim.bo.ui.RoleDocumentDelegationMemberQualifier) KimDocumentRoleQualifier(org.kuali.kfs.kim.bo.ui.KimDocumentRoleQualifier) KimDocumentRoleResponsibilityAction(org.kuali.kfs.kim.bo.ui.KimDocumentRoleResponsibilityAction) SequenceAccessorService(org.kuali.kfs.krad.service.SequenceAccessorService) KimDocumentRoleResponsibility(org.kuali.kfs.kim.bo.ui.KimDocumentRoleResponsibility) RoleDocumentDelegationMember(org.kuali.kfs.kim.bo.ui.RoleDocumentDelegationMember) AutoPopulatingList(org.springframework.util.AutoPopulatingList)

Example 2 with KimDocumentRoleQualifier

use of org.kuali.kfs.kim.bo.ui.KimDocumentRoleQualifier in project cu-kfs by CU-CommunityApps.

the class IdentityManagementRoleDocument method getBlankMember.

public KimDocumentRoleMember getBlankMember() {
    KimDocumentRoleMember member = new KimDocumentRoleMember();
    KimDocumentRoleQualifier qualifier;
    if (getDefinitions() != null) {
        for (KimAttributeField key : getDefinitions()) {
            qualifier = new KimDocumentRoleQualifier();
            qualifier.setKimAttrDefnId(getKimAttributeDefnId(key));
            member.getQualifiers().add(qualifier);
        }
    }
    setupMemberRspActions(member);
    return member;
}
Also used : KimAttributeField(org.kuali.kfs.kim.api.type.KimAttributeField) KimDocumentRoleMember(org.kuali.kfs.kim.bo.ui.KimDocumentRoleMember) KimDocumentRoleQualifier(org.kuali.kfs.kim.bo.ui.KimDocumentRoleQualifier)

Aggregations

KimDocumentRoleMember (org.kuali.kfs.kim.bo.ui.KimDocumentRoleMember)2 KimDocumentRoleQualifier (org.kuali.kfs.kim.bo.ui.KimDocumentRoleQualifier)2 KimAttributeField (org.kuali.kfs.kim.api.type.KimAttributeField)1 KimDocumentRolePermission (org.kuali.kfs.kim.bo.ui.KimDocumentRolePermission)1 KimDocumentRoleResponsibility (org.kuali.kfs.kim.bo.ui.KimDocumentRoleResponsibility)1 KimDocumentRoleResponsibilityAction (org.kuali.kfs.kim.bo.ui.KimDocumentRoleResponsibilityAction)1 RoleDocumentDelegation (org.kuali.kfs.kim.bo.ui.RoleDocumentDelegation)1 RoleDocumentDelegationMember (org.kuali.kfs.kim.bo.ui.RoleDocumentDelegationMember)1 RoleDocumentDelegationMemberQualifier (org.kuali.kfs.kim.bo.ui.RoleDocumentDelegationMemberQualifier)1 SequenceAccessorService (org.kuali.kfs.krad.service.SequenceAccessorService)1 AutoPopulatingList (org.springframework.util.AutoPopulatingList)1