1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
35
36 public class SubFundGroupServiceImpl implements SubFundGroupService {
37 private ParameterService parameterService;
38 private DataDictionaryService dataDictionaryService;
39 private SubFundGroupDao subFundGroupDao;
40
41
42
43
44 public boolean isForContractsAndGrants(SubFundGroup subFundGroup) {
45 if (ObjectUtils.isNull(subFundGroup)) {
46 return false;
47 }
48 else if (fundGroupDenotesContractsAndGrants()) {
49 return SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator(Account.class, OLEConstants.ChartApcParms.ACCOUNT_CG_DENOTING_VALUE, subFundGroup.getFundGroupCode()).evaluationSucceeds();
50
51 }
52 else {
53 return SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator(Account.class, OLEConstants.ChartApcParms.ACCOUNT_CG_DENOTING_VALUE, subFundGroup.getSubFundGroupCode()).evaluationSucceeds();
54
55
56 }
57 }
58
59
60
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
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
87
88 public Collection<String> getContractsAndGrantsDenotingValues() {
89 return parameterService.getParameterValuesAsString(Account.class, OLEConstants.ChartApcParms.ACCOUNT_CG_DENOTING_VALUE);
90 }
91
92
93
94
95
96 public String getContractsAndGrantsDenotingValueForMessage() {
97 return SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator(Account.class, OLEConstants.ChartApcParms.ACCOUNT_CG_DENOTING_VALUE).getParameterValuesForMessage();
98 }
99
100
101
102
103
104
105 protected boolean fundGroupDenotesContractsAndGrants() {
106 return parameterService.getParameterValueAsBoolean(Account.class, OLEConstants.ChartApcParms.ACCOUNT_FUND_GROUP_DENOTES_CG);
107 }
108
109
110
111
112 public SubFundGroup getByPrimaryId(String subFundGroupCode) {
113 return (SubFundGroup)SpringContext.getBean(BusinessObjectService.class).findBySinglePrimaryKey(SubFundGroup.class, subFundGroupCode);
114 }
115
116
117
118
119 public SubFundGroup getByChartAndAccount(String chartCode, String accountNumber) {
120 return subFundGroupDao.getByChartAndAccount(chartCode, accountNumber);
121 }
122
123
124
125
126
127
128 public void setParameterService(ParameterService parameterService) {
129 this.parameterService = parameterService;
130 }
131
132
133
134
135
136
137 public void setSubFundGroupDao(SubFundGroupDao subFundGroupDao) {
138 this.subFundGroupDao = subFundGroupDao;
139 }
140
141
142
143
144
145
146 public void setDataDictionaryService(DataDictionaryService dataDictionaryService) {
147 this.dataDictionaryService = dataDictionaryService;
148 }
149 }