View Javadoc

1   /**
2    * Copyright 2005-2011 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kim.impl.identity;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.kuali.rice.core.api.criteria.Predicate;
20  import org.kuali.rice.core.api.criteria.PredicateUtils;
21  import org.kuali.rice.core.api.criteria.QueryByCriteria;
22  import org.kuali.rice.kim.api.KimConstants;
23  import org.kuali.rice.kim.api.group.Group;
24  import org.kuali.rice.kim.api.group.GroupQueryResults;
25  import org.kuali.rice.kim.api.group.GroupService;
26  import org.kuali.rice.kim.api.identity.PersonService;
27  import org.kuali.rice.kim.api.services.KimApiServiceLocator;
28  import org.kuali.rice.kim.impl.KIMPropertyConstants;
29  import org.kuali.rice.kim.impl.group.GroupBo;
30  import org.kuali.rice.krad.lookup.LookupableImpl;
31  import org.kuali.rice.krad.web.form.LookupForm;
32  
33  import java.sql.Timestamp;
34  import java.util.ArrayList;
35  import java.util.Calendar;
36  import java.util.HashMap;
37  import java.util.List;
38  import java.util.Map;
39  
40  import static org.kuali.rice.core.api.criteria.PredicateFactory.*;
41  
42  /**
43   * Custom lookupable for the {@link PersonImpl} lookup to call the person service for searching
44   *
45   * @author Kuali Rice Team (rice.collab@kuali.org)
46   */
47  public class PersonLookupableImpl extends LookupableImpl {
48      private static final long serialVersionUID = -3149952849854425077L;
49  
50      /**
51       * Lower cases criteria on principal name and calls the person service to carry out the search
52       *
53       * @return List<PersonImpl>
54       */
55      @Override
56      protected List<?> getSearchResults(LookupForm form, Map<String, String> searchCriteria, boolean unbounded) {
57          // lower case principal name
58          if (searchCriteria != null && StringUtils.isNotEmpty(searchCriteria.get(
59                  KIMPropertyConstants.Person.PRINCIPAL_NAME))) {
60              searchCriteria.put(KIMPropertyConstants.Person.PRINCIPAL_NAME, searchCriteria.get(
61                      KIMPropertyConstants.Person.PRINCIPAL_NAME).toLowerCase());
62          }
63  
64          return getPersonService().findPeople(searchCriteria, unbounded);
65      }
66  
67      public PersonService getPersonService() {
68          return KimApiServiceLocator.getPersonService();
69      }
70  }