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.Collection; 019 import java.util.Collections; 020 import java.util.HashMap; 021 import java.util.List; 022 import java.util.Map; 023 024 import org.kuali.kfs.module.ld.businessobject.LaborCalculatedSalaryFoundationTracker; 025 import org.kuali.kfs.module.ld.businessobject.inquiry.AbstractLaborInquirableImpl; 026 import org.kuali.kfs.module.ld.businessobject.inquiry.LaborCalculatedSalaryFoundationTrackerInquirableImpl; 027 import org.kuali.kfs.module.ld.businessobject.inquiry.PositionDataDetailsInquirableImpl; 028 import org.kuali.kfs.module.ld.service.LaborCalculatedSalaryFoundationTrackerService; 029 import org.kuali.kfs.sys.KFSConstants; 030 import org.kuali.kfs.sys.KFSPropertyConstants; 031 import org.kuali.rice.kns.bo.BusinessObject; 032 import org.kuali.rice.kns.lookup.AbstractLookupableHelperServiceImpl; 033 import org.kuali.rice.kns.lookup.CollectionIncomplete; 034 import org.kuali.rice.kns.lookup.HtmlData; 035 import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData; 036 import org.kuali.rice.kns.util.BeanPropertyComparator; 037 038 /** 039 * The CSFTrackerBalanceLookupableHelperServiceImpl class is the front-end for all Calculated Salary Foundation balance inquiry 040 * processing. 041 */ 042 043 public class LaborCalculatedSalaryFoundationTrackerLookupableHelperServiceImpl extends AbstractLookupableHelperServiceImpl { 044 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(LaborCalculatedSalaryFoundationTrackerLookupableHelperServiceImpl.class); 045 046 private LaborCalculatedSalaryFoundationTrackerService laborCalculatedSalaryFoundationTrackerService; 047 048 /** 049 * @see org.kuali.rice.kns.lookup.AbstractLookupableHelperServiceImpl#getInquiryUrl(org.kuali.rice.kns.bo.BusinessObject, 050 * java.lang.String) 051 */ 052 @Override 053 public HtmlData getInquiryUrl(BusinessObject bo, String propertyName) { 054 if (KFSPropertyConstants.POSITION_NUMBER.equals(propertyName)) { 055 LaborCalculatedSalaryFoundationTracker CSFTracker = (LaborCalculatedSalaryFoundationTracker) bo; 056 AbstractLaborInquirableImpl positionDataDetailsInquirable = new PositionDataDetailsInquirableImpl(); 057 058 Map<String, String> fieldValues = new HashMap<String, String>(); 059 fieldValues.put(propertyName, CSFTracker.getPositionNumber()); 060 061 BusinessObject positionData = positionDataDetailsInquirable.getBusinessObject(fieldValues); 062 063 return positionData == null ? new AnchorHtmlData(KFSConstants.EMPTY_STRING, KFSConstants.EMPTY_STRING) : positionDataDetailsInquirable.getInquiryUrl(positionData, propertyName); 064 } 065 return (new LaborCalculatedSalaryFoundationTrackerInquirableImpl()).getInquiryUrl(bo, propertyName); 066 } 067 068 /** 069 * @see org.kuali.rice.kns.lookup.AbstractLookupableHelperServiceImpl#getSearchResults(java.util.Map) 070 */ 071 @Override 072 public List getSearchResults(Map fieldValues) { 073 setBackLocation((String) fieldValues.get(KFSConstants.BACK_LOCATION)); 074 setDocFormKey((String) fieldValues.get(KFSConstants.DOC_FORM_KEY)); 075 076 Collection searchResultsCollection = laborCalculatedSalaryFoundationTrackerService.findCSFTrackerWithJuly1(fieldValues, false); 077 078 return new CollectionIncomplete(searchResultsCollection, new Long(searchResultsCollection.size())); 079 } 080 081 /** 082 * build the serach result list from the given collection and the number of all qualified search results 083 * 084 * @param searchResultsCollection the given search results, which may be a subset of the qualified search results 085 * @param actualSize the number of all qualified search results 086 * @return the serach result list with the given results and actual size 087 */ 088 protected List buildSearchResultList(Collection searchResultsCollection, Long actualSize) { 089 CollectionIncomplete results = new CollectionIncomplete(searchResultsCollection, actualSize); 090 091 // sort list if default sort column given 092 List searchResults = (List) results; 093 List defaultSortColumns = getDefaultSortColumns(); 094 if (defaultSortColumns.size() > 0) { 095 Collections.sort(results, new BeanPropertyComparator(defaultSortColumns, true)); 096 } 097 return searchResults; 098 } 099 100 /** 101 * Sets the laborCalculatedSalaryFoundationTrackerService attribute value. 102 * 103 * @param laborCalculatedSalaryFoundationTrackerService The laborCalculatedSalaryFoundationTrackerService to set. 104 */ 105 public void setLaborCalculatedSalaryFoundationTrackerService(LaborCalculatedSalaryFoundationTrackerService laborCalculatedSalaryFoundationTrackerService) { 106 this.laborCalculatedSalaryFoundationTrackerService = laborCalculatedSalaryFoundationTrackerService; 107 } 108 }