001/*
002 * Copyright 2007 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 */
016package org.kuali.ole.vnd.businessobject.lookup;
017
018import java.util.Collections;
019import java.util.List;
020import java.util.Map;
021
022import org.kuali.ole.sys.OLEConstants;
023import org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl;
024import org.kuali.rice.krad.bo.BusinessObject;
025import org.kuali.rice.krad.util.BeanPropertyComparator;
026
027
028public 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(OLEConstants.BACK_LOCATION));
042        setDocFormKey(fieldValues.get(OLEConstants.DOC_FORM_KEY));
043        setReferencesToRefresh(fieldValues.get(OLEConstants.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