001: /*
002: * Copyright 2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.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/ecl1.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.module.labor.web.lookupable;
017:
018: import java.util.Collection;
019: import java.util.Collections;
020: import java.util.List;
021: import java.util.Map;
022:
023: import org.kuali.core.bo.BusinessObject;
024: import org.kuali.core.lookup.AbstractLookupableHelperServiceImpl;
025: import org.kuali.core.lookup.CollectionIncomplete;
026: import org.kuali.core.util.BeanPropertyComparator;
027: import org.kuali.core.web.ui.Row;
028: import org.kuali.kfs.KFSConstants;
029: import org.kuali.module.labor.service.LaborBaseFundsService;
030: import org.kuali.module.labor.service.LaborInquiryOptionsService;
031: import org.kuali.module.labor.web.inquirable.BaseFundsInquirableImpl;
032: import org.springframework.transaction.annotation.Transactional;
033:
034: /**
035: * The BaseFundsLookupableHelperServiceImpl class is the front-end for all Base Fund balance inquiry processing.
036: */
037: @Transactional
038: public class BaseFundsLookupableHelperServiceImpl extends
039: AbstractLookupableHelperServiceImpl {
040: private static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory
041: .getLog(BaseFundsLookupableHelperServiceImpl.class);
042:
043: private LaborBaseFundsService laborBaseFundsService;
044: private LaborInquiryOptionsService laborInquiryOptionsService;
045:
046: /**
047: * @see org.kuali.core.lookup.Lookupable#getInquiryUrl(org.kuali.core.bo.BusinessObject, java.lang.String)
048: */
049: @Override
050: public String getInquiryUrl(BusinessObject bo, String propertyName) {
051: return (new BaseFundsInquirableImpl()).getInquiryUrl(bo,
052: propertyName);
053: }
054:
055: /**
056: * @see org.kuali.core.lookup.Lookupable#getSearchResults(java.util.Map)
057: */
058: @Override
059: public List getSearchResults(Map fieldValues) {
060: setBackLocation((String) fieldValues
061: .get(KFSConstants.BACK_LOCATION));
062: setDocFormKey((String) fieldValues
063: .get(KFSConstants.DOC_FORM_KEY));
064:
065: // test if the consolidation option is selected or not
066: boolean isConsolidated = laborInquiryOptionsService
067: .isConsolidationSelected(fieldValues,
068: (Collection<Row>) getRows());
069:
070: Collection searchResultsCollection = laborBaseFundsService
071: .findAccountStatusBaseFundsWithCSFTracker(fieldValues,
072: isConsolidated);
073:
074: // get the actual size of all qualified search results
075: Long actualSize = new Long(searchResultsCollection.size());
076:
077: return this .buildSearchResultList(searchResultsCollection,
078: actualSize);
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(
089: Collection searchResultsCollection, Long actualSize) {
090: CollectionIncomplete results = new CollectionIncomplete(
091: searchResultsCollection, actualSize);
092:
093: // sort list if default sort column given
094: List searchResults = (List) results;
095: List defaultSortColumns = getDefaultSortColumns();
096: if (defaultSortColumns.size() > 0) {
097: Collections.sort(results, new BeanPropertyComparator(
098: defaultSortColumns, true));
099: }
100: return searchResults;
101: }
102:
103: /**
104: * Sets the laborInquiryOptionsService attribute value.
105: *
106: * @param laborInquiryOptionsService The laborInquiryOptionsService to set.
107: */
108: public void setLaborInquiryOptionsService(
109: LaborInquiryOptionsService laborInquiryOptionsService) {
110: this .laborInquiryOptionsService = laborInquiryOptionsService;
111: }
112:
113: /**
114: * Sets the laborBaseFundsService attribute value.
115: *
116: * @param laborBaseFundsService The laborBaseFundsService to set.
117: */
118: public void setLaborBaseFundsService(
119: LaborBaseFundsService laborBaseFundsService) {
120: this.laborBaseFundsService = laborBaseFundsService;
121: }
122: }
|