001: /*
002: * Copyright 2006-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 org.kuali.core.service.DataDictionaryService;
019: import org.kuali.core.util.ObjectUtils;
020: import org.kuali.kfs.KFSConstants;
021: import org.kuali.kfs.service.ParameterService;
022: import org.kuali.module.chart.bo.Account;
023: import org.kuali.module.chart.bo.FundGroup;
024: import org.kuali.module.chart.bo.SubFundGroup;
025: import org.kuali.module.chart.dao.SubFundGroupDao;
026: import org.kuali.module.chart.service.SubFundGroupService;
027: import org.springframework.transaction.annotation.Transactional;
028:
029: /**
030: * This service implementation is the default implementation of the SubFundGroup service that is delivered with Kuali.
031: */
032: @Transactional
033: public class SubFundGroupServiceImpl implements SubFundGroupService {
034: private ParameterService parameterService;
035: private DataDictionaryService dataDictionaryService;
036: private SubFundGroupDao subFundGroupDao;
037:
038: /**
039: * @see org.kuali.module.chart.service.SubFundGroupService#isForContractsAndGrants(org.kuali.module.chart.bo.SubFundGroup)
040: */
041: public boolean isForContractsAndGrants(SubFundGroup subFundGroup) {
042: if (ObjectUtils.isNull(subFundGroup)) {
043: return false;
044: } else if (fundGroupDenotesContractsAndGrants()) {
045: return getContractsAndGrantsDenotingValue().equals(
046: subFundGroup.getFundGroupCode());
047: } else {
048: return getContractsAndGrantsDenotingValue().equals(
049: subFundGroup.getSubFundGroupCode());
050: }
051: }
052:
053: /**
054: * @see org.kuali.module.chart.service.SubFundGroupService#getContractsAndGrantsDenotingAttributeLabel()
055: */
056: public String getContractsAndGrantsDenotingAttributeLabel() {
057: if (fundGroupDenotesContractsAndGrants()) {
058: return dataDictionaryService.getAttributeLabel(
059: FundGroup.class,
060: KFSConstants.FUND_GROUP_CODE_PROPERTY_NAME);
061: } else {
062: return dataDictionaryService.getAttributeLabel(
063: SubFundGroup.class,
064: KFSConstants.SUB_FUND_GROUP_CODE_PROPERTY_NAME);
065: }
066: }
067:
068: /**
069: *
070: * @see org.kuali.module.chart.service.SubFundGroupService#getContractsAndGrantsDenotingValue(org.kuali.module.chart.bo.SubFundGroup)
071: */
072: public String getContractsAndGrantsDenotingValue(
073: SubFundGroup subFundGroup) {
074: if (fundGroupDenotesContractsAndGrants()) {
075: return subFundGroup.getFundGroupCode();
076: } else {
077: return subFundGroup.getSubFundGroupCode();
078: }
079: }
080:
081: /**
082: * @see org.kuali.module.chart.service.SubFundGroupService#getContractsAndGrantsDenotingValue()
083: */
084: public String getContractsAndGrantsDenotingValue() {
085: return parameterService.getParameterValue(Account.class,
086: KFSConstants.ChartApcParms.ACCOUNT_CG_DENOTING_VALUE);
087: }
088:
089: /**
090: *
091: * This checks to see if there is a value for checking if a Fund Group denotes Contracts and Grants
092: * @return false if there is no value
093: */
094: private boolean fundGroupDenotesContractsAndGrants() {
095: return parameterService
096: .getIndicatorParameter(
097: Account.class,
098: KFSConstants.ChartApcParms.ACCOUNT_FUND_GROUP_DENOTES_CG);
099: }
100:
101: /**
102: * @see org.kuali.module.chart.service.SubFundGroupService#getByPrimaryId(java.lang.String)
103: */
104: public SubFundGroup getByPrimaryId(String subFundGroupCode) {
105: return subFundGroupDao.getByPrimaryId(subFundGroupCode);
106: }
107:
108: /**
109: * @see org.kuali.module.chart.service.SubFundGroupService#getByChartAndAccount(java.lang.String, java.lang.String)
110: */
111: public SubFundGroup getByChartAndAccount(String chartCode,
112: String accountNumber) {
113: return subFundGroupDao.getByChartAndAccount(chartCode,
114: accountNumber);
115: }
116:
117: /**
118: *
119: * This method injects the ParameterService
120: * @param parameterService
121: */
122: public void setParameterService(ParameterService parameterService) {
123: this .parameterService = parameterService;
124: }
125:
126: /**
127: * Sets the subFundGroupDao attribute values.
128: *
129: * @param subFundGroupDao The subFundGroupDao to set.
130: */
131: public void setSubFundGroupDao(SubFundGroupDao subFundGroupDao) {
132: this .subFundGroupDao = subFundGroupDao;
133: }
134:
135: /**
136: * Sets the dataDictionarySerivce
137: *
138: * @param dataDictionaryService The dataDictionaryService implementation to set.
139: */
140: public void setDataDictionaryService(
141: DataDictionaryService dataDictionaryService) {
142: this.dataDictionaryService = dataDictionaryService;
143: }
144: }
|