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.HashMap; 020 import java.util.List; 021 import java.util.Map; 022 023 import org.kuali.kfs.module.ld.businessobject.LaborCalculatedSalaryFoundationTracker; 024 import org.kuali.kfs.module.ld.businessobject.inquiry.AbstractLaborInquirableImpl; 025 import org.kuali.kfs.module.ld.businessobject.inquiry.PositionDataDetailsInquirableImpl; 026 import org.kuali.kfs.module.ld.businessobject.inquiry.PositionFundingInquirableImpl; 027 import org.kuali.kfs.sys.KFSConstants; 028 import org.kuali.kfs.sys.KFSPropertyConstants; 029 import org.kuali.rice.kns.bo.BusinessObject; 030 import org.kuali.rice.kns.lookup.AbstractLookupableHelperServiceImpl; 031 import org.kuali.rice.kns.lookup.HtmlData; 032 import org.kuali.rice.kns.lookup.LookupUtils; 033 import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData; 034 import org.kuali.rice.kns.util.BeanPropertyComparator; 035 036 public class PositionFundingLookupableHelperServiceImpl extends AbstractLookupableHelperServiceImpl { 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 LaborCalculatedSalaryFoundationTracker CSFTracker = (LaborCalculatedSalaryFoundationTracker) businessObject; 044 AbstractLaborInquirableImpl positionDataDetailsInquirable = new PositionDataDetailsInquirableImpl(); 045 046 Map<String, String> fieldValues = new HashMap<String, String>(); 047 fieldValues.put(propertyName, CSFTracker.getPositionNumber()); 048 049 BusinessObject positionData = positionDataDetailsInquirable.getBusinessObject(fieldValues); 050 051 return positionData == null ? new AnchorHtmlData(KFSConstants.EMPTY_STRING, KFSConstants.EMPTY_STRING) : positionDataDetailsInquirable.getInquiryUrl(positionData, propertyName); 052 } 053 return (new PositionFundingInquirableImpl()).getInquiryUrl(businessObject, propertyName); 054 } 055 056 /** 057 * @see org.kuali.rice.kns.lookup.AbstractLookupableHelperServiceImpl#getSearchResults(java.util.Map) 058 */ 059 @Override 060 public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) { 061 // remove hidden fields 062 LookupUtils.removeHiddenCriteriaFields(getBusinessObjectClass(), fieldValues); 063 064 setBackLocation(fieldValues.get(KFSConstants.BACK_LOCATION)); 065 setDocFormKey(fieldValues.get(KFSConstants.DOC_FORM_KEY)); 066 setReferencesToRefresh(fieldValues.get(KFSConstants.REFERENCES_TO_REFRESH)); 067 068 List searchResults = (List) getLookupService().findCollectionBySearchHelper(getBusinessObjectClass(), fieldValues, false); 069 // sort list if default sort column given 070 List defaultSortColumns = getDefaultSortColumns(); 071 if (defaultSortColumns.size() > 0) { 072 Collections.sort(searchResults, new BeanPropertyComparator(getDefaultSortColumns(), true)); 073 } 074 return searchResults; 075 } 076 }