Search in sources :

Example 1 with RoleMember

use of org.kuali.kfs.kim.impl.role.RoleMember in project cu-kfs by CU-CommunityApps.

the class OrgReviewRoleServiceImpl method getRoleMembers.

protected List<RoleMember> getRoleMembers(OrgReviewRole orr) {
    List<RoleMember> objectsToSave = new ArrayList<>();
    List<String> roleNamesToSaveFor = getRolesToSaveFor(orr.getRoleNamesToConsider(), orr.getReviewRolesIndicator());
    for (String roleName : roleNamesToSaveFor) {
        RoleLite roleInfo = getRoleInfo(roleName);
        RoleMember roleMemberToSave = getRoleMemberToSave(roleInfo, orr);
        if (roleMemberToSave != null) {
            objectsToSave.add(roleMemberToSave);
        }
    }
    return objectsToSave;
}
Also used : RoleLite(org.kuali.kfs.kim.impl.role.RoleLite) ArrayList(java.util.ArrayList) RoleMember(org.kuali.kfs.kim.impl.role.RoleMember)

Example 2 with RoleMember

use of org.kuali.kfs.kim.impl.role.RoleMember in project cu-kfs by CU-CommunityApps.

the class OrgReviewRoleServiceImpl method populateOrgReviewRoleFromRoleMember.

@Override
public void populateOrgReviewRoleFromRoleMember(OrgReviewRole orr, String roleMemberId) {
    if (StringUtils.isBlank(roleMemberId)) {
        throw new IllegalArgumentException("Role member ID may not be blank");
    }
    RoleMember roleMember = getRoleMemberFromKimRoleService(roleMemberId);
    orr.setRoleMember(roleMember);
    populateObjectExtras(orr);
}
Also used : RoleMember(org.kuali.kfs.kim.impl.role.RoleMember)

Example 3 with RoleMember

use of org.kuali.kfs.kim.impl.role.RoleMember in project cu-kfs by CU-CommunityApps.

the class OrgReviewRoleServiceImpl method populateOrgReviewRoleFromDelegationMember.

@Override
public void populateOrgReviewRoleFromDelegationMember(OrgReviewRole orr, String roleMemberId, String delegationMemberId) {
    RoleMember roleMember = null;
    if (StringUtils.isNotBlank(roleMemberId)) {
        roleMember = getRoleMemberFromKimRoleService(roleMemberId);
    }
    RoleService roleService = KimApiServiceLocator.getRoleService();
    DelegateMember delegationMember = roleService.getDelegationMemberById(delegationMemberId);
    DelegateType delegation = roleService.getDelegateTypeByDelegationId(delegationMember.getDelegationId());
    orr.setDelegationTypeCode(delegation.getDelegationType().getCode());
    orr.setDelegateMember(roleMember, delegationMember);
    orr.setRoleRspActions(roleService.getRoleMemberResponsibilityActions(delegationMember.getRoleMemberId()));
    populateObjectExtras(orr);
}
Also used : OrgReviewRoleService(org.kuali.kfs.coa.service.OrgReviewRoleService) RoleService(org.kuali.kfs.kim.api.role.RoleService) KfsKimDocDelegateMember(org.kuali.kfs.coa.identity.KfsKimDocDelegateMember) DelegateMember(org.kuali.kfs.kim.impl.common.delegate.DelegateMember) DelegateType(org.kuali.kfs.kim.impl.common.delegate.DelegateType) RoleMember(org.kuali.kfs.kim.impl.role.RoleMember)

Example 4 with RoleMember

use of org.kuali.kfs.kim.impl.role.RoleMember in project cu-kfs by CU-CommunityApps.

the class OrgReviewRoleServiceImpl method saveRoleMemberToKim.

protected void saveRoleMemberToKim(OrgReviewRole orr) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Saving role member from OrgReviewRole: " + orr);
    }
    RoleService roleService = KimApiServiceLocator.getRoleService();
    // Save role member(s)
    for (RoleMember roleMember : getRoleMembers(orr)) {
        List<RoleResponsibilityAction> roleRspActionsToSave = getRoleResponsibilityActions(orr, roleMember);
        // KFSCNTRB-1391
        GenericQueryResults<RoleMember> roleMembers = null;
        if (orr.isEdit()) {
            roleMembers = roleService.findRoleMembers(QueryByCriteria.Builder.fromPredicates(PredicateUtils.convertMapToPredicate(Collections.singletonMap(KimConstants.PrimaryKeyConstants.ID, roleMember.getId()))));
        }
        if (orr.isEdit() && roleMembers != null && roleMembers.getResults() != null && !roleMembers.getResults().isEmpty()) {
            RoleMember existingRoleMember = roleMembers.getResults().get(0);
            roleMember = roleService.updateRoleMember(existingRoleMember);
        } else {
            roleMember = roleService.createRoleMember(roleMember);
        }
        for (RoleResponsibilityAction rra : roleRspActionsToSave) {
            // ensure linked to the right record
            rra.setRoleMemberId(roleMember.getId());
            if (StringUtils.isBlank(rra.getId())) {
                roleService.createRoleResponsibilityAction(rra);
            } else {
                roleService.updateRoleResponsibilityAction(rra);
            }
        }
        orr.setRoleMemberId(roleMember.getId());
        orr.setORMId(roleMember.getId());
    }
}
Also used : OrgReviewRoleService(org.kuali.kfs.coa.service.OrgReviewRoleService) RoleService(org.kuali.kfs.kim.api.role.RoleService) RoleResponsibilityAction(org.kuali.kfs.kim.impl.role.RoleResponsibilityAction) RoleMember(org.kuali.kfs.kim.impl.role.RoleMember)

Example 5 with RoleMember

use of org.kuali.kfs.kim.impl.role.RoleMember in project cu-kfs by CU-CommunityApps.

the class OrgReviewRoleServiceImpl method getRoleMemberToSave.

protected RoleMember getRoleMemberToSave(RoleLite role, OrgReviewRole orr) {
    RoleMember roleMember = null;
    if (orr.getPerson() != null) {
        roleMember = new RoleMember();
        roleMember.setRoleId(role.getId());
        roleMember.setType(MemberType.PRINCIPAL);
        roleMember.setMemberId(orr.getPerson().getPrincipalId());
    } else if (orr.getGroup() != null) {
        roleMember = new RoleMember();
        roleMember.setRoleId(role.getId());
        roleMember.setType(MemberType.GROUP);
        roleMember.setMemberId(orr.getGroup().getId());
    } else if (orr.getRole() != null) {
        roleMember = new RoleMember();
        roleMember.setRoleId(role.getId());
        roleMember.setType(MemberType.ROLE);
        roleMember.setMemberId(orr.getRole().getId());
    }
    if (roleMember != null) {
        if (orr.isEdit()) {
            roleMember.setId(orr.getRoleMemberId());
        }
        roleMember.setAttributes(getAttributes(orr, role.getKimTypeId()));
        if (orr.getActiveFromDate() != null) {
            roleMember.setActiveFromDateValue(new Timestamp(orr.getActiveFromDate().getTime()));
        }
        if (orr.getActiveToDate() != null) {
            roleMember.setActiveToDateValue(new Timestamp(orr.getActiveToDate().getTime()));
        }
    }
    return roleMember;
}
Also used : Timestamp(java.sql.Timestamp) RoleMember(org.kuali.kfs.kim.impl.role.RoleMember)

Aggregations

RoleMember (org.kuali.kfs.kim.impl.role.RoleMember)7 ArrayList (java.util.ArrayList)2 OrgReviewRoleService (org.kuali.kfs.coa.service.OrgReviewRoleService)2 RoleService (org.kuali.kfs.kim.api.role.RoleService)2 Timestamp (java.sql.Timestamp)1 HashMap (java.util.HashMap)1 KfsKimDocDelegateMember (org.kuali.kfs.coa.identity.KfsKimDocDelegateMember)1 KimDocumentRoleMember (org.kuali.kfs.kim.bo.ui.KimDocumentRoleMember)1 DelegateMember (org.kuali.kfs.kim.impl.common.delegate.DelegateMember)1 DelegateType (org.kuali.kfs.kim.impl.common.delegate.DelegateType)1 Role (org.kuali.kfs.kim.impl.role.Role)1 RoleLite (org.kuali.kfs.kim.impl.role.RoleLite)1 RoleResponsibility (org.kuali.kfs.kim.impl.role.RoleResponsibility)1 RoleResponsibilityAction (org.kuali.kfs.kim.impl.role.RoleResponsibilityAction)1