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.coa.service.ChartService;
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.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 ObjectCodeGlobal extends PersistableBusinessObjectBase implements GlobalBusinessObject {
41
42 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ObjectCodeGlobal.class);
43
44 private String documentNumber;
45 private Integer universityFiscalYear;
46 private String chartOfAccountsCode;
47 private String financialObjectCode;
48 private String financialObjectCodeName;
49 private String financialObjectCodeShortName;
50 private String financialObjectLevelCode;
51 private String reportsToChartOfAccountsCode;
52 private String reportsToFinancialObjectCode;
53 private String financialObjectTypeCode;
54 private String financialObjectSubTypeCode;
55 private String historicalFinancialObjectCode;
56 private boolean financialObjectActiveIndicator;
57 private String financialBudgetAggregationCd;
58 private String finObjMandatoryTrnfrOrElimCd;
59 private String financialFederalFundedCode;
60 private String nextYearFinancialObjectCode;
61
62 private DocumentHeader financialDocument;
63 private ObjectCode financialObject;
64 private ObjectCode reportsToFinancialObject;
65 private SystemOptions universityFiscal;
66 private Chart chartOfAccounts;
67 private Chart reportsToChartOfAccounts;
68 private ObjectType financialObjectType;
69 private ObjectSubType financialObjectSubType;
70 private ObjectLevel financialObjectLevel;
71 private BudgetAggregationCode financialBudgetAggregation;
72 private MandatoryTransferEliminationCode finObjMandatoryTrnfrelim;
73 private FederalFundedCode financialFederalFunded;
74
75 private List<ObjectCodeGlobalDetail> objectCodeGlobalDetails;
76
77
78
79
80 public ObjectCodeGlobal() {
81 objectCodeGlobalDetails = new ArrayList<ObjectCodeGlobalDetail>();
82 }
83
84
85
86
87
88
89 @Override
90 public String getDocumentNumber() {
91 return documentNumber;
92 }
93
94
95
96
97
98
99 @Override
100 public void setDocumentNumber(String documentNumber) {
101 this.documentNumber = documentNumber;
102 }
103
104
105
106
107
108
109
110 public Integer getUniversityFiscalYear() {
111 return universityFiscalYear;
112 }
113
114
115
116
117
118
119 public void setUniversityFiscalYear(Integer universityFiscalYear) {
120 this.universityFiscalYear = universityFiscalYear;
121 }
122
123
124
125
126
127
128
129 public String getChartOfAccountsCode() {
130 return chartOfAccountsCode;
131 }
132
133
134
135
136
137
138 public void setChartOfAccountsCode(String chartOfAccountsCode) {
139 this.chartOfAccountsCode = chartOfAccountsCode;
140 }
141
142
143
144
145
146
147
148 public String getFinancialObjectCode() {
149 return financialObjectCode;
150 }
151
152
153
154
155
156
157 public void setFinancialObjectCode(String financialObjectCode) {
158 this.financialObjectCode = financialObjectCode;
159 }
160
161
162
163
164
165
166
167 public String getFinancialObjectCodeName() {
168 return financialObjectCodeName;
169 }
170
171
172
173
174
175
176 public void setFinancialObjectCodeName(String financialObjectCodeName) {
177 this.financialObjectCodeName = financialObjectCodeName;
178 }
179
180
181
182
183
184
185
186 public String getFinancialObjectCodeShortName() {
187 return financialObjectCodeShortName;
188 }
189
190
191
192
193
194
195 public void setFinancialObjectCodeShortName(String financialObjectCodeShortName) {
196 this.financialObjectCodeShortName = financialObjectCodeShortName;
197 }
198
199
200
201
202
203
204
205 public String getFinancialObjectLevelCode() {
206 return financialObjectLevelCode;
207 }
208
209
210
211
212
213
214 public void setFinancialObjectLevelCode(String financialObjectLevelCode) {
215 this.financialObjectLevelCode = financialObjectLevelCode;
216 }
217
218
219
220
221
222
223
224 public String getReportsToChartOfAccountsCode() {
225 return reportsToChartOfAccountsCode;
226 }
227
228
229
230
231
232
233 public void setReportsToChartOfAccountsCode(String reportsToChartOfAccountsCode) {
234 this.reportsToChartOfAccountsCode = reportsToChartOfAccountsCode;
235 }
236
237
238
239
240
241
242
243 public String getReportsToFinancialObjectCode() {
244 return reportsToFinancialObjectCode;
245 }
246
247
248
249
250
251
252 public void setReportsToFinancialObjectCode(String reportsToFinancialObjectCode) {
253 this.reportsToFinancialObjectCode = reportsToFinancialObjectCode;
254 }
255
256
257
258
259
260
261
262 public String getFinancialObjectTypeCode() {
263 return financialObjectTypeCode;
264 }
265
266
267
268
269
270
271 public void setFinancialObjectTypeCode(String financialObjectTypeCode) {
272 this.financialObjectTypeCode = financialObjectTypeCode;
273 }
274
275
276
277
278
279
280
281 public String getFinancialObjectSubTypeCode() {
282 return financialObjectSubTypeCode;
283 }
284
285
286
287
288
289
290 public void setFinancialObjectSubTypeCode(String financialObjectSubTypeCode) {
291 this.financialObjectSubTypeCode = financialObjectSubTypeCode;
292 }
293
294
295
296
297
298
299
300 public String getHistoricalFinancialObjectCode() {
301 return historicalFinancialObjectCode;
302 }
303
304
305
306
307
308
309 public void setHistoricalFinancialObjectCode(String historicalFinancialObjectCode) {
310 this.historicalFinancialObjectCode = historicalFinancialObjectCode;
311 }
312
313
314
315
316
317
318
319 public boolean isFinancialObjectActiveIndicator() {
320 return financialObjectActiveIndicator;
321 }
322
323
324
325
326
327
328
329 public void setFinancialObjectActiveIndicator(boolean financialObjectActiveIndicator) {
330 this.financialObjectActiveIndicator = financialObjectActiveIndicator;
331 }
332
333
334
335
336
337
338
339 public String getFinancialBudgetAggregationCd() {
340 return financialBudgetAggregationCd;
341 }
342
343
344
345
346
347
348 public void setFinancialBudgetAggregationCd(String financialBudgetAggregationCd) {
349 this.financialBudgetAggregationCd = financialBudgetAggregationCd;
350 }
351
352
353
354
355
356
357
358 public String getFinObjMandatoryTrnfrOrElimCd() {
359 return finObjMandatoryTrnfrOrElimCd;
360 }
361
362
363
364
365
366
367 public void setFinObjMandatoryTrnfrOrElimCd(String finObjMandatoryTrnfrOrElimCd) {
368 this.finObjMandatoryTrnfrOrElimCd = finObjMandatoryTrnfrOrElimCd;
369 }
370
371
372
373
374
375
376
377 public String getFinancialFederalFundedCode() {
378 return financialFederalFundedCode;
379 }
380
381
382
383
384
385
386 public void setFinancialFederalFundedCode(String financialFederalFundedCode) {
387 this.financialFederalFundedCode = financialFederalFundedCode;
388 }
389
390
391
392
393
394
395
396 public String getNextYearFinancialObjectCode() {
397 return nextYearFinancialObjectCode;
398 }
399
400
401
402
403
404
405 public void setNextYearFinancialObjectCode(String nextYearFinancialObjectCode) {
406 this.nextYearFinancialObjectCode = nextYearFinancialObjectCode;
407 }
408
409
410
411
412
413
414
415 public DocumentHeader getFinancialDocument() {
416 return financialDocument;
417 }
418
419
420
421
422
423
424
425 @Deprecated
426 public void setFinancialDocument(DocumentHeader financialDocument) {
427 this.financialDocument = financialDocument;
428 }
429
430
431
432
433
434
435 public ObjectCode getFinancialObject() {
436 return financialObject;
437 }
438
439
440
441
442
443
444
445 @Deprecated
446 public void setFinancialObject(ObjectCode financialObject) {
447 this.financialObject = financialObject;
448 }
449
450
451
452
453
454
455 public ObjectCode getReportsToFinancialObject() {
456 return reportsToFinancialObject;
457 }
458
459
460
461
462
463
464
465 @Deprecated
466 public void setReportsToFinancialObject(ObjectCode reportsToFinancialObject) {
467 this.reportsToFinancialObject = reportsToFinancialObject;
468 }
469
470
471
472
473
474
475 public SystemOptions getUniversityFiscal() {
476 return universityFiscal;
477 }
478
479
480
481
482
483
484
485 @Deprecated
486 public void setUniversityFiscal(SystemOptions universityFiscal) {
487 this.universityFiscal = universityFiscal;
488 }
489
490
491
492
493
494
495 public Chart getChartOfAccounts() {
496 return chartOfAccounts;
497 }
498
499
500
501
502
503
504
505 @Deprecated
506 public void setChartOfAccounts(Chart chartOfAccounts) {
507 this.chartOfAccounts = chartOfAccounts;
508 }
509
510
511
512
513
514
515 public Chart getReportsToChartOfAccounts() {
516 return reportsToChartOfAccounts;
517 }
518
519
520
521
522
523
524
525 @Deprecated
526 public void setReportsToChartOfAccounts(Chart reportsToChartOfAccounts) {
527 this.reportsToChartOfAccounts = reportsToChartOfAccounts;
528 }
529
530
531
532
533
534
535 public ObjectSubType getFinancialObjectSubType() {
536 return financialObjectSubType;
537 }
538
539
540
541
542
543
544
545 @Deprecated
546 public void setFinancialObjectSubType(ObjectSubType financialObjectSubType) {
547 this.financialObjectSubType = financialObjectSubType;
548 }
549
550
551
552
553
554
555 public ObjectType getFinancialObjectType() {
556 return financialObjectType;
557 }
558
559
560
561
562
563
564
565 @Deprecated
566 public void setFinancialObjectType(ObjectType financialObjectType) {
567 this.financialObjectType = financialObjectType;
568 }
569
570
571
572
573
574
575 public BudgetAggregationCode getFinancialBudgetAggregation() {
576 return financialBudgetAggregation;
577 }
578
579
580
581
582
583
584
585 @Deprecated
586 public void setFinancialBudgetAggregation(BudgetAggregationCode financialBudgetAggregation) {
587 this.financialBudgetAggregation = financialBudgetAggregation;
588 }
589
590
591
592
593
594
595 public FederalFundedCode getFinancialFederalFunded() {
596 return financialFederalFunded;
597 }
598
599
600
601
602
603
604
605 @Deprecated
606 public void setFinancialFederalFunded(FederalFundedCode financialFederalFunded) {
607 this.financialFederalFunded = financialFederalFunded;
608 }
609
610
611
612
613
614
615 public ObjectLevel getFinancialObjectLevel() {
616 return financialObjectLevel;
617 }
618
619
620
621
622
623
624
625 @Deprecated
626 public void setFinancialObjectLevel(ObjectLevel financialObjectLevel) {
627 this.financialObjectLevel = financialObjectLevel;
628 }
629
630
631
632
633
634
635 public MandatoryTransferEliminationCode getFinObjMandatoryTrnfrelim() {
636 return finObjMandatoryTrnfrelim;
637 }
638
639
640
641
642
643
644
645 @Deprecated
646 public void setFinObjMandatoryTrnfrelim(MandatoryTransferEliminationCode finObjMandatoryTrnfrelim) {
647 this.finObjMandatoryTrnfrelim = finObjMandatoryTrnfrelim;
648 }
649
650
651
652
653 protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
654 LinkedHashMap<String,String> m = new LinkedHashMap<String,String>();
655 m.put(OLEPropertyConstants.DOCUMENT_NUMBER, this.documentNumber);
656 return m;
657 }
658
659 public List<ObjectCodeGlobalDetail> getObjectCodeGlobalDetails() {
660 return objectCodeGlobalDetails;
661 }
662
663 public void setObjectCodeGlobalDetails(List<ObjectCodeGlobalDetail> objectCodeGlobalDetails) {
664 this.objectCodeGlobalDetails = objectCodeGlobalDetails;
665 }
666
667
668
669
670 @Override
671 public List<PersistableBusinessObject> generateDeactivationsToPersist() {
672 return null;
673 }
674
675
676
677
678
679
680 @Override
681 public List<PersistableBusinessObject> generateGlobalChangesToPersist() {
682 LOG.debug("applyGlobalChanges");
683 List<PersistableBusinessObject> persistables = new ArrayList<PersistableBusinessObject>();
684
685
686
687
688 for (ObjectCodeGlobalDetail detail : objectCodeGlobalDetails) {
689
690 Map pk = new HashMap();
691
692 Integer fiscalYear = detail.getUniversityFiscalYear();
693 String chart = detail.getChartOfAccountsCode();
694
695 if (fiscalYear != null && chart != null && chart.length() > 0) {
696 pk.put("UNIV_FISCAL_YR", fiscalYear);
697 pk.put("FIN_COA_CD", chart);
698 pk.put("FIN_OBJECT_CD", financialObjectCode);
699
700 ObjectCode objectCode = SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(ObjectCode.class, pk);
701 if (objectCode == null) {
702 objectCode = new ObjectCode(fiscalYear, chart, financialObjectCode);
703 objectCode.setFinancialObjectActiveCode(true);
704 }
705 populate(objectCode, detail);
706 Map<String, String> hierarchy = SpringContext.getBean(ChartService.class).getReportsToHierarchy();
707 objectCode.setReportsToChartOfAccountsCode(hierarchy.get(chart));
708
709 persistables.add(objectCode);
710 }
711 }
712
713 return persistables;
714 }
715
716 public void populate(ObjectCode old, ObjectCodeGlobalDetail detail) {
717
718 old.setFinancialObjectCodeName(update(financialObjectCodeName, old.getFinancialObjectCodeName()));
719 old.setFinancialObjectCodeShortName(update(financialObjectCodeShortName, old.getFinancialObjectCodeShortName()));
720
721 old.setFinancialObjectLevelCode(update(financialObjectLevelCode, old.getFinancialObjectLevelCode()));
722 old.setFinancialObjectTypeCode(update(financialObjectTypeCode, old.getFinancialObjectTypeCode()));
723 old.setFinancialObjectSubTypeCode(update(financialObjectSubTypeCode, old.getFinancialObjectSubTypeCode()));
724 old.setHistoricalFinancialObjectCode(update(historicalFinancialObjectCode, old.getHistoricalFinancialObjectCode()));
725 old.setFinancialObjectActiveCode(update(financialObjectActiveIndicator, old.isFinancialObjectActiveCode()));
726 old.setFinancialBudgetAggregationCd(update(financialBudgetAggregationCd, old.getFinancialBudgetAggregationCd()));
727 old.setFinObjMandatoryTrnfrelimCd(update(finObjMandatoryTrnfrOrElimCd, old.getFinObjMandatoryTrnfrelimCd()));
728 old.setFinancialFederalFundedCode(update(financialFederalFundedCode, old.getFinancialFederalFundedCode()));
729 old.setNextYearFinancialObjectCode(update(nextYearFinancialObjectCode, old.getNextYearFinancialObjectCode()));
730 old.setReportsToFinancialObjectCode(update(reportsToFinancialObjectCode, old.getReportsToFinancialObjectCode()));
731 }
732
733
734
735
736
737
738
739
740
741 private String update(String newValue, String oldValue) {
742 if (newValue == null || newValue.length() == 0) {
743 return oldValue;
744 }
745 return newValue;
746 }
747
748 private boolean update(boolean newValue, boolean oldValue) {
749 return newValue;
750 }
751
752
753 @Override
754 public boolean isPersistable() {
755 return true;
756 }
757
758 @Override
759 public List<? extends GlobalBusinessObjectDetail> getAllDetailObjects() {
760 return getObjectCodeGlobalDetails();
761 }
762
763
764
765
766 @Override
767 public List<Collection<PersistableBusinessObject>> buildListOfDeletionAwareLists() {
768 List<Collection<PersistableBusinessObject>> managedLists = super.buildListOfDeletionAwareLists();
769
770 managedLists.add( new ArrayList<PersistableBusinessObject>( getObjectCodeGlobalDetails() ) );
771
772 return managedLists;
773 }
774 }