01: /*
02: * Copyright 2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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.module.vendor.lookup;
17:
18: import java.util.Collections;
19: import java.util.List;
20: import java.util.Map;
21:
22: import org.kuali.core.bo.BusinessObject;
23: import org.kuali.core.bo.user.UniversalUser;
24: import org.kuali.core.lookup.KualiLookupableHelperServiceImpl;
25: import org.kuali.core.util.BeanPropertyComparator;
26: import org.kuali.kfs.KFSConstants;
27:
28: public class VendorAddressLookupableHelperServiceImpl extends
29: KualiLookupableHelperServiceImpl {
30: private boolean searchUsingOnlyPrimaryKeyValues = false;
31:
32: /**
33: * Overrides the default behavior because we need to restrict the search results to the vendor ids that we are sending in as
34: * criteria, but since they are set as hidden in the DD the default behavior is to remove them from the criteria.
35: *
36: * @see org.kuali.core.lookup.KualiLookupableHelperServiceImpl#getSearchResultsHelper(java.util.Map, boolean)
37: */
38: @Override
39: protected List<? extends BusinessObject> getSearchResultsHelper(
40: Map<String, String> fieldValues, boolean unbounded) {
41: searchUsingOnlyPrimaryKeyValues = getLookupService()
42: .allPrimaryKeyValuesPresentAndNotWildcard(
43: getBusinessObjectClass(), fieldValues);
44:
45: setBackLocation(fieldValues.get(KFSConstants.BACK_LOCATION));
46: setDocFormKey(fieldValues.get(KFSConstants.DOC_FORM_KEY));
47: setReferencesToRefresh(fieldValues
48: .get(KFSConstants.REFERENCES_TO_REFRESH));
49: List searchResults;
50: if (UniversalUser.class.equals(getBusinessObjectClass())) {
51: searchResults = (List) getUniversalUserService()
52: .findUniversalUsers(fieldValues);
53: } else if (getUniversalUserService().hasUniversalUserProperty(
54: getBusinessObjectClass(), fieldValues)) {
55: searchResults = (List) getUniversalUserService()
56: .findWithUniversalUserJoin(
57: getBusinessObjectClass(), fieldValues,
58: unbounded);
59: } else {
60: searchResults = (List) getLookupService()
61: .findCollectionBySearchHelper(
62: getBusinessObjectClass(), fieldValues,
63: unbounded);
64: }
65: // sort list if default sort column given
66: List defaultSortColumns = getDefaultSortColumns();
67: if (defaultSortColumns.size() > 0) {
68: Collections.sort(searchResults, new BeanPropertyComparator(
69: getDefaultSortColumns(), true));
70: }
71:
72: return searchResults;
73: }
74:
75: /**
76: * @see LookupableHelperService#isSearchUsingOnlyPrimaryKeyValues()
77: */
78: @Override
79: public boolean isSearchUsingOnlyPrimaryKeyValues() {
80:
81: return searchUsingOnlyPrimaryKeyValues;
82: }
83: }
|