/*
* The Kuali Financial System, a comprehensive financial management system for higher education.
*
* Copyright 2005-2014 The Kuali Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.kuali.kfs.module.ld.businessobject.lookup;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.kuali.kfs.module.ld.businessobject.inquiry.BaseFundsInquirableImpl;
import org.kuali.kfs.module.ld.service.LaborBaseFundsService;
import org.kuali.kfs.module.ld.service.LaborInquiryOptionsService;
import org.kuali.kfs.sys.KFSConstants;
import org.kuali.rice.kns.lookup.AbstractLookupableHelperServiceImpl;
import org.kuali.rice.kns.lookup.HtmlData;
import org.kuali.rice.kns.web.ui.Row;
import org.kuali.rice.krad.bo.BusinessObject;
import org.kuali.rice.krad.lookup.CollectionIncomplete;
import org.kuali.rice.krad.util.BeanPropertyComparator;
/**
* The BaseFundsLookupableHelperServiceImpl class is the front-end for all Base Fund balance inquiry processing.
*/
public class BaseFundsLookupableHelperServiceImpl extends AbstractLookupableHelperServiceImpl {
private static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory.getLog(BaseFundsLookupableHelperServiceImpl.class);
private LaborBaseFundsService laborBaseFundsService;
private LaborInquiryOptionsService laborInquiryOptionsService;
/**
* @see org.kuali.rice.kns.lookup.Lookupable#getInquiryUrl(org.kuali.rice.krad.bo.BusinessObject, java.lang.String)
*/
@Override
public HtmlData getInquiryUrl(BusinessObject bo, String propertyName) {
return (new BaseFundsInquirableImpl()).getInquiryUrl(bo, propertyName);
}
/**
* @see org.kuali.rice.kns.lookup.Lookupable#getSearchResults(java.util.Map)
*
* KRAD Conversion: Lookupable performs customization of the search results.
*
* No uses data dictionary.
*/
@Override
public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) {
setBackLocation((String) fieldValues.get(KFSConstants.BACK_LOCATION));
setDocFormKey((String) fieldValues.get(KFSConstants.DOC_FORM_KEY));
// test if the consolidation option is selected or not
boolean isConsolidated = laborInquiryOptionsService.isConsolidationSelected(fieldValues, (Collection<Row>) getRows());
Collection searchResultsCollection = laborBaseFundsService.findAccountStatusBaseFundsWithCSFTracker(fieldValues, isConsolidated);
// get the actual size of all qualified search results
Long actualSize = new Long(searchResultsCollection.size());
return this.buildSearchResultList(searchResultsCollection, actualSize);
}
/**
* build the serach result list from the given collection and the number of all qualified search results
*
* @param searchResultsCollection the given search results, which may be a subset of the qualified search results
* @param actualSize the number of all qualified search results
* @return the serach result list with the given results and actual size
*/
protected List buildSearchResultList(Collection searchResultsCollection, Long actualSize) {
CollectionIncomplete results = new CollectionIncomplete(searchResultsCollection, actualSize);
// sort list if default sort column given
List searchResults = (List) results;
List defaultSortColumns = getDefaultSortColumns();
if (defaultSortColumns.size() > 0) {
Collections.sort(results, new BeanPropertyComparator(defaultSortColumns, true));
}
return searchResults;
}
/**
* Sets the laborInquiryOptionsService attribute value.
*
* @param laborInquiryOptionsService The laborInquiryOptionsService to set.
*/
public void setLaborInquiryOptionsService(LaborInquiryOptionsService laborInquiryOptionsService) {
this.laborInquiryOptionsService = laborInquiryOptionsService;
}
/**
* Sets the laborBaseFundsService attribute value.
*
* @param laborBaseFundsService The laborBaseFundsService to set.
*/
public void setLaborBaseFundsService(LaborBaseFundsService laborBaseFundsService) {
this.laborBaseFundsService = laborBaseFundsService;
}
}