use of org.kuali.kfs.kim.impl.role.RoleResponsibilityAction 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);
}
use of org.kuali.kfs.kim.impl.role.RoleResponsibilityAction 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());
}
}
use of org.kuali.kfs.kim.impl.role.RoleResponsibilityAction in project cu-kfs by CU-CommunityApps.
the class OrgReviewRoleServiceImpl method getRoleResponsibilityActions.
protected List<RoleResponsibilityAction> getRoleResponsibilityActions(OrgReviewRole orr, RoleMember roleMember) {
List<RoleResponsibilityAction> roleResponsibilityActions = new ArrayList<>(1);
RoleResponsibilityAction rra = new RoleResponsibilityAction();
// otherwise, it will be left blank and a new one will be created
if (StringUtils.isNotBlank(roleMember.getId())) {
List<RoleResponsibilityAction> origRoleRspActions = KimApiServiceLocator.getRoleService().getRoleMemberResponsibilityActions(roleMember.getId());
if (origRoleRspActions != null && !origRoleRspActions.isEmpty()) {
rra.setId(origRoleRspActions.get(0).getId());
rra.setVersionNumber(origRoleRspActions.get(0).getVersionNumber());
}
}
rra.setRoleMemberId(roleMember.getId());
rra.setRoleResponsibilityId("*");
rra.setActionTypeCode(orr.getActionTypeCode());
rra.setActionPolicyCode(orr.getActionPolicyCode());
if (StringUtils.isNotBlank(orr.getPriorityNumber())) {
try {
rra.setPriorityNumber(Integer.valueOf(orr.getPriorityNumber()));
} catch (Exception nfx) {
rra.setPriorityNumber(null);
}
}
rra.setForceAction(orr.isForceAction());
roleResponsibilityActions.add(rra);
return roleResponsibilityActions;
}
use of org.kuali.kfs.kim.impl.role.RoleResponsibilityAction in project cu-kfs by CU-CommunityApps.
the class ResponsibilityServiceImpl method getResponsibilityAction.
private RoleResponsibilityAction getResponsibilityAction(String roleId, String responsibilityId, String roleMemberId) {
RoleResponsibilityAction result = null;
// KULRICE-7459: Requisition, PO and its subtype documents are going to final status where they should not.
//
// need to do in 2 steps due to "*" wildcard convention in column data for role member id and role
// responsibility id. Well, we could do in 1 step w/ straight SQL, but not w/ Criteria API due to the
// INNER JOIN automatically created between RoleResponsibility and RoleResponsibilityAction tables.
final Predicate roleResponsibilityPredicate = PredicateFactory.and(PredicateFactory.equal("responsibilityId", responsibilityId), PredicateFactory.equal("roleId", roleId), PredicateFactory.equal("active", "Y"));
// First get RoleResponsibilities
final QueryByCriteria.Builder roleResponsibilityQueryBuilder = QueryByCriteria.Builder.create();
roleResponsibilityQueryBuilder.setPredicates(roleResponsibilityPredicate);
final GenericQueryResults<RoleResponsibility> roleResponsibilityResults = criteriaLookupService.lookup(RoleResponsibility.class, roleResponsibilityQueryBuilder.build());
final List<RoleResponsibility> roleResponsibilities = roleResponsibilityResults.getResults();
if (!CollectionUtils.isEmpty(roleResponsibilities)) {
// if there are any...
// Then query RoleResponsibilityActions based on them
List<String> roleResponsibilityIds = new ArrayList<>(roleResponsibilities.size());
for (RoleResponsibility roleResponsibility : roleResponsibilities) {
roleResponsibilityIds.add(roleResponsibility.getRoleResponsibilityId());
}
final Predicate roleResponsibilityActionPredicate = PredicateFactory.or(PredicateFactory.and(PredicateFactory.in("roleResponsibilityId", roleResponsibilityIds.toArray()), PredicateFactory.or(PredicateFactory.equal(org.kuali.kfs.kim.impl.KIMPropertyConstants.RoleMember.ROLE_MEMBER_ID, roleMemberId), PredicateFactory.equal(org.kuali.kfs.kim.impl.KIMPropertyConstants.RoleMember.ROLE_MEMBER_ID, "*"))), PredicateFactory.and(PredicateFactory.equal("roleResponsibilityId", "*"), PredicateFactory.equal(KIMPropertyConstants.RoleMember.ROLE_MEMBER_ID, roleMemberId)));
final QueryByCriteria.Builder roleResponsibilityActionQueryBuilder = QueryByCriteria.Builder.create();
roleResponsibilityActionQueryBuilder.setPredicates(roleResponsibilityActionPredicate);
final GenericQueryResults<RoleResponsibilityAction> roleResponsibilityActionResults = criteriaLookupService.lookup(RoleResponsibilityAction.class, roleResponsibilityActionQueryBuilder.build());
final List<RoleResponsibilityAction> roleResponsibilityActions = roleResponsibilityActionResults.getResults();
// seems a little dubious that we are just returning the first result...
if (!roleResponsibilityActions.isEmpty()) {
result = roleResponsibilityActions.get(0);
}
}
return result;
}
Aggregations