use of org.kuali.kfs.kim.impl.role.RoleResponsibility 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;
}
use of org.kuali.kfs.kim.impl.role.RoleResponsibility in project cu-kfs by CU-CommunityApps.
the class ResponsibilityServiceImpl method getRoleIdsForPredicate.
private List<String> getRoleIdsForPredicate(Predicate p) {
final QueryByCriteria.Builder builder = QueryByCriteria.Builder.create();
builder.setPredicates(p);
final GenericQueryResults<RoleResponsibility> qr = criteriaLookupService.lookup(RoleResponsibility.class, builder.build());
final List<String> roleIds = new ArrayList<>();
for (RoleResponsibility bo : qr.getResults()) {
roleIds.add(bo.getRoleId());
}
return Collections.unmodifiableList(roleIds);
}
use of org.kuali.kfs.kim.impl.role.RoleResponsibility in project cu-kfs by CU-CommunityApps.
the class ResponsibilityInternalServiceImpl method saveRoleMember.
@Override
public RoleMember saveRoleMember(RoleMember roleMember) {
// need to find what responsibilities changed so we can notify interested clients. Like workflow.
List<RoleResponsibility> oldRoleResp = getRoleResponsibilities(roleMember.getRoleId());
// add row to member table
RoleMember member = businessObjectService.save(roleMember);
// need to find what responsibilities changed so we can notify interested clients. Like workflow.
// the new member has been added
List<RoleResponsibility> newRoleResp = getRoleResponsibilities(roleMember.getRoleId());
updateActionRequestsForResponsibilityChange(getChangedRoleResponsibilityIds(oldRoleResp, newRoleResp));
return member;
}
Aggregations