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