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;
}
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);
}
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);
}
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());
}
}
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;
}
Aggregations