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.sql.Date;
20 import java.util.ArrayList;
21 import java.util.Collection;
22 import java.util.HashMap;
23 import java.util.List;
24 import java.util.Map;
25
26 import org.apache.commons.lang.StringUtils;
27 import org.kuali.ole.sys.OLEConstants;
28 import org.kuali.ole.sys.context.SpringContext;
29 import org.kuali.rice.kim.api.identity.Person;
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 import org.kuali.rice.krad.service.KualiModuleService;
37 import org.kuali.rice.krad.service.ModuleService;
38 import org.kuali.rice.krad.service.PersistenceStructureService;
39 import org.kuali.rice.location.api.LocationConstants;
40 import org.kuali.rice.location.framework.postalcode.PostalCodeEbo;
41 import org.kuali.rice.location.framework.state.StateEbo;
42
43
44
45
46 public class AccountGlobal extends PersistableBusinessObjectBase implements GlobalBusinessObject {
47
48 protected String documentNumber;
49 protected String accountFiscalOfficerSystemIdentifier;
50 protected String accountsSupervisorySystemsIdentifier;
51 protected String accountManagerSystemIdentifier;
52 protected String chartOfAccountsCode;
53 protected String organizationCode;
54 protected String subFundGroupCode;
55 protected String accountCityName;
56 protected String accountStateCode;
57 protected String accountStreetAddress;
58 protected String accountZipCode;
59 protected Date accountExpirationDate;
60 protected String continuationFinChrtOfAcctCd;
61 protected String continuationAccountNumber;
62 protected String incomeStreamFinancialCoaCode;
63 protected String incomeStreamAccountNumber;
64 protected String accountCfdaNumber;
65 protected String financialHigherEdFunctionCd;
66 protected String accountSufficientFundsCode;
67 protected Boolean pendingAcctSufficientFundsIndicator;
68 protected String accountSearchCriteriaTxt;
69 protected List<AccountGlobalDetail> accountGlobalDetails;
70
71 protected DocumentHeader financialDocument;
72 protected Person accountFiscalOfficerUser;
73 protected Person accountSupervisoryUser;
74 protected Person accountManagerUser;
75 protected Chart continuationFinChrtOfAcct;
76 protected Account continuationAccount;
77 protected Account incomeStreamAccount;
78 protected Chart incomeStreamFinancialCoa;
79 protected Chart chartOfAccounts;
80 protected Organization organization;
81 protected SubFundGroup subFundGroup;
82 protected StateEbo accountState;
83 protected HigherEducationFunction financialHigherEdFunction;
84 protected PostalCodeEbo postalZipCode;
85 protected SufficientFundsCode sufficientFundsCode;
86
87 protected CFDA cfda;
88
89 public CFDA getCfda() {
90 return cfda;
91 }
92
93 public void setCfda(CFDA cfda) {
94 this.cfda = cfda;
95 }
96
97
98 private String laborBenefitRateCategoryCode;
99
100
101
102
103
104 public AccountGlobal() {
105 accountGlobalDetails = new ArrayList<AccountGlobalDetail>();
106 }
107
108
109
110
111 @Override
112 public List<PersistableBusinessObject> generateDeactivationsToPersist() {
113 return null;
114 }
115
116
117
118
119 @Override
120 public List<PersistableBusinessObject> generateGlobalChangesToPersist() {
121
122
123
124 List<PersistableBusinessObject> persistables = new ArrayList<PersistableBusinessObject>();
125
126
127 for (AccountGlobalDetail detail : accountGlobalDetails) {
128
129
130 Account account = SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(Account.class, detail.getPrimaryKeys());
131
132
133 if (account != null) {
134
135
136
137
138
139
140 if (StringUtils.isNotBlank(accountFiscalOfficerSystemIdentifier)) {
141 account.setAccountFiscalOfficerSystemIdentifier(accountFiscalOfficerSystemIdentifier);
142 }
143
144
145 if (StringUtils.isNotBlank(accountsSupervisorySystemsIdentifier)) {
146 account.setAccountsSupervisorySystemsIdentifier(accountsSupervisorySystemsIdentifier);
147 }
148
149
150 if (StringUtils.isNotBlank(accountManagerSystemIdentifier)) {
151 account.setAccountManagerSystemIdentifier(accountManagerSystemIdentifier);
152 }
153
154
155 if (StringUtils.isNotBlank(organizationCode)) {
156 account.setOrganizationCode(organizationCode);
157 }
158
159
160 if (StringUtils.isNotBlank(subFundGroupCode)) {
161 account.setSubFundGroupCode(subFundGroupCode);
162 }
163
164
165 if (StringUtils.isNotBlank(accountCityName)) {
166 account.setAccountCityName(accountCityName);
167 }
168
169
170 if (StringUtils.isNotBlank(accountStateCode)) {
171 account.setAccountStateCode(accountStateCode);
172 }
173
174
175 if (StringUtils.isNotBlank(accountStreetAddress)) {
176 account.setAccountStreetAddress(accountStreetAddress);
177 }
178
179
180 if (StringUtils.isNotBlank(accountZipCode)) {
181 account.setAccountZipCode(accountZipCode);
182 }
183
184
185 if (accountExpirationDate != null) {
186 account.setAccountExpirationDate(new Date(accountExpirationDate.getTime()));
187 }
188
189
190 if (StringUtils.isNotBlank(continuationFinChrtOfAcctCd)) {
191 account.setContinuationFinChrtOfAcctCd(continuationFinChrtOfAcctCd);
192 }
193
194
195 if (StringUtils.isNotBlank(continuationAccountNumber)) {
196 account.setContinuationAccountNumber(continuationAccountNumber);
197 }
198
199
200 if (StringUtils.isNotBlank(incomeStreamFinancialCoaCode)) {
201 account.setIncomeStreamFinancialCoaCode(incomeStreamFinancialCoaCode);
202 }
203
204
205 if (StringUtils.isNotBlank(incomeStreamAccountNumber)) {
206 account.setIncomeStreamAccountNumber(incomeStreamAccountNumber);
207 }
208
209
210 if (StringUtils.isNotBlank(accountCfdaNumber)) {
211 account.setAccountCfdaNumber(accountCfdaNumber);
212 }
213
214
215 if (StringUtils.isNotBlank(financialHigherEdFunctionCd)) {
216 account.setFinancialHigherEdFunctionCd(financialHigherEdFunctionCd);
217 }
218
219
220 if (StringUtils.isNotBlank(accountSufficientFundsCode)) {
221 account.setAccountSufficientFundsCode(accountSufficientFundsCode);
222 }
223
224
225 if (StringUtils.isNotBlank(laborBenefitRateCategoryCode)) {
226 account.setLaborBenefitRateCategoryCode(laborBenefitRateCategoryCode);
227 }
228
229
230 if (pendingAcctSufficientFundsIndicator != null) {
231 account.setPendingAcctSufficientFundsIndicator(pendingAcctSufficientFundsIndicator);
232 }
233
234
235 if (StringUtils.isNotBlank(laborBenefitRateCategoryCode)) {
236 account.setLaborBenefitRateCategoryCode(laborBenefitRateCategoryCode);
237 }
238
239 persistables.add(account);
240
241 }
242 }
243
244 return persistables;
245 }
246
247
248
249
250
251
252 @Override
253 public String getDocumentNumber() {
254 return documentNumber;
255 }
256
257
258
259
260
261
262 @Override
263 public void setDocumentNumber(String documentNumber) {
264 this.documentNumber = documentNumber;
265 }
266
267
268
269
270
271
272 public String getChartOfAccountsCode() {
273 return chartOfAccountsCode;
274 }
275
276
277
278
279
280
281 public void setChartOfAccountsCode(String chartOfAccountsCode) {
282 this.chartOfAccountsCode = chartOfAccountsCode;
283 }
284
285
286
287
288
289
290 public String getOrganizationCode() {
291 return organizationCode;
292 }
293
294
295
296
297
298
299 public void setOrganizationCode(String organizationCode) {
300 this.organizationCode = organizationCode;
301 }
302
303
304
305
306
307
308 public String getSubFundGroupCode() {
309 return subFundGroupCode;
310 }
311
312
313
314
315
316
317 public void setSubFundGroupCode(String subFundGroupCode) {
318 this.subFundGroupCode = subFundGroupCode;
319 }
320
321
322
323
324
325
326 public String getAccountCityName() {
327 return accountCityName;
328 }
329
330
331
332
333
334
335 public void setAccountCityName(String accountCityName) {
336 this.accountCityName = accountCityName;
337 }
338
339
340
341
342
343
344
345 public String getAccountStateCode() {
346 return accountStateCode;
347 }
348
349
350
351
352
353
354 public void setAccountStateCode(String accountStateCode) {
355 this.accountStateCode = accountStateCode;
356 }
357
358
359
360
361
362
363
364 public String getAccountStreetAddress() {
365 return accountStreetAddress;
366 }
367
368
369
370
371
372
373 public void setAccountStreetAddress(String accountStreetAddress) {
374 this.accountStreetAddress = accountStreetAddress;
375 }
376
377
378
379
380
381
382
383 public String getAccountZipCode() {
384 return accountZipCode;
385 }
386
387
388
389
390
391
392 public void setAccountZipCode(String accountZipCode) {
393 this.accountZipCode = accountZipCode;
394 }
395
396
397
398
399
400
401 public Date getAccountExpirationDate() {
402 return accountExpirationDate;
403 }
404
405
406
407
408
409
410 public void setAccountExpirationDate(Date accountExpirationDate) {
411 this.accountExpirationDate = accountExpirationDate;
412 }
413
414
415
416
417
418
419
420 public String getContinuationFinChrtOfAcctCd() {
421 return continuationFinChrtOfAcctCd;
422 }
423
424
425
426
427
428
429 public void setContinuationFinChrtOfAcctCd(String continuationFinChrtOfAcctCd) {
430 this.continuationFinChrtOfAcctCd = continuationFinChrtOfAcctCd;
431 }
432
433
434
435
436
437
438
439 public String getContinuationAccountNumber() {
440 return continuationAccountNumber;
441 }
442
443
444
445
446
447
448 public void setContinuationAccountNumber(String continuationAccountNumber) {
449 this.continuationAccountNumber = continuationAccountNumber;
450 }
451
452
453
454
455
456
457 public String getIncomeStreamFinancialCoaCode() {
458 return incomeStreamFinancialCoaCode;
459 }
460
461
462
463
464
465
466 public void setIncomeStreamFinancialCoaCode(String incomeStreamFinancialCoaCode) {
467 this.incomeStreamFinancialCoaCode = incomeStreamFinancialCoaCode;
468 }
469
470
471
472
473
474
475
476 public String getIncomeStreamAccountNumber() {
477 return incomeStreamAccountNumber;
478 }
479
480
481
482
483
484
485 public void setIncomeStreamAccountNumber(String incomeStreamAccountNumber) {
486 this.incomeStreamAccountNumber = incomeStreamAccountNumber;
487 }
488
489
490
491
492
493
494 public String getAccountSufficientFundsCode() {
495 return accountSufficientFundsCode;
496 }
497
498
499
500
501
502
503 public void setAccountSufficientFundsCode(String accountSufficientFundsCode) {
504 this.accountSufficientFundsCode = accountSufficientFundsCode;
505 }
506
507
508
509
510
511
512
513 public Boolean getPendingAcctSufficientFundsIndicator() {
514 return pendingAcctSufficientFundsIndicator;
515 }
516
517
518
519
520
521
522
523 public void setPendingAcctSufficientFundsIndicator(Boolean pendingAcctSufficientFundsIndicator) {
524 this.pendingAcctSufficientFundsIndicator = pendingAcctSufficientFundsIndicator;
525 }
526
527
528
529
530
531
532 public String getAccountCfdaNumber() {
533 return accountCfdaNumber;
534 }
535
536
537
538
539
540
541 public void setAccountCfdaNumber(String accountCfdaNumber) {
542 this.accountCfdaNumber = accountCfdaNumber;
543 }
544
545
546
547
548
549
550 public String getAccountSearchCriteriaTxt() {
551 return accountSearchCriteriaTxt;
552 }
553
554
555
556
557
558
559 public void setAccountSearchCriteriaTxt(String accountSearchCriteriaTxt) {
560 this.accountSearchCriteriaTxt = accountSearchCriteriaTxt;
561 }
562
563
564
565
566
567
568
569 public DocumentHeader getFinancialDocument() {
570 return financialDocument;
571 }
572
573
574
575
576
577
578
579 @Deprecated
580 public void setFinancialDocument(DocumentHeader financialDocument) {
581 this.financialDocument = financialDocument;
582 }
583
584 public Person getAccountFiscalOfficerUser() {
585 accountFiscalOfficerUser = SpringContext.getBean(org.kuali.rice.kim.api.identity.PersonService.class).updatePersonIfNecessary(accountFiscalOfficerSystemIdentifier, accountFiscalOfficerUser);
586 return accountFiscalOfficerUser;
587 }
588
589
590
591
592
593
594 @Deprecated
595 public void setAccountFiscalOfficerUser(Person accountFiscalOfficerUser) {
596 this.accountFiscalOfficerUser = accountFiscalOfficerUser;
597 }
598
599 public Person getAccountManagerUser() {
600 accountManagerUser = SpringContext.getBean(org.kuali.rice.kim.api.identity.PersonService.class).updatePersonIfNecessary(accountManagerSystemIdentifier, accountManagerUser);
601 return accountManagerUser;
602 }
603
604
605
606
607
608 @Deprecated
609 public void setAccountManagerUser(Person accountManagerUser) {
610 this.accountManagerUser = accountManagerUser;
611 }
612
613
614 public Person getAccountSupervisoryUser() {
615 accountSupervisoryUser = SpringContext.getBean(org.kuali.rice.kim.api.identity.PersonService.class).updatePersonIfNecessary(accountsSupervisorySystemsIdentifier, accountSupervisoryUser);
616 return accountSupervisoryUser;
617 }
618
619
620
621
622
623
624 @Deprecated
625 public void setAccountSupervisoryUser(Person accountSupervisoryUser) {
626 this.accountSupervisoryUser = accountSupervisoryUser;
627 }
628
629
630
631
632
633
634 public Chart getContinuationFinChrtOfAcct() {
635 return continuationFinChrtOfAcct;
636 }
637
638
639
640
641
642
643
644 @Deprecated
645 public void setContinuationFinChrtOfAcct(Chart continuationFinChrtOfAcct) {
646 this.continuationFinChrtOfAcct = continuationFinChrtOfAcct;
647 }
648
649
650
651
652
653
654 public Account getContinuationAccount() {
655 return continuationAccount;
656 }
657
658
659
660
661
662
663
664 @Deprecated
665 public void setContinuationAccount(Account continuationAccount) {
666 this.continuationAccount = continuationAccount;
667 }
668
669
670
671
672
673
674 public Account getIncomeStreamAccount() {
675 return incomeStreamAccount;
676 }
677
678
679
680
681
682
683
684 @Deprecated
685 public void setIncomeStreamAccount(Account incomeStreamAccount) {
686 this.incomeStreamAccount = incomeStreamAccount;
687 }
688
689
690
691
692
693
694 public Chart getIncomeStreamFinancialCoa() {
695 return incomeStreamFinancialCoa;
696 }
697
698
699
700
701
702
703
704 @Deprecated
705 public void setIncomeStreamFinancialCoa(Chart incomeStreamFinancialCoa) {
706 this.incomeStreamFinancialCoa = incomeStreamFinancialCoa;
707 }
708
709
710
711
712 public List<AccountGlobalDetail> getAccountGlobalDetails() {
713 return accountGlobalDetails;
714 }
715
716
717
718
719 public void setAccountGlobalDetails(List<AccountGlobalDetail> accountGlobalDetails) {
720 this.accountGlobalDetails = accountGlobalDetails;
721 }
722
723
724
725
726
727
728 public String getFinancialHigherEdFunctionCd() {
729 return financialHigherEdFunctionCd;
730 }
731
732
733
734
735
736
737 public void setFinancialHigherEdFunctionCd(String financialHigherEdFunctionCd) {
738 this.financialHigherEdFunctionCd = financialHigherEdFunctionCd;
739 }
740
741
742
743
744
745
746 public String getAccountFiscalOfficerSystemIdentifier() {
747 return accountFiscalOfficerSystemIdentifier;
748 }
749
750
751
752
753
754
755 public void setAccountFiscalOfficerSystemIdentifier(String accountFiscalOfficerSystemIdentifier) {
756 this.accountFiscalOfficerSystemIdentifier = accountFiscalOfficerSystemIdentifier;
757 }
758
759
760
761
762
763
764 public String getAccountManagerSystemIdentifier() {
765 return accountManagerSystemIdentifier;
766 }
767
768
769
770
771
772
773 public void setAccountManagerSystemIdentifier(String accountManagerSystemIdentifier) {
774 this.accountManagerSystemIdentifier = accountManagerSystemIdentifier;
775 }
776
777
778
779
780
781
782 public String getAccountsSupervisorySystemsIdentifier() {
783 return accountsSupervisorySystemsIdentifier;
784 }
785
786
787
788
789
790
791 public void setAccountsSupervisorySystemsIdentifier(String accountsSupervisorySystemsIdentifier) {
792 this.accountsSupervisorySystemsIdentifier = accountsSupervisorySystemsIdentifier;
793 }
794
795
796
797
798
799
800 public Chart getChartOfAccounts() {
801 return chartOfAccounts;
802 }
803
804
805
806
807
808
809
810 @Deprecated
811 public void setChartOfAccounts(Chart chartOfAccounts) {
812 this.chartOfAccounts = chartOfAccounts;
813 }
814
815
816
817
818
819
820 public StateEbo getAccountState() {
821 if ( StringUtils.isBlank(accountStateCode) || StringUtils.isBlank(OLEConstants.COUNTRY_CODE_UNITED_STATES ) ) {
822 accountState = null;
823 } else {
824 if ( accountState == null || !StringUtils.equals( accountState.getCode(),accountStateCode) || !StringUtils.equals(accountState.getCountryCode(), OLEConstants.COUNTRY_CODE_UNITED_STATES ) ) {
825 ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(StateEbo.class);
826 if ( moduleService != null ) {
827 Map<String,Object> keys = new HashMap<String, Object>(2);
828 keys.put(LocationConstants.PrimaryKeyConstants.COUNTRY_CODE, OLEConstants.COUNTRY_CODE_UNITED_STATES);
829 keys.put(LocationConstants.PrimaryKeyConstants.CODE, accountStateCode);
830 accountState = moduleService.getExternalizableBusinessObject(StateEbo.class, keys);
831 } else {
832 throw new RuntimeException( "CONFIGURATION ERROR: No responsible module found for EBO class. Unable to proceed." );
833 }
834 }
835 }
836 return accountState;
837 }
838
839
840
841
842
843
844 public void setAccountState(StateEbo accountState) {
845 this.accountState = accountState;
846 }
847
848
849
850
851
852
853 public HigherEducationFunction getFinancialHigherEdFunction() {
854 return financialHigherEdFunction;
855 }
856
857
858
859
860
861
862 public void setFinancialHigherEdFunction(HigherEducationFunction financialHigherEdFunction) {
863 this.financialHigherEdFunction = financialHigherEdFunction;
864 }
865
866
867
868
869
870
871 public Organization getOrganization() {
872 return organization;
873 }
874
875
876
877
878
879
880 public void setOrganization(Organization organization) {
881 this.organization = organization;
882 }
883
884
885
886
887
888
889 public PostalCodeEbo getPostalZipCode() {
890 if ( StringUtils.isBlank(accountZipCode) || StringUtils.isBlank(OLEConstants.COUNTRY_CODE_UNITED_STATES ) ) {
891 postalZipCode = null;
892 } else {
893 if ( postalZipCode == null || !StringUtils.equals( postalZipCode.getCode(),accountZipCode) || !StringUtils.equals(postalZipCode.getCountryCode(), OLEConstants.COUNTRY_CODE_UNITED_STATES ) ) {
894 ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(PostalCodeEbo.class);
895 if ( moduleService != null ) {
896 Map<String,Object> keys = new HashMap<String, Object>(2);
897 keys.put(LocationConstants.PrimaryKeyConstants.COUNTRY_CODE, OLEConstants.COUNTRY_CODE_UNITED_STATES);
898 keys.put(LocationConstants.PrimaryKeyConstants.CODE, accountZipCode);
899 postalZipCode = moduleService.getExternalizableBusinessObject(PostalCodeEbo.class, keys);
900 } else {
901 throw new RuntimeException( "CONFIGURATION ERROR: No responsible module found for EBO class. Unable to proceed." );
902 }
903 }
904 }
905 return postalZipCode;
906 }
907
908
909
910
911
912
913 public void setPostalZipCode(PostalCodeEbo postalZipCode) {
914 this.postalZipCode = postalZipCode;
915 }
916
917
918
919
920
921
922 public SubFundGroup getSubFundGroup() {
923 return subFundGroup;
924 }
925
926
927
928
929
930
931 public void setSubFundGroup(SubFundGroup subFundGroup) {
932 this.subFundGroup = subFundGroup;
933 }
934
935
936
937
938
939
940 public final SufficientFundsCode getSufficientFundsCode() {
941 return sufficientFundsCode;
942 }
943
944
945
946
947
948
949 public final void setSufficientFundsCode(SufficientFundsCode sufficientFundsCode) {
950 this.sufficientFundsCode = sufficientFundsCode;
951 }
952
953
954
955
956 @Override
957 public boolean isPersistable() {
958 PersistenceStructureService persistenceStructureService = SpringContext.getBean(PersistenceStructureService.class);
959
960
961 if (StringUtils.isBlank(documentNumber)) {
962 return false;
963 }
964
965
966 for (AccountGlobalDetail account : getAccountGlobalDetails()) {
967 if (!persistenceStructureService.hasPrimaryKeyFieldValues(account)) {
968 return false;
969 }
970 }
971
972
973 return true;
974 }
975
976 @Override
977 public List<? extends GlobalBusinessObjectDetail> getAllDetailObjects() {
978 return accountGlobalDetails;
979 }
980
981
982
983
984 @Override
985 public List<Collection<PersistableBusinessObject>> buildListOfDeletionAwareLists() {
986 List<Collection<PersistableBusinessObject>> managedLists = super.buildListOfDeletionAwareLists();
987
988 managedLists.add( new ArrayList<PersistableBusinessObject>( getAccountGlobalDetails() ) );
989
990 return managedLists;
991 }
992
993
994
995
996
997
998 public String getLaborBenefitRateCategoryCode() {
999 return laborBenefitRateCategoryCode;
1000 }
1001
1002
1003
1004
1005
1006
1007 public void setLaborBenefitRateCategoryCode(String laborBenefitRateCategoryCode) {
1008 this.laborBenefitRateCategoryCode = laborBenefitRateCategoryCode;
1009 }
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030 }