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.List;
020: import java.util.Map;
021:
022: import org.kuali.kfs.KFSConstants;
023: import org.kuali.kfs.KFSPropertyConstants;
024: import org.kuali.kfs.bo.Options;
025: import org.kuali.kfs.service.OptionsService;
026: import org.kuali.module.gl.util.OJBUtility;
027: import org.kuali.module.gl.web.Constant;
028: import org.kuali.module.labor.LaborPropertyConstants;
029: import org.kuali.module.labor.LaborConstants.BenefitExpenseTransfer;
030: import org.kuali.module.labor.bo.LedgerBalance;
031: import org.kuali.module.labor.util.ConsolidationUtil;
032: import org.springframework.transaction.annotation.Transactional;
033:
034: /**
035: * The class is the front-end for the balance inquiry of Ledger Balance For Benefit Expense Transfer processing.
036: */
037: @Transactional
038: public class LedgerBalanceForBenefitExpenseTransferLookupableHelperServiceImpl
039: extends
040: LedgerBalanceForExpenseTransferLookupableHelperServiceImpl {
041: private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
042: .getLogger(LedgerBalanceForBenefitExpenseTransferLookupableHelperServiceImpl.class);
043:
044: private OptionsService optionsService;
045:
046: /**
047: * @see org.kuali.core.lookup.Lookupable#getSearchResults(java.util.Map)
048: */
049: @Override
050: public List getSearchResults(Map fieldValues) {
051: LOG.info("Start getSearchResults()");
052:
053: setBackLocation((String) fieldValues
054: .get(KFSConstants.BACK_LOCATION));
055: setDocFormKey((String) fieldValues
056: .get(KFSConstants.DOC_FORM_KEY));
057:
058: String fiscalYearString = (String) fieldValues
059: .get(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR);
060: Options options = this .getOptions(fiscalYearString);
061:
062: fieldValues.put(
063: KFSPropertyConstants.FINANCIAL_OBJECT_TYPE_CODE,
064: options.getFinObjTypeExpenditureexpCd());
065: fieldValues
066: .put(
067: LaborPropertyConstants.LABOR_OBJECT
068: + "."
069: + LaborPropertyConstants.FINANCIAL_OBJECT_FRINGE_OR_SALARY_CODE,
070: BenefitExpenseTransfer.LABOR_LEDGER_BENEFIT_CODE);
071:
072: // get the ledger balances with actual balance type code
073: fieldValues.put(
074: KFSPropertyConstants.FINANCIAL_BALANCE_TYPE_CODE,
075: options.getActualFinancialBalanceTypeCd());
076: Collection actualBalances = buildDetailedBalanceCollection(
077: getBalanceService().findBalance(fieldValues, false),
078: Constant.NO_PENDING_ENTRY);
079:
080: // get the ledger balances with effort balance type code
081: fieldValues.put(
082: KFSPropertyConstants.FINANCIAL_BALANCE_TYPE_CODE,
083: KFSConstants.BALANCE_TYPE_A21);
084: Collection effortBalances = buildDetailedBalanceCollection(
085: getBalanceService().findBalance(fieldValues, false),
086: Constant.NO_PENDING_ENTRY);
087:
088: Collection<LedgerBalance> consolidatedBalances = ConsolidationUtil
089: .consolidateA2Balances(actualBalances, effortBalances,
090: options.getActualFinancialBalanceTypeCd());
091:
092: Integer recordCount = getBalanceService()
093: .getBalanceRecordCount(fieldValues, true);
094: Long actualSize = OJBUtility.getResultActualSize(
095: consolidatedBalances, recordCount, fieldValues,
096: new LedgerBalance());
097:
098: return buildSearchResultList(consolidatedBalances, actualSize);
099: }
100:
101: /**
102: * get the Options object for the given fiscal year
103: *
104: * @param fiscalYearString the given fiscal year
105: * @return the Options object for the given fiscal year
106: */
107: private Options getOptions(String fiscalYearString) {
108: Options options;
109: if (fiscalYearString == null) {
110: options = optionsService.getCurrentYearOptions();
111: } else {
112: Integer fiscalYear = Integer.valueOf(fiscalYearString
113: .trim());
114: options = optionsService.getOptions(fiscalYear);
115: }
116: return options;
117: }
118:
119: /**
120: * Sets the optionsService attribute value.
121: *
122: * @param optionsService The optionsService to set.
123: */
124: public void setOptionsService(OptionsService optionsService) {
125: this.optionsService = optionsService;
126: }
127: }
|