Search in sources :

Example 1 with ResponsibilityAction

use of org.kuali.kfs.kim.api.responsibility.ResponsibilityAction in project cu-kfs by CU-CommunityApps.

the class ResponsibilityServiceImpl method getActionsForResponsibilityRoles.

private List<ResponsibilityAction> getActionsForResponsibilityRoles(Responsibility responsibility, List<String> roleIds, Map<String, String> qualification) {
    List<ResponsibilityAction> results = new ArrayList<>();
    Collection<RoleMembership> roleMembers = roleService.getRoleMembers(roleIds, qualification);
    for (RoleMembership rm : roleMembers) {
        // only add them to the list if the member ID has been populated
        if (StringUtils.isNotBlank(rm.getMemberId())) {
            final ResponsibilityAction.Builder rai = ResponsibilityAction.Builder.create();
            rai.setMemberRoleId((rm.getEmbeddedRoleId() == null) ? rm.getRoleId() : rm.getEmbeddedRoleId());
            rai.setRoleId(rm.getRoleId());
            rai.setQualifier(rm.getQualifier());
            rai.setDelegates(rm.getDelegates());
            rai.setResponsibilityId(responsibility.getId());
            rai.setResponsibilityName(responsibility.getName());
            rai.setResponsibilityNamespaceCode(responsibility.getNamespaceCode());
            if (MemberType.PRINCIPAL.equals(rm.getType())) {
                rai.setPrincipalId(rm.getMemberId());
            } else {
                rai.setGroupId(rm.getMemberId());
            }
            // get associated resp resolution objects
            RoleResponsibilityAction action = getResponsibilityAction(rm.getRoleId(), responsibility.getId(), rm.getId());
            if (action == null) {
                LOG.error("Unable to get responsibility action record for role/responsibility/roleMember: " + rm.getRoleId() + "/" + responsibility.getId() + "/" + rm.getId());
                LOG.error("Skipping this role member in getActionsForResponsibilityRoles()");
                continue;
            }
            // add the data to the ResponsibilityActionInfo objects
            rai.setActionTypeCode(action.getActionTypeCode());
            rai.setActionPolicyCode(action.getActionPolicyCode());
            rai.setPriorityNumber(action.getPriorityNumber() == null ? DEFAULT_PRIORITY_NUMBER : action.getPriorityNumber());
            rai.setForceAction(action.isForceAction());
            rai.setParallelRoutingGroupingCode((rm.getRoleSortingCode() == null) ? "" : rm.getRoleSortingCode());
            rai.setRoleResponsibilityActionId(action.getId());
            results.add(rai.build());
        }
    }
    return Collections.unmodifiableList(results);
}
Also used : RoleResponsibilityAction(org.kuali.kfs.kim.impl.role.RoleResponsibilityAction) ArrayList(java.util.ArrayList) RoleMembership(org.kuali.kfs.kim.api.role.RoleMembership) ResponsibilityAction(org.kuali.kfs.kim.api.responsibility.ResponsibilityAction) RoleResponsibilityAction(org.kuali.kfs.kim.impl.role.RoleResponsibilityAction)

Example 2 with ResponsibilityAction

use of org.kuali.kfs.kim.api.responsibility.ResponsibilityAction in project cu-kfs by CU-CommunityApps.

the class ResponsibilityServiceImpl method getRespActions.

private List<ResponsibilityAction> getRespActions(final List<Responsibility> responsibilities, final Map<String, String> qualification, final Map<String, String> responsibilityDetails) {
    // now, filter the full list by the detail passed
    List<Responsibility> applicableResponsibilities = getMatchingResponsibilities(responsibilities, responsibilityDetails);
    List<ResponsibilityAction> results = new ArrayList<>();
    for (Responsibility r : applicableResponsibilities) {
        List<String> roleIds = getRoleIdsForResponsibility(r.getId());
        results.addAll(getActionsForResponsibilityRoles(r, roleIds, qualification));
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("Found " + results.size() + " matching ResponsibilityAction objects");
        if (LOG.isTraceEnabled()) {
            LOG.trace(results);
        }
    }
    return results;
}
Also used : ArrayList(java.util.ArrayList) RoleResponsibility(org.kuali.kfs.kim.impl.role.RoleResponsibility) ResponsibilityAction(org.kuali.kfs.kim.api.responsibility.ResponsibilityAction) RoleResponsibilityAction(org.kuali.kfs.kim.impl.role.RoleResponsibilityAction)

Aggregations

ArrayList (java.util.ArrayList)2 ResponsibilityAction (org.kuali.kfs.kim.api.responsibility.ResponsibilityAction)2 RoleResponsibilityAction (org.kuali.kfs.kim.impl.role.RoleResponsibilityAction)2 RoleMembership (org.kuali.kfs.kim.api.role.RoleMembership)1 RoleResponsibility (org.kuali.kfs.kim.impl.role.RoleResponsibility)1