1 /*
2 * Copyright 2006 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.ole.coa.service.impl;
17
18 import java.util.Collection;
19
20 import org.kuali.ole.coa.businessobject.Account;
21 import org.kuali.ole.coa.businessobject.FundGroup;
22 import org.kuali.ole.coa.businessobject.SubFundGroup;
23 import org.kuali.ole.coa.dataaccess.SubFundGroupDao;
24 import org.kuali.ole.coa.service.SubFundGroupService;
25 import org.kuali.ole.sys.OLEConstants;
26 import org.kuali.ole.sys.context.SpringContext;
27 import org.kuali.rice.core.api.parameter.ParameterEvaluatorService;
28 import org.kuali.rice.coreservice.framework.parameter.ParameterService;
29 import org.kuali.rice.kns.service.DataDictionaryService;
30 import org.kuali.rice.krad.service.BusinessObjectService;
31 import org.kuali.rice.krad.util.ObjectUtils;
32
33 /**
34 * This service implementation is the default implementation of the SubFundGroup service that is delivered with Kuali.
35 */
36 public class SubFundGroupServiceImpl implements SubFundGroupService {
37 private ParameterService parameterService;
38 private DataDictionaryService dataDictionaryService;
39 private SubFundGroupDao subFundGroupDao;
40
41 /**
42 * @see org.kuali.ole.coa.service.SubFundGroupService#isForContractsAndGrants(org.kuali.ole.coa.businessobject.SubFundGroup)
43 */
44 public boolean isForContractsAndGrants(SubFundGroup subFundGroup) {
45 if (ObjectUtils.isNull(subFundGroup)) {
46 return false;
47 }
48 else if (fundGroupDenotesContractsAndGrants()) {
49 return /*REFACTORME*/SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator(Account.class, OLEConstants.ChartApcParms.ACCOUNT_CG_DENOTING_VALUE, subFundGroup.getFundGroupCode()).evaluationSucceeds();
50 // return getContractsAndGrantsDenotingValue(subFundGroup.getFundGroupCode());
51 }
52 else {
53 return /*REFACTORME*/SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator(Account.class, OLEConstants.ChartApcParms.ACCOUNT_CG_DENOTING_VALUE, subFundGroup.getSubFundGroupCode()).evaluationSucceeds();
54
55 //return getContractsAndGrantsDenotingValue(subFundGroup.getSubFundGroupCode());
56 }
57 }
58
59 /**
60 * @see org.kuali.ole.coa.service.SubFundGroupService#getContractsAndGrantsDenotingAttributeLabel()
61 */
62 public String getContractsAndGrantsDenotingAttributeLabel() {
63 if (fundGroupDenotesContractsAndGrants()) {
64 return dataDictionaryService.getAttributeLabel(FundGroup.class, OLEConstants.FUND_GROUP_CODE_PROPERTY_NAME);
65 }
66 else {
67 return dataDictionaryService.getAttributeLabel(SubFundGroup.class, OLEConstants.SUB_FUND_GROUP_CODE_PROPERTY_NAME);
68 }
69 }
70
71 /**
72 *
73 * @see org.kuali.ole.coa.service.SubFundGroupService#getContractsAndGrantsDenotingValue(org.kuali.ole.coa.businessobject.SubFundGroup)
74 */
75 public String getContractsAndGrantsDenotingValue(SubFundGroup subFundGroup) {
76 if (fundGroupDenotesContractsAndGrants()) {
77 return subFundGroup.getFundGroupCode();
78 }
79 else {
80 return subFundGroup.getSubFundGroupCode();
81 }
82 }
83
84
85 /**
86 * @see org.kuali.ole.coa.service.SubFundGroupService#getContractsAndGrantsDenotingValues()
87 */
88 public Collection<String> getContractsAndGrantsDenotingValues() {
89 return parameterService.getParameterValuesAsString(Account.class, OLEConstants.ChartApcParms.ACCOUNT_CG_DENOTING_VALUE);
90 }
91
92
93 /**
94 * @see org.kuali.ole.coa.service.SubFundGroupService#getContractsAndGrantsDenotingValueForMessage()
95 */
96 public String getContractsAndGrantsDenotingValueForMessage() {
97 return /*REFACTORME*/SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator(Account.class, OLEConstants.ChartApcParms.ACCOUNT_CG_DENOTING_VALUE).getParameterValuesForMessage();
98 }
99
100 /**
101 *
102 * This checks to see if there is a value for checking if a Fund Group denotes Contracts and Grants
103 * @return false if there is no value
104 */
105 protected boolean fundGroupDenotesContractsAndGrants() {
106 return parameterService.getParameterValueAsBoolean(Account.class, OLEConstants.ChartApcParms.ACCOUNT_FUND_GROUP_DENOTES_CG);
107 }
108
109 /**
110 * @see org.kuali.ole.coa.service.SubFundGroupService#getByPrimaryId(java.lang.String)
111 */
112 public SubFundGroup getByPrimaryId(String subFundGroupCode) {
113 return (SubFundGroup)SpringContext.getBean(BusinessObjectService.class).findBySinglePrimaryKey(SubFundGroup.class, subFundGroupCode);
114 }
115
116 /**
117 * @see org.kuali.ole.coa.service.SubFundGroupService#getByChartAndAccount(java.lang.String, java.lang.String)
118 */
119 public SubFundGroup getByChartAndAccount(String chartCode, String accountNumber) {
120 return subFundGroupDao.getByChartAndAccount(chartCode, accountNumber);
121 }
122
123 /**
124 *
125 * This method injects the ParameterService
126 * @param parameterService
127 */
128 public void setParameterService(ParameterService parameterService) {
129 this.parameterService = parameterService;
130 }
131
132 /**
133 * Sets the subFundGroupDao attribute values.
134 *
135 * @param subFundGroupDao The subFundGroupDao to set.
136 */
137 public void setSubFundGroupDao(SubFundGroupDao subFundGroupDao) {
138 this.subFundGroupDao = subFundGroupDao;
139 }
140
141 /**
142 * Sets the dataDictionarySerivce
143 *
144 * @param dataDictionaryService The dataDictionaryService implementation to set.
145 */
146 public void setDataDictionaryService(DataDictionaryService dataDictionaryService) {
147 this.dataDictionaryService = dataDictionaryService;
148 }
149 }