001: /*
002: * Copyright 2005-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.chart.service.impl;
017:
018: import java.util.ArrayList;
019: import java.util.Collection;
020: import java.util.List;
021:
022: import org.kuali.core.util.spring.Cached;
023: import org.kuali.kfs.bo.Options;
024: import org.kuali.kfs.dao.OptionsDao;
025: import org.kuali.kfs.service.KualiCodeService;
026: import org.kuali.module.chart.bo.codes.BalanceTyp;
027: import org.kuali.module.chart.dao.BalanceTypeDao;
028: import org.kuali.module.chart.service.BalanceTypService;
029: import org.kuali.module.financial.service.UniversityDateService;
030: import org.springframework.transaction.annotation.Transactional;
031:
032: /**
033: * This service implementation is the default implementation of the BalanceTyp service that is delivered with Kuali. It uses the
034: * balance types that are defined in the Kuali database.
035: */
036: @Transactional
037: public class BalanceTypServiceImpl implements BalanceTypService {
038: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
039: .getLogger(BalanceTypServiceImpl.class);
040:
041: // balance type constants
042: private static final String ACTUAL_BALANCE_TYPE = "AC";
043:
044: private KualiCodeService kualiCodeService;
045: private BalanceTypeDao balanceTypeDao;
046:
047: private UniversityDateService universityDateService;
048: private OptionsDao optionsDao;
049:
050: /**
051: * @see org.kuali.module.chart.service.BalanceTypService#getActualBalanceTyp()
052: */
053: public BalanceTyp getActualBalanceTyp() {
054: return getBalanceTypByCode(ACTUAL_BALANCE_TYPE);
055: }
056:
057: /**
058: * @see org.kuali.module.chart.service.BalanceTypService#getEncumbranceBalanceTypes()
059: */
060: public Collection getEncumbranceBalanceTypes() {
061: LOG.debug("getEncumbranceBalanceTypes() started");
062:
063: return balanceTypeDao.getEncumbranceBalanceTypes();
064: }
065:
066: /**
067: * This method retrieves a BalanceTyp instance from the Kuali database by its primary key - the balance typ's code.
068: *
069: * @param code The primary key in the database for this data type.
070: * @return A fully populated object instance.
071: */
072: @Cached
073: public BalanceTyp getBalanceTypByCode(String code) {
074: return (BalanceTyp) kualiCodeService.getByCode(
075: BalanceTyp.class, code);
076: }
077:
078: /**
079: * @see org.kuali.module.chart.service.BalanceTypService#getAllBalanceTyps()
080: */
081: @Cached
082: public Collection getAllBalanceTyps() {
083: return kualiCodeService.getAll(BalanceTyp.class);
084: }
085:
086: /**
087: *
088: * This method injects the KualiCodeService
089: * @param kualiCodeService
090: */
091: public void setKualiCodeService(KualiCodeService kualiCodeService) {
092: this .kualiCodeService = kualiCodeService;
093: }
094:
095: /**
096: *
097: * This method injects the BalanceTypeDao
098: * @param balanceTypeDao
099: */
100: public void setBalanceTypeDao(BalanceTypeDao balanceTypeDao) {
101: this .balanceTypeDao = balanceTypeDao;
102: }
103:
104: /**
105: *
106: * This method injects the UniversityDateService
107: * @param universityDateService
108: */
109: public void setUniversityDateService(
110: UniversityDateService universityDateService) {
111: this .universityDateService = universityDateService;
112: }
113:
114: /**
115: *
116: * This method injects the OptionsDao
117: * @param optionsDao
118: */
119: public void setOptionsDao(OptionsDao optionsDao) {
120: this .optionsDao = optionsDao;
121: }
122:
123: /**
124: * @see org.kuali.module.chart.service.BalanceTypService#getCostShareEncumbranceBalanceType(java.lang.Integer)
125: */
126: public String getCostShareEncumbranceBalanceType(
127: Integer universityFiscalYear) {
128: return optionsDao.getByPrimaryId(universityFiscalYear)
129: .getCostShareEncumbranceBalanceTypeCd();
130: }
131:
132: /**
133: *
134: * @see org.kuali.module.chart.service.BalanceTypService#getEncumbranceBalanceTypes(java.lang.Integer)
135: */
136: public List<String> getEncumbranceBalanceTypes(
137: Integer universityFiscalYear) {
138: Options option = optionsDao
139: .getByPrimaryId(universityFiscalYear);
140: List<String> encumberanceBalanceTypes = new ArrayList<String>();
141: encumberanceBalanceTypes.add(option
142: .getExtrnlEncumFinBalanceTypCd());
143: encumberanceBalanceTypes.add(option
144: .getIntrnlEncumFinBalanceTypCd());
145: encumberanceBalanceTypes.add(option
146: .getPreencumbranceFinBalTypeCd());
147: encumberanceBalanceTypes.add(option
148: .getCostShareEncumbranceBalanceTypeCd());
149: return encumberanceBalanceTypes;
150: }
151:
152: /**
153: *
154: * @see org.kuali.module.chart.service.BalanceTypService#getCurrentYearCostShareEncumbranceBalanceType()
155: */
156: public String getCurrentYearCostShareEncumbranceBalanceType() {
157: return getCostShareEncumbranceBalanceType(universityDateService
158: .getCurrentFiscalYear());
159: }
160:
161: /**
162: *
163: * @see org.kuali.module.chart.service.BalanceTypService#getCurrentYearEncumbranceBalanceTypes()
164: */
165: public List<String> getCurrentYearEncumbranceBalanceTypes() {
166: return getEncumbranceBalanceTypes(universityDateService
167: .getCurrentFiscalYear());
168: }
169:
170: /**
171: *
172: * @see org.kuali.module.chart.service.BalanceTypService#getContinuationAccountBypassBalanceTypeCodes(java.lang.Integer)
173: */
174: public List<String> getContinuationAccountBypassBalanceTypeCodes(
175: Integer universityFiscalYear) {
176: Options option = optionsDao
177: .getByPrimaryId(universityFiscalYear);
178: List<String> continuationAccountBypassBalanceTypes = new ArrayList<String>();
179: continuationAccountBypassBalanceTypes.add(option
180: .getExtrnlEncumFinBalanceTypCd());
181: continuationAccountBypassBalanceTypes.add(option
182: .getIntrnlEncumFinBalanceTypCd());
183: continuationAccountBypassBalanceTypes.add(option
184: .getPreencumbranceFinBalTypeCd());
185: return continuationAccountBypassBalanceTypes;
186: }
187: }
|