View Javadoc
1   /**
2    * Copyright 2005-2016 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.kim.api.identity.PersonService;
20  import org.kuali.rice.kim.api.services.KimApiServiceLocator;
21  import org.kuali.rice.kim.impl.KIMPropertyConstants;
22  import org.kuali.rice.krad.lookup.LookupableImpl;
23  import org.kuali.rice.krad.lookup.LookupForm;
24  
25  import java.util.Collection;
26  import java.util.List;
27  import java.util.Map;
28  
29  /**
30   * Custom lookupable for the {@link PersonImpl} lookup to call the person service for searching
31   *
32   * @author Kuali Rice Team (rice.collab@kuali.org)
33   */
34  public class PersonLookupableImpl extends LookupableImpl {
35      private static final long serialVersionUID = -3149952849854425077L;
36  
37      /**
38       * Lower cases criteria on principal name and calls the person service to carry out the search
39       *
40       * @return List<PersonImpl>
41       */
42      @Override
43      protected Collection<?> executeSearch(Map<String, String> adjustedSearchCriteria,
44                  List<String> wildcardAsLiteralSearchCriteria, boolean bounded, Integer searchResultsLimit) {
45          // lower case principal name
46          if (adjustedSearchCriteria != null && StringUtils.isNotEmpty(adjustedSearchCriteria.get(
47                  KIMPropertyConstants.Person.PRINCIPAL_NAME))) {
48              adjustedSearchCriteria.put(KIMPropertyConstants.Person.PRINCIPAL_NAME, adjustedSearchCriteria.get(
49                      KIMPropertyConstants.Person.PRINCIPAL_NAME).toLowerCase());
50          }
51  
52          return getPersonService().findPeople(adjustedSearchCriteria, !bounded);
53      }
54  
55      public PersonService getPersonService() {
56          return KimApiServiceLocator.getPersonService();
57      }
58  }