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 VendorCustomerNumberLookupableHelperServiceImpl extends
29: KualiLookupableHelperServiceImpl {
30: private boolean searchUsingOnlyPrimaryKeyValues = false;
31:
32: /**
33: * Overrides the getSearchResultsHelper in the super class so that we can do some customization
34: *
35: * @see org.kuali.core.lookup.KualiLookupableHelperServiceImpl#getSearchResultsHelper(java.util.Map, boolean)
36: */
37: @Override
38: protected List<? extends BusinessObject> getSearchResultsHelper(
39: Map<String, String> fieldValues, boolean unbounded) {
40: searchUsingOnlyPrimaryKeyValues = getLookupService()
41: .allPrimaryKeyValuesPresentAndNotWildcard(
42: getBusinessObjectClass(), fieldValues);
43:
44: setBackLocation(fieldValues.get(KFSConstants.BACK_LOCATION));
45: setDocFormKey(fieldValues.get(KFSConstants.DOC_FORM_KEY));
46: setReferencesToRefresh(fieldValues
47: .get(KFSConstants.REFERENCES_TO_REFRESH));
48: List searchResults;
49: if (UniversalUser.class.equals(getBusinessObjectClass())) {
50: searchResults = (List) getUniversalUserService()
51: .findUniversalUsers(fieldValues);
52: } else if (getUniversalUserService().hasUniversalUserProperty(
53: getBusinessObjectClass(), fieldValues)) {
54: searchResults = (List) getUniversalUserService()
55: .findWithUniversalUserJoin(
56: getBusinessObjectClass(), fieldValues,
57: unbounded);
58: } else {
59: searchResults = (List) getLookupService()
60: .findCollectionBySearchHelper(
61: getBusinessObjectClass(), fieldValues,
62: unbounded);
63: }
64: // sort list if default sort column given
65: List defaultSortColumns = getDefaultSortColumns();
66: if (defaultSortColumns.size() > 0) {
67: Collections.sort(searchResults, new BeanPropertyComparator(
68: getDefaultSortColumns(), true));
69: }
70:
71: return searchResults;
72: }
73:
74: /**
75: * @see LookupableHelperService#isSearchUsingOnlyPrimaryKeyValues()
76: */
77: @Override
78: public boolean isSearchUsingOnlyPrimaryKeyValues() {
79:
80: return searchUsingOnlyPrimaryKeyValues;
81: }
82: }
|