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.ArrayList;
19 import java.util.Collection;
20 import java.util.HashMap;
21 import java.util.LinkedHashMap;
22 import java.util.List;
23 import java.util.Map;
24
25 import org.apache.commons.lang.StringUtils;
26 import org.kuali.ole.coa.service.OrganizationReversionService;
27 import org.kuali.ole.sys.OLEPropertyConstants;
28 import org.kuali.ole.sys.businessobject.SystemOptions;
29 import org.kuali.ole.sys.context.SpringContext;
30 import org.kuali.rice.krad.bo.GlobalBusinessObject;
31 import org.kuali.rice.krad.bo.GlobalBusinessObjectDetail;
32 import org.kuali.rice.krad.bo.PersistableBusinessObject;
33 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
34 import org.kuali.rice.krad.service.BusinessObjectService;
35 import org.kuali.rice.krad.service.PersistenceStructureService;
36
37
38
39
40
41
42 public class OrganizationReversionGlobal extends PersistableBusinessObjectBase implements GlobalBusinessObject {
43 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OrganizationReversionGlobal.class);
44 protected String documentNumber;
45
46 protected Integer universityFiscalYear;
47 protected String budgetReversionChartOfAccountsCode;
48 protected String budgetReversionAccountNumber;
49 protected Boolean carryForwardByObjectCodeIndicator;
50 protected String cashReversionFinancialChartOfAccountsCode;
51 protected String cashReversionAccountNumber;
52
53 protected Account cashReversionAccount;
54 protected Account budgetReversionAccount;
55 protected Chart budgetReversionChartOfAccounts;
56 protected Chart cashReversionFinancialChartOfAccounts;
57 protected SystemOptions universityFiscal;
58
59 protected List<OrganizationReversionGlobalDetail> organizationReversionGlobalDetails;
60 protected List<OrganizationReversionGlobalOrganization> organizationReversionGlobalOrganizations;
61
62 public OrganizationReversionGlobal() {
63 super();
64 organizationReversionGlobalDetails = new ArrayList<OrganizationReversionGlobalDetail>();
65 organizationReversionGlobalOrganizations = new ArrayList<OrganizationReversionGlobalOrganization>();
66 }
67
68
69
70
71
72 protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
73 LinkedHashMap stringMapper = new LinkedHashMap();
74 stringMapper.put(OLEPropertyConstants.DOCUMENT_NUMBER, this.documentNumber);
75 stringMapper.put(OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR, this.universityFiscalYear);
76 return stringMapper;
77 }
78
79
80
81
82
83
84 public Account getBudgetReversionAccount() {
85 return budgetReversionAccount;
86 }
87
88
89
90
91
92
93 public String getDocumentNumber() {
94 return documentNumber;
95 }
96
97
98
99
100
101
102 public void setDocumentNumber(String documentNumber) {
103 this.documentNumber = documentNumber;
104 }
105
106
107
108
109
110
111
112 public void setBudgetReversionAccount(Account budgetReversionAccount) {
113 this.budgetReversionAccount = budgetReversionAccount;
114 }
115
116
117
118
119
120
121 public String getBudgetReversionAccountNumber() {
122 return budgetReversionAccountNumber;
123 }
124
125
126
127
128
129
130 public void setBudgetReversionAccountNumber(String budgetReversionAccountNumber) {
131 this.budgetReversionAccountNumber = budgetReversionAccountNumber;
132 }
133
134
135
136
137
138
139 public Chart getBudgetReversionChartOfAccounts() {
140 return budgetReversionChartOfAccounts;
141 }
142
143
144
145
146
147
148
149 public void setBudgetReversionChartOfAccounts(Chart budgetReversionChartOfAccounts) {
150 this.budgetReversionChartOfAccounts = budgetReversionChartOfAccounts;
151 }
152
153
154
155
156
157
158 public String getBudgetReversionChartOfAccountsCode() {
159 return budgetReversionChartOfAccountsCode;
160 }
161
162
163
164
165
166
167 public void setBudgetReversionChartOfAccountsCode(String budgetReversionChartOfAccountsCode) {
168 this.budgetReversionChartOfAccountsCode = budgetReversionChartOfAccountsCode;
169 }
170
171
172
173
174
175
176 public Boolean isCarryForwardByObjectCodeIndicator() {
177 return carryForwardByObjectCodeIndicator;
178 }
179
180
181
182
183
184
185
186 public Boolean getCarryForwardByObjectCodeIndicator() {
187 return this.isCarryForwardByObjectCodeIndicator();
188 }
189
190
191
192
193
194
195 public void setCarryForwardByObjectCodeIndicator(Boolean carryForwardByObjectCodeIndicator) {
196 this.carryForwardByObjectCodeIndicator = carryForwardByObjectCodeIndicator;
197 }
198
199
200
201
202
203
204 public Account getCashReversionAccount() {
205 return cashReversionAccount;
206 }
207
208
209
210
211
212
213
214 public void setCashReversionAccount(Account cashReversionAccount) {
215 this.cashReversionAccount = cashReversionAccount;
216 }
217
218
219
220
221
222
223 public String getCashReversionAccountNumber() {
224 return cashReversionAccountNumber;
225 }
226
227
228
229
230
231
232 public void setCashReversionAccountNumber(String cashReversionAccountNumber) {
233 this.cashReversionAccountNumber = cashReversionAccountNumber;
234 }
235
236
237
238
239
240
241 public Chart getCashReversionFinancialChartOfAccounts() {
242 return cashReversionFinancialChartOfAccounts;
243 }
244
245
246
247
248
249
250
251 public void setCashReversionFinancialChartOfAccounts(Chart cashReversionFinancialChartOfAccounts) {
252 this.cashReversionFinancialChartOfAccounts = cashReversionFinancialChartOfAccounts;
253 }
254
255
256
257
258
259
260 public String getCashReversionFinancialChartOfAccountsCode() {
261 return cashReversionFinancialChartOfAccountsCode;
262 }
263
264
265
266
267
268
269 public void setCashReversionFinancialChartOfAccountsCode(String cashReversionFinancialChartOfAccountsCode) {
270 this.cashReversionFinancialChartOfAccountsCode = cashReversionFinancialChartOfAccountsCode;
271 }
272
273
274
275
276
277
278 public List<OrganizationReversionGlobalOrganization> getOrganizationReversionGlobalOrganizations() {
279 return organizationReversionGlobalOrganizations;
280 }
281
282
283
284
285
286
287
288 public void setOrganizationReversionGlobalOrganizations(List<OrganizationReversionGlobalOrganization> organizationReversionGlobalOrganizations) {
289 this.organizationReversionGlobalOrganizations = organizationReversionGlobalOrganizations;
290 }
291
292
293
294
295
296
297 public List<OrganizationReversionGlobalDetail> getOrganizationReversionGlobalDetails() {
298 return organizationReversionGlobalDetails;
299 }
300
301
302
303
304
305
306 public void setOrganizationReversionGlobalDetails(List<OrganizationReversionGlobalDetail> organizationReversionGlobalDetails) {
307 this.organizationReversionGlobalDetails = organizationReversionGlobalDetails;
308 }
309
310
311
312
313
314
315 public Integer getUniversityFiscalYear() {
316 return universityFiscalYear;
317 }
318
319
320
321
322
323
324 public void setUniversityFiscalYear(Integer universityFiscalYear) {
325 this.universityFiscalYear = universityFiscalYear;
326 }
327
328
329
330
331
332
333 public SystemOptions getUniversityFiscal() {
334 return universityFiscal;
335 }
336
337
338
339
340
341
342 public void setUniversityFiscal(SystemOptions universityFiscal) {
343 this.universityFiscal = universityFiscal;
344 }
345
346
347
348
349
350 public List<PersistableBusinessObject> generateDeactivationsToPersist() {
351 return null;
352 }
353
354
355
356
357
358 public List<PersistableBusinessObject> generateGlobalChangesToPersist() {
359 List<PersistableBusinessObject> persistingChanges = new ArrayList<PersistableBusinessObject>();
360
361 BusinessObjectService boService = SpringContext.getBean(BusinessObjectService.class);
362 Map<String, OrganizationReversionGlobalDetail> detailsMap = this.rearrangeOrganizationReversionDetailsAsMap();
363
364 for (OrganizationReversionGlobalOrganization orgRevOrg : this.getOrganizationReversionGlobalOrganizations()) {
365
366 OrganizationReversion currOrgRev = SpringContext.getBean(OrganizationReversionService.class).getByPrimaryId(this.getUniversityFiscalYear(), orgRevOrg.getChartOfAccountsCode(), orgRevOrg.getOrganizationCode());
367
368 if (currOrgRev != null) {
369
370 if (!StringUtils.isBlank(this.getBudgetReversionChartOfAccountsCode())) {
371 currOrgRev.setBudgetReversionChartOfAccountsCode(this.getBudgetReversionChartOfAccountsCode());
372 }
373 if (!StringUtils.isBlank(this.getBudgetReversionAccountNumber())) {
374 currOrgRev.setBudgetReversionAccountNumber(this.getBudgetReversionAccountNumber());
375 }
376 if (!StringUtils.isBlank(this.getCashReversionFinancialChartOfAccountsCode())) {
377 currOrgRev.setCashReversionFinancialChartOfAccountsCode(this.getCashReversionFinancialChartOfAccountsCode());
378 }
379 if (!StringUtils.isBlank(this.getCashReversionAccountNumber())) {
380 currOrgRev.setCashReversionAccountNumber(this.getCashReversionAccountNumber());
381 }
382
383 if (this.isCarryForwardByObjectCodeIndicator() != null) {
384 currOrgRev.setCarryForwardByObjectCodeIndicator(this.isCarryForwardByObjectCodeIndicator().booleanValue());
385 }
386
387
388 for (OrganizationReversionDetail orgRevDetail : currOrgRev.getOrganizationReversionDetail()) {
389 OrganizationReversionGlobalDetail changeDetail = detailsMap.get(orgRevDetail.getOrganizationReversionCategoryCode());
390 if (changeDetail != null) {
391 if (!StringUtils.isBlank(changeDetail.getOrganizationReversionCode())) {
392 orgRevDetail.setOrganizationReversionCode(changeDetail.getOrganizationReversionCode());
393 }
394 if (!StringUtils.isBlank(changeDetail.getOrganizationReversionObjectCode())) {
395 orgRevDetail.setOrganizationReversionObjectCode(changeDetail.getOrganizationReversionObjectCode());
396 }
397 }
398 }
399
400 currOrgRev.refreshNonUpdateableReferences();
401 persistingChanges.add(currOrgRev);
402 }
403
404 }
405 return persistingChanges;
406 }
407
408
409
410
411
412
413
414 protected Map<String, OrganizationReversionGlobalDetail> rearrangeOrganizationReversionDetailsAsMap() {
415 Map<String, OrganizationReversionGlobalDetail> orgRevMap = new HashMap<String, OrganizationReversionGlobalDetail>();
416 for (OrganizationReversionGlobalDetail orgRevDetail : this.getOrganizationReversionGlobalDetails()) {
417 if (!StringUtils.isBlank(orgRevDetail.getOrganizationReversionObjectCode()) || !StringUtils.isBlank(orgRevDetail.getOrganizationReversionCode())) {
418 orgRevMap.put(orgRevDetail.getOrganizationReversionCategoryCode(), orgRevDetail);
419 }
420 }
421 return orgRevMap;
422 }
423
424
425
426
427
428 public List<? extends GlobalBusinessObjectDetail> getAllDetailObjects() {
429 List<GlobalBusinessObjectDetail> detailObjects = new ArrayList<GlobalBusinessObjectDetail>();
430 detailObjects.addAll(this.getOrganizationReversionGlobalDetails());
431 detailObjects.addAll(this.getOrganizationReversionGlobalOrganizations());
432 return detailObjects;
433 }
434
435
436
437
438
439
440 public boolean isPersistable() {
441 PersistenceStructureService persistenceStructureService = SpringContext.getBean(PersistenceStructureService.class);
442
443 if (!persistenceStructureService.hasPrimaryKeyFieldValues(this)) {
444 return false;
445 }
446
447 for (OrganizationReversionGlobalDetail orgRevDetail : this.getOrganizationReversionGlobalDetails()) {
448 if (!persistenceStructureService.hasPrimaryKeyFieldValues(orgRevDetail)) {
449 return false;
450 }
451 }
452
453 for (OrganizationReversionGlobalOrganization orgRevOrg : this.getOrganizationReversionGlobalOrganizations()) {
454 if (!persistenceStructureService.hasPrimaryKeyFieldValues(orgRevOrg)) {
455 return false;
456 }
457 }
458
459
460 return true;
461 }
462
463
464
465
466 @Override
467 public List buildListOfDeletionAwareLists() {
468 List<Collection<PersistableBusinessObject>> managedLists = super.buildListOfDeletionAwareLists();
469
470 managedLists.add( new ArrayList<PersistableBusinessObject>( getOrganizationReversionGlobalDetails() ) );
471 managedLists.add( new ArrayList<PersistableBusinessObject>( getOrganizationReversionGlobalOrganizations() ) );
472
473 return managedLists;
474 }
475 }