1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.coa.businessobject;
17
18 import java.util.LinkedHashMap;
19
20 import org.kuali.ole.gl.businessobject.SufficientFundRebuild;
21 import org.kuali.ole.sys.context.SpringContext;
22 import org.kuali.rice.core.api.mo.common.active.MutableInactivatable;
23 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
24 import org.kuali.rice.krad.service.BusinessObjectService;
25
26
27
28
29 public class ObjectLevel extends PersistableBusinessObjectBase implements MutableInactivatable {
30 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ObjectLevel.class);
31
32 private String chartOfAccountsCode;
33 private String financialObjectLevelCode;
34 private String financialObjectLevelName;
35 private String financialObjectLevelShortNm;
36 private boolean active;
37 private String financialReportingSortCode;
38 private String financialConsolidationObjectCode;
39
40 private ObjectConsolidation financialConsolidationObject;
41 private Chart chartOfAccounts;
42
43
44
45
46
47 public ObjectLevel() {
48 super();
49 this.financialConsolidationObject = new ObjectConsolidation();
50 }
51
52
53
54
55
56
57 public String getFinancialObjectLevelCode() {
58 return financialObjectLevelCode;
59 }
60
61
62
63
64
65
66 public void setFinancialObjectLevelCode(String financialObjectLevelCode) {
67 this.financialObjectLevelCode = financialObjectLevelCode;
68 }
69
70
71
72
73
74
75 public String getFinancialObjectLevelName() {
76 return financialObjectLevelName;
77 }
78
79
80
81
82
83
84 public void setFinancialObjectLevelName(String financialObjectLevelName) {
85 this.financialObjectLevelName = financialObjectLevelName;
86 }
87
88
89
90
91
92
93 public String getFinancialObjectLevelShortNm() {
94 return financialObjectLevelShortNm;
95 }
96
97
98
99
100
101
102 public void setFinancialObjectLevelShortNm(String financialObjectLevelShortNm) {
103 this.financialObjectLevelShortNm = financialObjectLevelShortNm;
104 }
105
106
107
108
109
110
111 public boolean isActive() {
112 return active;
113 }
114
115
116
117
118
119
120 public void setActive(boolean financialObjectLevelActiveIndicator) {
121 this.active = financialObjectLevelActiveIndicator;
122 }
123
124
125
126
127
128
129 public String getFinancialReportingSortCode() {
130 return financialReportingSortCode;
131 }
132
133
134
135
136
137
138 public void setFinancialReportingSortCode(String financialReportingSortCode) {
139 this.financialReportingSortCode = financialReportingSortCode;
140 }
141
142
143 public String getConsolidatedObjectCode() {
144 return financialConsolidationObject.getFinancialReportingSortCode();
145 }
146
147
148
149
150
151
152 public ObjectConsolidation getFinancialConsolidationObject() {
153 return financialConsolidationObject;
154 }
155
156
157
158
159
160
161 public void setFinancialConsolidationObject(ObjectConsolidation financialConsolidationObject) {
162 this.financialConsolidationObject = financialConsolidationObject;
163 }
164
165 public String getChartOfAccountsCode() {
166 return chartOfAccountsCode;
167 }
168
169
170
171
172
173
174 public Chart getChartOfAccounts() {
175 return chartOfAccounts;
176 }
177
178
179
180
181
182
183
184 public void setChartOfAccounts(Chart chartOfAccounts) {
185 this.chartOfAccounts = chartOfAccounts;
186 }
187
188
189
190
191
192 public String getFinancialConsolidationObjectCode() {
193 return financialConsolidationObjectCode;
194 }
195
196
197
198
199 public void setFinancialConsolidationObjectCode(String financialConsolidationObjectCode) {
200 this.financialConsolidationObjectCode = financialConsolidationObjectCode;
201 }
202
203 public void setChartOfAccountsCode(String chart) {
204 this.chartOfAccountsCode = chart;
205 }
206
207 @Override protected void preUpdate() {
208 super.preUpdate();
209 try {
210
211
212 BusinessObjectService boService = SpringContext.getBean(BusinessObjectService.class);
213 ObjectLevel originalObjLevel = (ObjectLevel) boService.retrieve(this);
214
215 if (originalObjLevel != null) {
216 if (!originalObjLevel.getFinancialConsolidationObjectCode().equals(getFinancialConsolidationObjectCode())) {
217 SufficientFundRebuild sfr = new SufficientFundRebuild();
218 sfr.setAccountFinancialObjectTypeCode(SufficientFundRebuild.REBUILD_OBJECT);
219 sfr.setChartOfAccountsCode(originalObjLevel.getChartOfAccountsCode());
220 sfr.setAccountNumberFinancialObjectCode(originalObjLevel.getFinancialConsolidationObjectCode());
221 if (boService.retrieve(sfr) == null) {
222 boService.save(sfr);
223 }
224 sfr = new SufficientFundRebuild();
225 sfr.setAccountFinancialObjectTypeCode(SufficientFundRebuild.REBUILD_OBJECT);
226 sfr.setChartOfAccountsCode(getChartOfAccountsCode());
227 sfr.setAccountNumberFinancialObjectCode(getFinancialConsolidationObjectCode());
228 if (boService.retrieve(sfr) == null) {
229 boService.save(sfr);
230 }
231 }
232 }
233 }
234 catch (Exception ex) {
235 LOG.error("Problem updating sufficient funds rebuild table: ", ex);
236 }
237 }
238
239 }