1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.ole.coa.businessobject;
18
19 import java.util.ArrayList;
20 import java.util.Collection;
21 import java.util.HashMap;
22 import java.util.LinkedHashMap;
23 import java.util.List;
24 import java.util.Map;
25
26 import org.kuali.ole.sys.OLEPropertyConstants;
27 import org.kuali.ole.sys.businessobject.SystemOptions;
28 import org.kuali.ole.sys.context.SpringContext;
29 import org.kuali.rice.core.api.mo.common.active.MutableInactivatable;
30 import org.kuali.rice.krad.bo.DocumentHeader;
31 import org.kuali.rice.krad.bo.GlobalBusinessObject;
32 import org.kuali.rice.krad.bo.GlobalBusinessObjectDetail;
33 import org.kuali.rice.krad.bo.PersistableBusinessObject;
34 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
35 import org.kuali.rice.krad.service.BusinessObjectService;
36
37
38
39
40 public class SubObjectCodeGlobal extends PersistableBusinessObjectBase implements GlobalBusinessObject, MutableInactivatable {
41
42 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(SubObjectCodeGlobal.class);
43
44 protected String documentNumber;
45 protected Integer universityFiscalYear;
46 protected String chartOfAccountsCode;
47 protected String financialSubObjectCode;
48 protected String financialSubObjectCodeName;
49 protected String financialSubObjectCodeShortName;
50 protected boolean active;
51
52 protected DocumentHeader financialDocument;
53 protected SystemOptions universityFiscal;
54 protected Chart chartOfAccounts;
55
56 protected List<SubObjectCodeGlobalDetail> subObjCdGlobalDetails;
57 protected List<AccountGlobalDetail> accountGlobalDetails;
58
59
60
61
62 public SubObjectCodeGlobal() {
63
64
65 subObjCdGlobalDetails = new ArrayList<SubObjectCodeGlobalDetail>();
66 accountGlobalDetails = new ArrayList<AccountGlobalDetail>();
67
68 }
69
70
71
72
73
74
75 public String getDocumentNumber() {
76 return documentNumber;
77 }
78
79
80
81
82
83
84 public void setDocumentNumber(String documentNumber) {
85 this.documentNumber = documentNumber;
86 }
87
88
89
90
91
92
93
94 public Integer getUniversityFiscalYear() {
95 return universityFiscalYear;
96 }
97
98
99
100
101
102
103 public void setUniversityFiscalYear(Integer universityFiscalYear) {
104 this.universityFiscalYear = universityFiscalYear;
105 }
106
107
108
109
110
111
112
113 public String getChartOfAccountsCode() {
114 return chartOfAccountsCode;
115 }
116
117
118
119
120
121
122 public void setChartOfAccountsCode(String chartOfAccountsCode) {
123 this.chartOfAccountsCode = chartOfAccountsCode;
124 }
125
126
127
128
129
130
131
132 public String getFinancialSubObjectCode() {
133 return financialSubObjectCode;
134 }
135
136
137
138
139
140
141 public void setFinancialSubObjectCode(String financialSubObjectCode) {
142 this.financialSubObjectCode = financialSubObjectCode;
143 }
144
145
146
147
148
149
150
151 public String getFinancialSubObjectCodeName() {
152 return financialSubObjectCodeName;
153 }
154
155
156
157
158
159
160 public void setFinancialSubObjectCodeName(String financialSubObjectCodeName) {
161 this.financialSubObjectCodeName = financialSubObjectCodeName;
162 }
163
164
165
166
167
168
169
170 public String getFinancialSubObjectCodeShortName() {
171 return financialSubObjectCodeShortName;
172 }
173
174
175
176
177
178
179 public void setFinancialSubObjectCodeShortName(String financialSubObjectCdshortNm) {
180 this.financialSubObjectCodeShortName = financialSubObjectCdshortNm;
181 }
182
183
184
185
186
187
188
189 public boolean isActive() {
190 return active;
191 }
192
193
194
195
196
197
198
199 public void setActive(boolean active) {
200 this.active = active;
201 }
202
203
204
205
206
207
208
209 public DocumentHeader getFinancialDocument() {
210 return financialDocument;
211 }
212
213
214
215
216
217
218
219 public void setFinancialDocument(DocumentHeader financialDocument) {
220 this.financialDocument = financialDocument;
221 }
222
223
224
225
226
227
228 public SystemOptions getUniversityFiscal() {
229 return universityFiscal;
230 }
231
232
233
234
235
236
237
238 public void setUniversityFiscal(SystemOptions universityFiscal) {
239 this.universityFiscal = universityFiscal;
240 }
241
242
243
244
245
246
247 public Chart getChartOfAccounts() {
248 return chartOfAccounts;
249 }
250
251
252
253
254
255
256
257 public void setChartOfAccounts(Chart chartOfAccounts) {
258 this.chartOfAccounts = chartOfAccounts;
259 }
260
261
262
263
264 protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
265 LinkedHashMap m = new LinkedHashMap();
266 m.put(OLEPropertyConstants.DOCUMENT_NUMBER, this.documentNumber);
267 return m;
268 }
269
270 public List<SubObjectCodeGlobalDetail> getSubObjCdGlobalDetails() {
271 return subObjCdGlobalDetails;
272 }
273
274 public void setSubObjCdGlobalDetails(List<SubObjectCodeGlobalDetail> subObjCdGlobalDetails) {
275 this.subObjCdGlobalDetails = subObjCdGlobalDetails;
276 }
277
278 public List<AccountGlobalDetail> getAccountGlobalDetails() {
279 return accountGlobalDetails;
280 }
281
282 public void setAccountGlobalDetails(List<AccountGlobalDetail> accountGlobalDetails) {
283 this.accountGlobalDetails = accountGlobalDetails;
284 }
285
286
287
288
289 public List<PersistableBusinessObject> generateDeactivationsToPersist() {
290 return null;
291 }
292
293
294
295
296
297
298 public List<PersistableBusinessObject> generateGlobalChangesToPersist() {
299 LOG.debug("applyGlobalChanges");
300 List result = new ArrayList();
301
302
303
304 for (SubObjectCodeGlobalDetail subObjCdGlobalDetail : subObjCdGlobalDetails) {
305
306 String financialObjectCode = subObjCdGlobalDetail.getFinancialObjectCode();
307
308 if (financialObjectCode != null && financialObjectCode.length() > 0) {
309
310 for (AccountGlobalDetail accountGlobalDetail : accountGlobalDetails) {
311
312 Map pk = new HashMap();
313
314 String accountNumber = accountGlobalDetail.getAccountNumber();
315
316 if (accountNumber != null && accountNumber.length() > 0) {
317 pk.put("UNIV_FISCAL_YR", this.universityFiscalYear);
318 pk.put("FIN_COA_CD", this.chartOfAccountsCode);
319 pk.put("ACCOUNT_NBR", accountNumber);
320 pk.put("FIN_OBJECT_CD", financialObjectCode);
321 pk.put("FIN_SUB_OBJ_CD", this.financialSubObjectCode);
322
323 SubObjectCode subObjCd = (SubObjectCode) SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(SubObjectCode.class, pk);
324 if (subObjCd == null) {
325 subObjCd = new SubObjectCode(this.universityFiscalYear, this.chartOfAccountsCode, accountNumber, financialObjectCode, this.financialSubObjectCode);
326 }
327 populate(subObjCd, accountGlobalDetail, subObjCdGlobalDetail);
328 result.add(subObjCd);
329 }
330 }
331 }
332 }
333
334 return result;
335 }
336
337 public void populate(SubObjectCode old, AccountGlobalDetail accountGlobalDetail, SubObjectCodeGlobalDetail subObjCdGlobalDetail) {
338 old.setFinancialSubObjectCodeName(update(old.getFinancialSubObjectCodeName(), financialSubObjectCodeName));
339 old.setFinancialSubObjectCdshortNm(update(old.getFinancialSubObjectCdshortNm(), financialSubObjectCodeShortName));
340 old.setActive(update(old.isActive(), active));
341 }
342
343
344
345
346
347
348
349
350
351 protected String update(String oldValue, String newValue) {
352 if (newValue == null || newValue.length() == 0) {
353 return oldValue;
354 }
355 return newValue;
356 }
357
358 protected boolean update(boolean oldValue, boolean newValue) {
359 return newValue;
360 }
361
362
363 public boolean isPersistable() {
364 return true;
365 }
366
367 public List<? extends GlobalBusinessObjectDetail> getAllDetailObjects() {
368 ArrayList<GlobalBusinessObjectDetail> details = new ArrayList<GlobalBusinessObjectDetail>(accountGlobalDetails.size() + subObjCdGlobalDetails.size());
369 details.addAll(accountGlobalDetails);
370 details.addAll(subObjCdGlobalDetails);
371 return details;
372 }
373
374
375
376
377 @Override
378 public List buildListOfDeletionAwareLists() {
379 List<Collection<PersistableBusinessObject>> managedLists = super.buildListOfDeletionAwareLists();
380
381 managedLists.add( new ArrayList<PersistableBusinessObject>( getAccountGlobalDetails() ) );
382 managedLists.add( new ArrayList<PersistableBusinessObject>( getSubObjCdGlobalDetails() ) );
383
384 return managedLists;
385 }
386 }