use of org.kuali.kfs.core.api.membership.MemberType in project cu-kfs by CU-CommunityApps.
the class GroupServiceImpl method getActiveGroupMembers.
/**
* This helper method gets the active group members of the specified type
* (@see {@link KimConstants.KimGroupMemberTypes}). If the optional params are null, it will return all active
* members for the specified group regardless of type.
*
* @param parentId
* @param childId optional, but if provided then memberType must be too
* @param memberType optional, but must be provided if childId is
* @return a list of group members
*/
private List<GroupMember> getActiveGroupMembers(String parentId, String childId, MemberType memberType) {
final Date today = new Date(System.currentTimeMillis());
if (childId != null && memberType == null) {
throw new RuntimeException("memberType must be non-null if childId is non-null");
}
Map<String, Object> criteria = new HashMap<>(4);
criteria.put(KIMPropertyConstants.GroupMember.GROUP_ID, parentId);
if (childId != null) {
criteria.put(KIMPropertyConstants.GroupMember.MEMBER_ID, childId);
criteria.put(KIMPropertyConstants.GroupMember.MEMBER_TYPE_CODE, memberType.getCode());
}
Collection<GroupMember> groupMembers = this.businessObjectService.findMatching(GroupMember.class, criteria);
CollectionUtils.filter(groupMembers, (Predicate) object -> {
GroupMember member = (GroupMember) object;
return member.getActiveToDate() == null || today.before(member.getActiveToDate().toDate());
});
return new ArrayList<>(groupMembers);
}
Aggregations