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