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.module.ld.businessobject.lookup; 017 018 import java.util.Collections; 019 import java.util.List; 020 import java.util.Map; 021 022 import org.kuali.kfs.module.ld.businessobject.inquiry.PositionDataDetailsInquirableImpl; 023 import org.kuali.kfs.module.ld.businessobject.inquiry.PositionDataInquirableImpl; 024 import org.kuali.kfs.sys.KFSConstants; 025 import org.kuali.kfs.sys.KFSPropertyConstants; 026 import org.kuali.rice.kns.bo.BusinessObject; 027 import org.kuali.rice.kns.lookup.AbstractLookupableHelperServiceImpl; 028 import org.kuali.rice.kns.lookup.HtmlData; 029 import org.kuali.rice.kns.lookup.LookupUtils; 030 import org.kuali.rice.kns.util.BeanPropertyComparator; 031 032 /** 033 * The class is the front-end for all position data inquiry processing. 034 */ 035 public class PositionDataLookupableHelperServiceImpl extends AbstractLookupableHelperServiceImpl { 036 037 /** 038 * @see org.kuali.rice.kns.lookup.Lookupable#getInquiryUrl(org.kuali.rice.kns.bo.BusinessObject, java.lang.String) 039 */ 040 @Override 041 public HtmlData getInquiryUrl(BusinessObject businessObject, String propertyName) { 042 if (KFSPropertyConstants.POSITION_NUMBER.equals(propertyName)) { 043 return (new PositionDataDetailsInquirableImpl()).getInquiryUrl(businessObject, propertyName); 044 } 045 return (new PositionDataInquirableImpl()).getInquiryUrl(businessObject, propertyName); 046 } 047 048 /** 049 * @see org.kuali.rice.kns.lookup.AbstractLookupableHelperServiceImpl#getSearchResults(java.util.Map) 050 */ 051 @Override 052 public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) { 053 // remove hidden fields 054 LookupUtils.removeHiddenCriteriaFields(getBusinessObjectClass(), fieldValues); 055 056 setBackLocation(fieldValues.get(KFSConstants.BACK_LOCATION)); 057 setDocFormKey(fieldValues.get(KFSConstants.DOC_FORM_KEY)); 058 setReferencesToRefresh(fieldValues.get(KFSConstants.REFERENCES_TO_REFRESH)); 059 060 List searchResults = (List) getLookupService().findCollectionBySearchHelper(getBusinessObjectClass(), fieldValues, false); 061 // sort list if default sort column given 062 List defaultSortColumns = getDefaultSortColumns(); 063 if (defaultSortColumns.size() > 0) { 064 Collections.sort(searchResults, new BeanPropertyComparator(getDefaultSortColumns(), true)); 065 } 066 return searchResults; 067 } 068 069 }