Search in sources :

Example 1 with MemberType

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);
}
Also used : KimAttributeData(org.kuali.kfs.kim.impl.common.attribute.KimAttributeData) KimApiServiceLocator(org.kuali.kfs.kim.api.services.KimApiServiceLocator) Predicate(org.apache.commons.collections4.Predicate) Cacheable(org.springframework.cache.annotation.Cacheable) GenericQueryResults(org.kuali.kfs.core.api.criteria.GenericQueryResults) CacheEvict(org.springframework.cache.annotation.CacheEvict) HashMap(java.util.HashMap) StringUtils(org.apache.commons.lang3.StringUtils) CollectionUtils(org.apache.commons.collections4.CollectionUtils) KIMPropertyConstants(org.kuali.kfs.kim.impl.KIMPropertyConstants) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) QueryByCriteria(org.kuali.kfs.core.api.criteria.QueryByCriteria) Map(java.util.Map) GroupService(org.kuali.kfs.kim.api.group.GroupService) AttributeTransform(org.kuali.kfs.kim.impl.common.attribute.AttributeTransform) MemberType(org.kuali.kfs.core.api.membership.MemberType) Role(org.kuali.kfs.kim.impl.role.Role) KimConstants(org.kuali.kfs.kim.api.KimConstants) Timestamp(java.sql.Timestamp) Collection(java.util.Collection) KimImplServiceLocator(org.kuali.kfs.kim.impl.services.KimImplServiceLocator) Set(java.util.Set) LookupCustomizer(org.kuali.kfs.core.api.criteria.LookupCustomizer) Collectors(java.util.stream.Collectors) Date(java.sql.Date) PredicateFactory(org.kuali.kfs.core.api.criteria.PredicateFactory) List(java.util.List) Logger(org.apache.logging.log4j.Logger) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) CriteriaLookupService(org.kuali.kfs.core.api.criteria.CriteriaLookupService) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Date(java.sql.Date)

Aggregations

Date (java.sql.Date)1 Timestamp (java.sql.Timestamp)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 CollectionUtils (org.apache.commons.collections4.CollectionUtils)1 Predicate (org.apache.commons.collections4.Predicate)1 StringUtils (org.apache.commons.lang3.StringUtils)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1 CriteriaLookupService (org.kuali.kfs.core.api.criteria.CriteriaLookupService)1 GenericQueryResults (org.kuali.kfs.core.api.criteria.GenericQueryResults)1 LookupCustomizer (org.kuali.kfs.core.api.criteria.LookupCustomizer)1 PredicateFactory (org.kuali.kfs.core.api.criteria.PredicateFactory)1