001 /* 002 * Copyright 2011 The Kuali Foundation. 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.kfs.vnd.businessobject.lookup; 017 018 import java.util.Collections; 019 import java.util.List; 020 import java.util.Map; 021 022 import org.kuali.kfs.sys.KFSConstants; 023 import org.kuali.rice.kns.bo.BusinessObject; 024 import org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl; 025 import org.kuali.rice.kns.util.BeanPropertyComparator; 026 027 028 public class VendorCustomerNumberLookupableHelperServiceImpl extends KualiLookupableHelperServiceImpl { 029 private boolean searchUsingOnlyPrimaryKeyValues = false; 030 031 /** 032 * Overrides the getSearchResultsHelper in the super class so that we can do some customization 033 * 034 * @see org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl#getSearchResultsHelper(java.util.Map, boolean) 035 */ 036 @SuppressWarnings("unchecked") 037 @Override 038 protected List<? extends BusinessObject> getSearchResultsHelper(Map<String, String> fieldValues, boolean unbounded) { 039 searchUsingOnlyPrimaryKeyValues = getLookupService().allPrimaryKeyValuesPresentAndNotWildcard(getBusinessObjectClass(), fieldValues); 040 041 setBackLocation(fieldValues.get(KFSConstants.BACK_LOCATION)); 042 setDocFormKey(fieldValues.get(KFSConstants.DOC_FORM_KEY)); 043 setReferencesToRefresh(fieldValues.get(KFSConstants.REFERENCES_TO_REFRESH)); 044 List searchResults = (List) getLookupService().findCollectionBySearchHelper(getBusinessObjectClass(), fieldValues, unbounded); 045 // sort list if default sort column given 046 List defaultSortColumns = getDefaultSortColumns(); 047 if (defaultSortColumns.size() > 0) { 048 Collections.sort(searchResults, new BeanPropertyComparator(getDefaultSortColumns(), true)); 049 } 050 051 return searchResults; 052 } 053 054 /** 055 * @see LookupableHelperService#isSearchUsingOnlyPrimaryKeyValues() 056 */ 057 @Override 058 public boolean isSearchUsingOnlyPrimaryKeyValues() { 059 060 return searchUsingOnlyPrimaryKeyValues; 061 } 062 } 063