Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2005-2012 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
import static org.kuali.rice.core.api.criteria.PredicateFactory.*;
import static org.kuali.rice.core.api.criteria.PredicateFactory.and;
import static org.kuali.rice.core.api.criteria.PredicateFactory.lessThan;

Custom lookupable for the GroupBo lookup to call the group service for searching

Kuali Rice Team (
public class GroupLookupableImpl extends LookupableImpl {
    private static final long serialVersionUID = -3149952849854425077L;

Translates any search criteria on principal name to member id and active data, then calls group service to retrieve matching groups

    protected List<?> getSearchResults(LookupForm formMap<StringStringsearchCriteriaboolean unbounded) {
        Map<StringStringcriteriaMap = new HashMap<StringString>(searchCriteria);
        QueryByCriteria.Builder criteria = QueryByCriteria.Builder.create();
        if (!criteriaMap.isEmpty()) {
            List<Predicatepredicates = new ArrayList<Predicate>();
            //principalId doesn't exist on 'Group'.  Lets do this predicate conversion separately
            if (StringUtils.isNotBlank(criteriaMap.get(..))) {
                String principalId = KimApiServiceLocator.getIdentityService().getPrincipalByPrincipalName(
                Timestamp currentTime = new Timestamp(Calendar.getInstance().getTimeInMillis());
                predicates.add(and(equal("members.memberId"principalId), equal("members.typeCode",
                        ...getCode()), and(or(isNull(
                        "members.activeFromDateValue"), greaterThanOrEqual("members.activeFromDateValue"currentTime)),
                        or(isNull("members.activeToDateValue"), lessThan("members.activeToDateValue"currentTime)))));
            criteria.setPredicates(and(predicates.toArray(new Predicate[predicates.size()])));
        GroupQueryResults groupResults = getGroupService().findGroups(;
        List<Groupgroups = groupResults.getResults();
        //have to convert back to Bos :(
        List<GroupBogroupBos = new ArrayList<GroupBo>(groups.size());
        for (Group group : groups) {
        return groupBos;
    public GroupService getGroupService() {
        return KimApiServiceLocator.getGroupService();
New to GrepCode? Check out our FAQ X