View Javadoc
1   /**
2    * Copyright 2005-2014 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.krad.demo.uif.lookup;
17  
18  import org.apache.commons.collections.MapUtils;
19  import org.kuali.rice.kim.impl.KIMPropertyConstants;
20  import org.kuali.rice.kim.impl.group.GroupBo;
21  import org.kuali.rice.kim.impl.identity.principal.PrincipalBo;
22  import org.kuali.rice.kim.impl.role.RoleBo;
23  import org.kuali.rice.krad.lookup.LookupUtils;
24  import org.kuali.rice.krad.lookup.LookupableImpl;
25  import org.kuali.rice.krad.lookup.LookupForm;
26  
27  import java.util.Collection;
28  import java.util.List;
29  import java.util.Map;
30  
31  /**
32   * @author Kuali Rice Team (rice.collab@kuali.org)
33   */
34  public class UIRoleMemberLookupableImpl extends LookupableImpl {
35  
36      @Override
37      public Collection<?> performSearch(LookupForm form, Map<String, String> searchCriteria, boolean bounded) {
38          // removed blank search values and decrypt any encrypted search values
39          Map<String, String> nonBlankSearchCriteria = processSearchCriteria(form, searchCriteria);
40          List<String> wildcardAsLiteralSearchCriteria = identifyWildcardDisabledFields(form, nonBlankSearchCriteria);
41  
42          Integer searchResultsLimit = null;
43  
44          if (bounded) {
45              searchResultsLimit = LookupUtils.getSearchResultsLimit(getDataObjectClass(), form);
46          }
47  
48          Class<?> dataObjectClass = null;
49  
50          if ("P".equals(MapUtils.getString(searchCriteria, KIMPropertyConstants.KimMember.MEMBER_TYPE_CODE))) {
51              dataObjectClass = PrincipalBo.class;
52          } else if ("G".equals(MapUtils.getString(searchCriteria, KIMPropertyConstants.KimMember.MEMBER_TYPE_CODE))) {
53              dataObjectClass = GroupBo.class;
54          } else if ("R".equals(MapUtils.getString(searchCriteria, KIMPropertyConstants.KimMember.MEMBER_TYPE_CODE))) {
55              dataObjectClass = RoleBo.class;
56          }
57  
58          return getLookupService().findCollectionBySearchHelper(dataObjectClass, nonBlankSearchCriteria,
59                  wildcardAsLiteralSearchCriteria, !bounded, searchResultsLimit);
60      }
61  }