View Javadoc
1   /*
2    * Copyright 2007 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.ole.vnd.businessobject.lookup;
17  
18  import java.util.Collections;
19  import java.util.List;
20  import java.util.Map;
21  
22  import org.kuali.ole.sys.OLEConstants;
23  import org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl;
24  import org.kuali.rice.krad.bo.BusinessObject;
25  import org.kuali.rice.krad.util.BeanPropertyComparator;
26  
27  
28  public class VendorAddressLookupableHelperServiceImpl extends KualiLookupableHelperServiceImpl {
29      private boolean searchUsingOnlyPrimaryKeyValues = false;
30  
31      /**
32       * Overrides the default behavior because we need to restrict the search results to the vendor ids that we are sending in as
33       * criteria, but since they are set as hidden in the DD the default behavior is to remove them from the criteria.
34       * 
35       * @see org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl#getSearchResultsHelper(java.util.Map, boolean)
36       */
37      @SuppressWarnings("unchecked")
38      @Override
39      protected List<? extends BusinessObject> getSearchResultsHelper(Map<String, String> fieldValues, boolean unbounded) {
40          searchUsingOnlyPrimaryKeyValues = getLookupService().allPrimaryKeyValuesPresentAndNotWildcard(getBusinessObjectClass(), fieldValues);
41  
42          setBackLocation(fieldValues.get(OLEConstants.BACK_LOCATION));
43          setDocFormKey(fieldValues.get(OLEConstants.DOC_FORM_KEY));
44          setReferencesToRefresh(fieldValues.get(OLEConstants.REFERENCES_TO_REFRESH));
45          List searchResults = (List) getLookupService().findCollectionBySearchHelper(getBusinessObjectClass(), fieldValues, unbounded);
46          // sort list if default sort column given
47          List defaultSortColumns = getDefaultSortColumns();
48          if (defaultSortColumns.size() > 0) {
49              Collections.sort(searchResults, new BeanPropertyComparator(getDefaultSortColumns(), true));
50          }
51  
52          return searchResults;
53      }
54  
55      /**
56       * @see LookupableHelperService#isSearchUsingOnlyPrimaryKeyValues()
57       */
58      @Override
59      public boolean isSearchUsingOnlyPrimaryKeyValues() {
60  
61          return searchUsingOnlyPrimaryKeyValues;
62      }
63  }
64