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.sql.Date;
19 import java.util.HashMap;
20 import java.util.HashSet;
21 import java.util.Map;
22 import java.util.Properties;
23 import java.util.Set;
24
25 import org.apache.commons.lang.StringUtils;
26 import org.apache.log4j.Logger;
27 import org.kuali.ole.coa.service.OrganizationService;
28 import org.kuali.ole.sys.OLEConstants;
29 import org.kuali.ole.sys.context.SpringContext;
30 import org.kuali.rice.core.api.config.property.ConfigurationService;
31 import org.kuali.rice.core.api.mo.common.active.MutableInactivatable;
32 import org.kuali.rice.kim.api.identity.Person;
33 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
34 import org.kuali.rice.krad.service.KualiModuleService;
35 import org.kuali.rice.krad.service.ModuleService;
36 import org.kuali.rice.krad.util.UrlFactory;
37 import org.kuali.rice.location.api.LocationConstants;
38 import org.kuali.rice.location.framework.campus.CampusEbo;
39 import org.kuali.rice.location.framework.country.CountryEbo;
40 import org.kuali.rice.location.framework.postalcode.PostalCodeEbo;
41
42
43
44
45 public class Organization extends PersistableBusinessObjectBase implements MutableInactivatable {
46 private static final Logger LOG = Logger.getLogger(Organization.class);
47
48 private static final long serialVersionUID = 121873645110037203L;
49
50 public static final String CACHE_NAME = OLEConstants.APPLICATION_NAMESPACE_CODE + "/" + "Organization";
51
52 protected String organizationCode;
53 protected String organizationName;
54 protected String organizationCityName;
55 protected String organizationStateCode;
56 protected String organizationZipCode;
57 protected Date organizationBeginDate;
58 protected Date organizationEndDate;
59 protected boolean organizationInFinancialProcessingIndicator = false;
60 protected String organizationManagerUniversalId;
61 protected String responsibilityCenterCode;
62 protected String organizationPhysicalCampusCode;
63 protected String organizationTypeCode;
64 protected String reportsToChartOfAccountsCode;
65 protected String reportsToOrganizationCode;
66 protected String organizationPlantAccountNumber;
67 protected String campusPlantAccountNumber;
68 protected String organizationPlantChartCode;
69 protected String campusPlantChartCode;
70 protected String organizationCountryCode;
71 protected String organizationLine1Address;
72 protected String organizationLine2Address;
73
74 protected Chart chartOfAccounts;
75 protected Organization hrisOrganization;
76 protected Account organizationDefaultAccount;
77 protected Person organizationManagerUniversal;
78 protected ResponsibilityCenter responsibilityCenter;
79 protected CampusEbo organizationPhysicalCampus;
80 protected OrganizationType organizationType;
81 protected Organization reportsToOrganization;
82 protected Chart reportsToChartOfAccounts;
83 protected Account organizationPlantAccount;
84 protected Account campusPlantAccount;
85 protected Chart organizationPlantChart;
86 protected Chart campusPlantChart;
87 protected PostalCodeEbo postalZip;
88 protected CountryEbo organizationCountry;
89
90
91 protected OrganizationExtension organizationExtension;
92 protected String editHrmsUnitSectionBlank;
93 protected String editHrmsUnitSection;
94
95
96 protected String organizationDefaultAccountNumber;
97 protected String chartOfAccountsCode;
98
99
100 protected String editPlantAccountsSectionBlank;
101 protected String editPlantAccountsSection;
102
103 protected boolean active = true;
104
105
106
107
108
109
110 public String getOrganizationCode() {
111 return organizationCode;
112 }
113
114
115
116
117
118
119 public void setOrganizationCode(String organizationCode) {
120 this.organizationCode = organizationCode;
121 }
122
123
124
125
126
127
128 public String getOrganizationName() {
129 return organizationName;
130 }
131
132
133
134
135
136
137 public void setOrganizationName(String organizationName) {
138 this.organizationName = organizationName;
139 }
140
141
142
143
144
145
146 public String getOrganizationCityName() {
147 return organizationCityName;
148 }
149
150
151
152
153
154
155 public void setOrganizationCityName(String organizationCityName) {
156 this.organizationCityName = organizationCityName;
157 }
158
159
160
161
162
163
164 public String getOrganizationStateCode() {
165 return organizationStateCode;
166 }
167
168
169
170
171
172
173 public void setOrganizationStateCode(String organizationStateCode) {
174 this.organizationStateCode = organizationStateCode;
175 }
176
177
178
179
180
181
182 public String getOrganizationZipCode() {
183 return organizationZipCode;
184 }
185
186
187
188
189
190
191 public void setOrganizationZipCode(String organizationZipCode) {
192 this.organizationZipCode = organizationZipCode;
193 }
194
195
196
197
198
199
200 public Date getOrganizationBeginDate() {
201 return organizationBeginDate;
202 }
203
204
205
206
207
208
209 public void setOrganizationBeginDate(Date organizationBeginDate) {
210 this.organizationBeginDate = organizationBeginDate;
211 }
212
213
214
215
216
217
218 public Date getOrganizationEndDate() {
219 return organizationEndDate;
220 }
221
222
223
224
225
226
227 public void setOrganizationEndDate(Date organizationEndDate) {
228 this.organizationEndDate = organizationEndDate;
229 }
230
231
232
233
234
235
236 public boolean isOrganizationInFinancialProcessingIndicator() {
237 return organizationInFinancialProcessingIndicator;
238 }
239
240
241
242
243
244
245 public void setOrganizationInFinancialProcessingIndicator(boolean organizationInFinancialProcessingIndicator) {
246 this.organizationInFinancialProcessingIndicator = organizationInFinancialProcessingIndicator;
247 }
248
249
250
251
252
253
254 public Chart getChartOfAccounts() {
255 return chartOfAccounts;
256 }
257
258
259
260
261
262
263
264 @Deprecated
265 public void setChartOfAccounts(Chart chartOfAccounts) {
266 this.chartOfAccounts = chartOfAccounts;
267 }
268
269
270
271
272
273
274 public Account getOrganizationDefaultAccount() {
275 return organizationDefaultAccount;
276 }
277
278
279
280
281
282
283
284 @Deprecated
285 public void setOrganizationDefaultAccount(Account organizationDefaultAccount) {
286 this.organizationDefaultAccount = organizationDefaultAccount;
287 }
288
289 public Person getOrganizationManagerUniversal() {
290 organizationManagerUniversal = SpringContext.getBean(org.kuali.rice.kim.api.identity.PersonService.class).updatePersonIfNecessary(organizationManagerUniversalId, organizationManagerUniversal);
291 return organizationManagerUniversal;
292 }
293
294
295
296
297
298
299
300 @Deprecated
301 public void setOrganizationManagerUniversal(Person organizationManagerUniversal) {
302 this.organizationManagerUniversal = organizationManagerUniversal;
303 }
304
305
306
307
308
309
310 public ResponsibilityCenter getResponsibilityCenter() {
311 return responsibilityCenter;
312 }
313
314
315
316
317
318
319
320 @Deprecated
321 public void setResponsibilityCenter(ResponsibilityCenter responsibilityCenter) {
322 this.responsibilityCenter = responsibilityCenter;
323 }
324
325
326
327
328
329
330 public CampusEbo getOrganizationPhysicalCampus() {
331 if ( StringUtils.isBlank(organizationPhysicalCampusCode) ) {
332 organizationPhysicalCampus = null;
333 } else {
334 if ( organizationPhysicalCampus == null || !StringUtils.equals( organizationPhysicalCampus.getCode(),organizationPhysicalCampusCode) ) {
335 ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(CampusEbo.class);
336 if ( moduleService != null ) {
337 Map<String,Object> keys = new HashMap<String, Object>(1);
338 keys.put(LocationConstants.PrimaryKeyConstants.CODE, organizationPhysicalCampusCode);
339 organizationPhysicalCampus = moduleService.getExternalizableBusinessObject(CampusEbo.class, keys);
340 } else {
341 throw new RuntimeException( "CONFIGURATION ERROR: No responsible module found for EBO class. Unable to proceed." );
342 }
343 }
344 }
345 return organizationPhysicalCampus;
346 }
347
348
349
350
351
352
353
354 @Deprecated
355 public void setOrganizationPhysicalCampus(CampusEbo organizationPhysicalCampus) {
356 this.organizationPhysicalCampus = organizationPhysicalCampus;
357 }
358
359
360
361
362
363
364 public OrganizationType getOrganizationType() {
365 return organizationType;
366 }
367
368
369
370
371
372
373
374 @Deprecated
375 public void setOrganizationType(OrganizationType organizationType) {
376 this.organizationType = organizationType;
377 }
378
379
380
381
382
383
384 public Organization getReportsToOrganization() {
385 return reportsToOrganization;
386 }
387
388
389
390
391
392
393
394 @Deprecated
395 public void setReportsToOrganization(Organization reportsToOrganization) {
396 this.reportsToOrganization = reportsToOrganization;
397 }
398
399
400
401
402
403
404 public Chart getReportsToChartOfAccounts() {
405 return reportsToChartOfAccounts;
406 }
407
408
409
410
411
412
413
414 @Deprecated
415 public void setReportsToChartOfAccounts(Chart reportsToChartOfAccounts) {
416 this.reportsToChartOfAccounts = reportsToChartOfAccounts;
417 }
418
419
420
421
422
423
424 public Account getOrganizationPlantAccount() {
425 return organizationPlantAccount;
426 }
427
428
429
430
431
432
433
434 @Deprecated
435 public void setOrganizationPlantAccount(Account organizationPlantAccount) {
436 this.organizationPlantAccount = organizationPlantAccount;
437 }
438
439
440
441
442
443
444 public Account getCampusPlantAccount() {
445 return campusPlantAccount;
446 }
447
448
449
450
451
452
453
454 @Deprecated
455 public void setCampusPlantAccount(Account campusPlantAccount) {
456 this.campusPlantAccount = campusPlantAccount;
457 }
458
459
460
461
462
463
464 public Chart getOrganizationPlantChart() {
465 return organizationPlantChart;
466 }
467
468
469
470
471
472
473
474 @Deprecated
475 public void setOrganizationPlantChart(Chart organizationPlantChart) {
476 this.organizationPlantChart = organizationPlantChart;
477 }
478
479
480
481
482
483
484 public Chart getCampusPlantChart() {
485 return campusPlantChart;
486 }
487
488
489
490
491
492
493
494 @Deprecated
495 public void setCampusPlantChart(Chart campusPlantChart) {
496 this.campusPlantChart = campusPlantChart;
497 }
498
499
500
501
502
503
504 public CountryEbo getOrganizationCountry() {
505 if ( StringUtils.isBlank(organizationCountryCode) ) {
506 organizationCountry = null;
507 } else {
508 if ( organizationCountry == null || !StringUtils.equals( organizationCountry.getCode(),organizationCountryCode) ) {
509 ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(CountryEbo.class);
510 if ( moduleService != null ) {
511 Map<String,Object> keys = new HashMap<String, Object>(1);
512 keys.put(LocationConstants.PrimaryKeyConstants.CODE, organizationCountryCode);
513 organizationCountry = moduleService.getExternalizableBusinessObject(CountryEbo.class, keys);
514 } else {
515 throw new RuntimeException( "CONFIGURATION ERROR: No responsible module found for EBO class. Unable to proceed." );
516 }
517 }
518 }
519 return organizationCountry;
520 }
521
522
523
524
525
526
527
528 @Deprecated
529 public void setOrganizationCountry(CountryEbo organizationCountry) {
530 this.organizationCountry = organizationCountry;
531 }
532
533
534
535
536
537
538 public String getChartOfAccountsCode() {
539 return chartOfAccountsCode;
540 }
541
542
543
544
545
546
547 public void setChartOfAccountsCode(String chartOfAccountsCode) {
548 this.chartOfAccountsCode = chartOfAccountsCode;
549 }
550
551
552
553
554
555
556 public String getOrganizationDefaultAccountNumber() {
557 return organizationDefaultAccountNumber;
558 }
559
560
561
562
563
564
565 public void setOrganizationDefaultAccountNumber(String organizationDefaultAccountNumber) {
566 this.organizationDefaultAccountNumber = organizationDefaultAccountNumber;
567 }
568
569
570
571
572 public String getCampusPlantAccountNumber() {
573 return campusPlantAccountNumber;
574 }
575
576
577
578
579 public void setCampusPlantAccountNumber(String campusPlantAccountNumber) {
580 this.campusPlantAccountNumber = campusPlantAccountNumber;
581 }
582
583
584
585
586 public String getCampusPlantChartCode() {
587 return campusPlantChartCode;
588 }
589
590
591
592
593 public void setCampusPlantChartCode(String campusPlantChartCode) {
594 this.campusPlantChartCode = campusPlantChartCode;
595 }
596
597
598
599
600 public String getOrganizationManagerUniversalId() {
601 return organizationManagerUniversalId;
602 }
603
604
605
606
607 public void setOrganizationManagerUniversalId(String organizationManagerUniversalId) {
608 this.organizationManagerUniversalId = organizationManagerUniversalId;
609 }
610
611
612
613
614 public String getOrganizationPhysicalCampusCode() {
615 return organizationPhysicalCampusCode;
616 }
617
618
619
620
621 public void setOrganizationPhysicalCampusCode(String organizationPhysicalCampusCode) {
622 this.organizationPhysicalCampusCode = organizationPhysicalCampusCode;
623 }
624
625
626
627
628 public String getOrganizationPlantAccountNumber() {
629 return organizationPlantAccountNumber;
630 }
631
632
633
634
635 public void setOrganizationPlantAccountNumber(String organizationPlantAccountNumber) {
636 this.organizationPlantAccountNumber = organizationPlantAccountNumber;
637 }
638
639
640
641
642 public String getOrganizationPlantChartCode() {
643 return organizationPlantChartCode;
644 }
645
646
647
648
649 public void setOrganizationPlantChartCode(String organizationPlantChartCode) {
650 this.organizationPlantChartCode = organizationPlantChartCode;
651 }
652
653
654
655
656 public String getOrganizationTypeCode() {
657 return organizationTypeCode;
658 }
659
660
661
662
663 public void setOrganizationTypeCode(String organizationTypeCode) {
664 this.organizationTypeCode = organizationTypeCode;
665 }
666
667
668
669
670 public String getReportsToChartOfAccountsCode() {
671 return reportsToChartOfAccountsCode;
672 }
673
674
675
676
677 public void setReportsToChartOfAccountsCode(String reportsToChartOfAccountsCode) {
678 this.reportsToChartOfAccountsCode = reportsToChartOfAccountsCode;
679 }
680
681
682
683
684 public String getReportsToOrganizationCode() {
685 return reportsToOrganizationCode;
686 }
687
688
689
690
691 public void setReportsToOrganizationCode(String reportsToOrganizationCode) {
692 this.reportsToOrganizationCode = reportsToOrganizationCode;
693 }
694
695
696
697
698 public String getResponsibilityCenterCode() {
699 return responsibilityCenterCode;
700 }
701
702
703
704
705 public void setResponsibilityCenterCode(String responsibilityCenterCode) {
706 this.responsibilityCenterCode = responsibilityCenterCode;
707 }
708
709
710
711
712
713
714 public PostalCodeEbo getPostalZip() {
715 if ( StringUtils.isBlank(organizationZipCode) || StringUtils.isBlank(organizationCountryCode) ) {
716 postalZip = null;
717 } else {
718 if ( postalZip == null || !StringUtils.equals( postalZip.getCode(),organizationZipCode) || !StringUtils.equals(postalZip.getCountryCode(), organizationCountryCode ) ) {
719 ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(PostalCodeEbo.class);
720 if ( moduleService != null ) {
721 Map<String,Object> keys = new HashMap<String, Object>(2);
722 keys.put(LocationConstants.PrimaryKeyConstants.COUNTRY_CODE, organizationCountryCode);
723 keys.put(LocationConstants.PrimaryKeyConstants.CODE, organizationZipCode);
724 postalZip = moduleService.getExternalizableBusinessObject(PostalCodeEbo.class, keys);
725 } else {
726 throw new RuntimeException( "CONFIGURATION ERROR: No responsible module found for EBO class. Unable to proceed." );
727 }
728 }
729 }
730 return postalZip;
731 }
732
733
734
735
736
737
738 public void setPostalZip(PostalCodeEbo postalZip) {
739 this.postalZip = postalZip;
740 }
741
742
743
744
745
746
747 public String getOrganizationCountryCode() {
748 return organizationCountryCode;
749 }
750
751
752
753
754
755
756 public void setOrganizationCountryCode(String organizationCountryCode) {
757 this.organizationCountryCode = organizationCountryCode;
758 }
759
760
761
762
763
764
765 public String getOrganizationLine1Address() {
766 return organizationLine1Address;
767 }
768
769
770
771
772
773
774 public void setOrganizationLine1Address(String organizationLine1Address) {
775 this.organizationLine1Address = organizationLine1Address;
776 }
777
778
779
780
781
782
783 public String getOrganizationLine2Address() {
784 return organizationLine2Address;
785 }
786
787
788
789
790
791
792 public void setOrganizationLine2Address(String organizationLine2Address) {
793 this.organizationLine2Address = organizationLine2Address;
794 }
795
796
797
798
799
800
801 public String getEditPlantAccountsSection() {
802 return editPlantAccountsSection;
803 }
804
805
806
807
808
809
810 public String getEditPlantAccountsSectionBlank() {
811 return editPlantAccountsSectionBlank;
812 }
813
814
815
816
817
818
819 public final String getEditHrmsUnitSection() {
820 return editHrmsUnitSection;
821 }
822
823
824
825
826
827
828 public final void setEditHrmsUnitSection(String editHrmsUnitSection) {
829 this.editHrmsUnitSection = editHrmsUnitSection;
830 }
831
832
833
834
835
836
837 public final String getEditHrmsUnitSectionBlank() {
838 return editHrmsUnitSectionBlank;
839 }
840
841
842
843
844
845
846 public final void setEditHrmsUnitSectionBlank(String editHrmsUnitSectionBlank) {
847 this.editHrmsUnitSectionBlank = editHrmsUnitSectionBlank;
848 }
849
850
851
852
853
854
855 public final OrganizationExtension getOrganizationExtension() {
856 return organizationExtension;
857 }
858
859
860
861
862
863
864 public final void setOrganizationExtension(OrganizationExtension organizationExtension) {
865 this.organizationExtension = organizationExtension;
866 }
867
868 public String getOrganizationHierarchy() {
869 OrganizationService organizationService = SpringContext.getBean(OrganizationService.class);
870 StringBuffer result = new StringBuffer();
871 Set<Organization> seen = new HashSet<Organization>();
872
873 Organization org = this;
874
875 while (org != null && org.getReportsToOrganizationCode() != null && !seen.contains(org)) {
876 String rChart = org.getReportsToChartOfAccountsCode();
877 String rOrg = org.getReportsToOrganizationCode();
878
879 seen.add(org);
880 org = organizationService.getByPrimaryIdWithCaching(rChart, rOrg);
881
882 result.append(rChart).append("/").append(rOrg).append(" ");
883 result.append(((org == null) ? "" : org.getOrganizationName()));
884 if (org != null && org.getReportsToOrganizationCode() != null && !seen.contains(org)) {
885 result.append(" ==> ");
886 }
887 result.append("\n");
888 }
889
890 return result.toString();
891 }
892
893 public String getOrganizationReviewHierarchy() {
894
895 Properties params = new Properties();
896 params.put("methodToCall", "start");
897 params.put("docFormKey", "");
898 params.put("lookupableImplServiceName", "RuleBaseValuesLookupableImplService");
899 params.put("fin_coa_cd", this.chartOfAccountsCode);
900 params.put("org_cd", this.organizationCode);
901 params.put("conversionFields", "");
902 params.put("returnLocation", "");
903 params.put("active_ind", "true");
904 params.put("ruleTemplateName", "KualiOrgReviewTemplate");
905
906 return UrlFactory.parameterizeUrl(SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(OLEConstants.WORKFLOW_URL_KEY) + "/Lookup.do", params);
907 }
908
909
910
911
912
913
914 public String getOrganizationPhysicalCampusCodeForReport() {
915 return organizationPhysicalCampusCode;
916 }
917
918
919
920
921
922
923 @Override
924 public boolean equals(Object obj) {
925 boolean equal = false;
926
927 if (obj != null) {
928
929 if (this == obj) {
930 return true;
931 }
932
933 if (this.getClass().isAssignableFrom(obj.getClass())) {
934
935 Organization other = (Organization) obj;
936
937 if (StringUtils.equals(this.getChartOfAccountsCode(), other.getChartOfAccountsCode())) {
938 if (StringUtils.equals(this.getOrganizationCode(), other.getOrganizationCode())) {
939 equal = true;
940 }
941 }
942 }
943 }
944
945 return equal;
946 }
947
948
949
950
951 public String getCodeAndDescription() {
952 String theString = getOrganizationCode() + "-" + getOrganizationName();
953 return theString;
954 }
955
956
957
958
959 @Override
960 public int hashCode() {
961 String hashString = getChartOfAccountsCode() + "|" + getOrganizationCode();
962 return hashString.hashCode();
963 }
964
965 @Override
966 public boolean isActive() {
967 return active;
968 }
969
970 @Override
971 public void setActive(boolean active) {
972 this.active = active;
973 }
974
975
976
977
978
979
980 public String getOrganizationCodeForReport() {
981 return organizationCode;
982 }
983
984
985
986
987 @Override
988 public void refreshReferenceObject(String referenceObjectName) {
989 if (referenceObjectName.equals("organizationManagerUniversal")) {
990 getOrganizationManagerUniversal();
991 }
992 else {
993 super.refreshReferenceObject(referenceObjectName);
994 }
995 }
996 }