1 package org.kuali.ole.patron.bo;
2
3 import org.apache.commons.collections.CollectionUtils;
4 import org.kuali.ole.deliver.loan.bo.OleLoanDocument;
5 import org.kuali.ole.deliver.loan.bo.OleTemporaryCirculationHistory;
6 import org.kuali.ole.deliver.request.bo.OleDeliverRequestBo;
7 import org.kuali.ole.patron.api.*;
8 import org.kuali.rice.kim.api.KimConstants;
9 import org.kuali.rice.kim.api.identity.address.EntityAddress;
10 import org.kuali.rice.kim.api.identity.affiliation.EntityAffiliation;
11 import org.kuali.rice.kim.api.identity.email.EntityEmail;
12 import org.kuali.rice.kim.api.identity.employment.EntityEmployment;
13 import org.kuali.rice.kim.api.identity.phone.EntityPhone;
14 import org.kuali.rice.kim.impl.identity.address.EntityAddressBo;
15 import org.kuali.rice.kim.impl.identity.affiliation.EntityAffiliationBo;
16 import org.kuali.rice.kim.impl.identity.affiliation.EntityAffiliationTypeBo;
17 import org.kuali.rice.kim.impl.identity.email.EntityEmailBo;
18 import org.kuali.rice.kim.impl.identity.employment.EntityEmploymentBo;
19 import org.kuali.rice.kim.impl.identity.entity.EntityBo;
20 import org.kuali.rice.kim.impl.identity.name.EntityNameBo;
21 import org.kuali.rice.kim.impl.identity.phone.EntityPhoneBo;
22 import org.kuali.rice.kim.impl.identity.type.EntityTypeContactInfoBo;
23 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
24
25 import java.util.*;
26
27
28
29
30 public class OlePatronDocument extends PersistableBusinessObjectBase implements OlePatronContract {
31
32 private String olePatronId;
33 private String barcode;
34 private String borrowerType;
35 private String affiliationType;
36 private boolean activeIndicator;
37 private boolean generalBlock;
38 private String generalBlockNotes;
39 private boolean pagingPrivilege;
40 private boolean courtesyNotice;
41 private boolean deliveryPrivilege;
42 private boolean realPatronCheck;
43 private Date expirationDate;
44 private Date activationDate;
45 private String firstName;
46 private String middleName;
47 private String lastName;
48 private String emailAddress;
49 private String phoneNumber;
50 private String borrowerTypeName;
51 private String processMessage;
52 private String source;
53 private String statisticalCategory;
54 private String oleSourceName;
55 private String oleStatisticalCategoryName;
56 private boolean patronBillFlag;
57 private String proxyPatronId;
58 private byte[] patronPhotograph;
59 private boolean loanFlag;
60 private boolean tempCircHistoryFlag;
61 private boolean requestFlag;
62
63 private List<OleLoanDocument> oleLoanDocuments = new ArrayList<OleLoanDocument>();
64 private List<EntityPhoneBo> phones = new ArrayList<EntityPhoneBo>();
65 private List<EntityAddressBo> addresses = new ArrayList<EntityAddressBo>();
66 private List<OleEntityAddressBo> oleEntityAddressBo = new ArrayList<OleEntityAddressBo>();
67 private EntityNameBo name = new EntityNameBo();
68 private List<OleAddressBo> oleAddresses = new ArrayList<OleAddressBo>();
69 private List<EntityEmailBo> emails = new ArrayList<EntityEmailBo>();
70 private List<OlePatronNotes> notes = new ArrayList<OlePatronNotes>();
71 private List<OlePatronLostBarcode> lostBarcodes = new ArrayList<OlePatronLostBarcode>();
72 private OleBorrowerType oleBorrowerType;
73 private EntityBo entity = new EntityBo();
74 private OleSourceBo sourceBo;
75 private OleStatisticalCategoryBo statisticalCategoryBo;
76 private List<OlePatronAffiliation> patronAffiliations = new ArrayList<OlePatronAffiliation>();
77 private List<EntityEmploymentBo> employments = new ArrayList<EntityEmploymentBo>();
78 private List<OleDeliverRequestBo> oleDeliverRequestBos = new ArrayList<OleDeliverRequestBo>();
79 private List<OleProxyPatronDocument> oleProxyPatronDocuments = new ArrayList<OleProxyPatronDocument>();
80 private List<OleTemporaryCirculationHistory> oleTemporaryCirculationHistoryRecords = new ArrayList<OleTemporaryCirculationHistory>();
81 private List<OlePatronLocalIdentificationBo> olePatronLocalIds = new ArrayList<OlePatronLocalIdentificationBo>();
82
83
84 public OlePatronDocument() {
85 this.setDeliveryPrivilege(true);
86 this.setPagingPrivilege(true);
87 }
88
89
90 public List<OleTemporaryCirculationHistory> getOleTemporaryCirculationHistoryRecords() {
91 return oleTemporaryCirculationHistoryRecords;
92 }
93
94 public void setOleTemporaryCirculationHistoryRecords(List<OleTemporaryCirculationHistory> oleTemporaryCirculationHistoryRecords) {
95 this.oleTemporaryCirculationHistoryRecords = oleTemporaryCirculationHistoryRecords;
96 }
97
98 public List<OleDeliverRequestBo> getOleDeliverRequestBos() {
99 return oleDeliverRequestBos;
100 }
101
102 public void setOleDeliverRequestBos(List<OleDeliverRequestBo> oleDeliverRequestBos) {
103 this.oleDeliverRequestBos = oleDeliverRequestBos;
104 }
105
106
107
108
109
110
111 public static OlePatronDefinition to(OlePatronDocument bo) {
112 if (bo == null) {
113 return null;
114 }
115 return OlePatronDefinition.Builder.create(bo).build();
116 }
117
118
119
120
121
122
123 public static OlePatronDocument from(OlePatronDefinition immutable) {
124 return fromAndUpdate(immutable, null);
125 }
126
127
128
129
130
131
132
133 static OlePatronDocument fromAndUpdate(OlePatronDefinition immutable, OlePatronDocument toUpdate) {
134 if (immutable == null) {
135 return null;
136 }
137 OlePatronDocument bo = toUpdate;
138 if (toUpdate == null) {
139 bo = new OlePatronDocument();
140 }
141
142 bo.olePatronId = immutable.getOlePatronId();
143
144 bo.name = new EntityNameBo();
145
146 if (immutable.getName() != null) {
147 bo.name = EntityNameBo.from(immutable.getName());
148 }
149
150 bo.barcode = immutable.getBarcode();
151 bo.borrowerType = immutable.getBorrowerType();
152 bo.courtesyNotice = immutable.isCourtesyNotice();
153 bo.generalBlock = immutable.isGeneralBlock();
154 bo.deliveryPrivilege = immutable.isDeliveryPrivilege();
155 bo.pagingPrivilege = immutable.isPagingPrivilege();
156 bo.expirationDate = immutable.getExpirationDate();
157 bo.activationDate = immutable.getActivationDate();
158 bo.activeIndicator = immutable.isActiveIndicator();
159 bo.generalBlockNotes = immutable.getGeneralBlockNotes();
160 bo.source = immutable.getSource();
161 bo.statisticalCategory = immutable.getStatisticalCategory();
162
163
164
165
166
167
168
169
170
171 if (immutable.getEntity() != null) {
172 bo.entity = EntityBo.from(immutable.getEntity());
173 }
174 if(immutable.getOleBorrowerType() != null) {
175 bo.oleBorrowerType = OleBorrowerType.from(immutable.getOleBorrowerType());
176 }
177 if (CollectionUtils.isNotEmpty(immutable.getAddresses())) {
178 for (EntityAddress entityAddr : immutable.getAddresses()) {
179 bo.addresses.add(EntityAddressBo.from(entityAddr));
180 }
181 }
182 if (CollectionUtils.isNotEmpty(immutable.getEmails())) {
183 for (EntityEmail entityEmail : immutable.getEmails()) {
184 bo.emails.add(EntityEmailBo.from(entityEmail));
185 }
186 }
187 if (CollectionUtils.isNotEmpty(immutable.getPhones())) {
188 for (EntityPhone entityPhone : immutable.getPhones()) {
189 bo.phones.add(EntityPhoneBo.from(entityPhone));
190 }
191 }
192
193 if (CollectionUtils.isNotEmpty(immutable.getNotes())) {
194 for (OlePatronNotesDefinition note : immutable.getNotes()) {
195 bo.notes.add(OlePatronNotes.from(note));
196 }
197 }
198 if (CollectionUtils.isNotEmpty(immutable.getLostBarcodes())) {
199 for (OlePatronLostBarcodeDefinition lostBarcode : immutable.getLostBarcodes()) {
200 bo.lostBarcodes.add(OlePatronLostBarcode.from(lostBarcode));
201 }
202 }
203 if (CollectionUtils.isNotEmpty(immutable.getOleEntityAddressBo())) {
204 for (OleEntityAddressDefinition address : immutable.getOleEntityAddressBo()) {
205 bo.oleEntityAddressBo.add(OleEntityAddressBo.from(address));
206 }
207 }
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229 if (CollectionUtils.isNotEmpty(immutable.getPatronAffiliations())) {
230 for (OlePatronAffiliationDefinition affiliation : immutable.getPatronAffiliations()) {
231 bo.patronAffiliations.add(OlePatronAffiliation.from(affiliation));
232 }
233 }
234 if (CollectionUtils.isNotEmpty(immutable.getOleProxyPatronDocuments())) {
235 for (OleProxyPatronDefinition proxyPatron : immutable.getOleProxyPatronDocuments()) {
236 bo.oleProxyPatronDocuments.add(OleProxyPatronDocument.from(proxyPatron));
237 }
238 }
239 if (CollectionUtils.isNotEmpty(immutable.getOleAddresses())) {
240 for (OleAddressDefinition oleAddress : immutable.getOleAddresses()) {
241 bo.oleAddresses.add(OleAddressBo.from(oleAddress));
242 }
243 }
244 if (CollectionUtils.isNotEmpty(immutable.getOlePatronLocalIds())) {
245 for (OlePatronLocalIdentificationDefinition olePatronLocalId : immutable.getOlePatronLocalIds()) {
246 bo.olePatronLocalIds.add(OlePatronLocalIdentificationBo.from(olePatronLocalId));
247 }
248 }
249
250 bo.versionNumber = immutable.getVersionNumber();
251
252 EntityBo entityBo = new EntityBo();
253 entityBo.setActive(true);
254
255 if (null != bo.getEntity()) {
256 entityBo = bo.getEntity();
257 entityBo.setActive(true);
258 }
259 if (CollectionUtils.isNotEmpty(immutable.getPatronAffiliations())) {
260 for (OlePatronAffiliationDefinition affiliation : immutable.getPatronAffiliations()) {
261 EntityAffiliationBo entityAffiliationBo = new EntityAffiliationBo();
262 entityAffiliationBo.setId(affiliation.getEntityAffiliationId());
263 entityAffiliationBo.setAffiliationTypeCode(affiliation.getAffiliationTypeCode());
264 entityAffiliationBo.setAffiliationType(EntityAffiliationTypeBo.from(affiliation.getAffiliationType()));
265 entityAffiliationBo.setActive(affiliation.isActive());
266 entityAffiliationBo.setDefaultValue(affiliation.isDefaultValue());
267 entityAffiliationBo.setCampusCode(affiliation.getCampusCode());
268 entityAffiliationBo.setObjectId(affiliation.getObjectId());
269 entityAffiliationBo.setVersionNumber(affiliation.getVersionNumber());
270 entityAffiliationBo.setEntityId(affiliation.getEntityId());
271
272 entityBo.getAffiliations().add(entityAffiliationBo);
273 for(EntityEmployment entityEmployment : affiliation.getEmployments()) {
274 entityBo.getEmploymentInformation().add(EntityEmploymentBo.from(entityEmployment));
275 }
276
277 bo.patronAffiliations.add(OlePatronAffiliation.from(affiliation));
278 }
279 }
280 entityBo.setNames(Arrays.asList(bo.getName()));
281 EntityTypeContactInfoBo entityTypeContactInfoBo = new EntityTypeContactInfoBo();
282 if(null != bo.getEntity().getEntityTypeContactInfos() && bo.getEntity().getEntityTypeContactInfos().size() > 0) {
283 entityTypeContactInfoBo = bo.getEntity().getEntityTypeContactInfos().get(0);
284 }
285 entityTypeContactInfoBo.setAddresses(bo.getAddresses());
286 entityTypeContactInfoBo.setEmailAddresses(bo.getEmails());
287 entityTypeContactInfoBo.setPhoneNumbers(bo.getPhones());
288 entityTypeContactInfoBo.setEntityTypeCode(KimConstants.EntityTypes.PERSON);
289 entityBo.setEntityTypeContactInfos(Arrays.asList(entityTypeContactInfoBo));
290 bo.setEntity(entityBo);
291 return bo;
292 }
293
294 public boolean isRealPatronCheck() {
295 return realPatronCheck;
296 }
297
298 public void setRealPatronCheck(boolean realPatronCheck) {
299 this.realPatronCheck = realPatronCheck;
300 }
301
302
303
304
305
306 public List<OleLoanDocument> getOleLoanDocuments() {
307 return oleLoanDocuments;
308 }
309
310
311
312
313 public void setOleLoanDocuments(List<OleLoanDocument> oleLoanDocuments) {
314 this.oleLoanDocuments = oleLoanDocuments;
315 }
316
317
318
319
320 public String getBorrowerTypeName() {
321 if(oleBorrowerType!=null) {
322 return oleBorrowerType.getBorrowerTypeName();
323 }
324 return null;
325 }
326
327
328
329
330 public EntityBo getEntity() {
331 return entity;
332 }
333
334
335
336
337 public void setEntity(EntityBo entity) {
338 this.entity = entity;
339 }
340
341 public String getAffiliationType() {
342 return affiliationType;
343 }
344
345 public void setAffiliationType(String affiliationType) {
346 this.affiliationType = affiliationType;
347 }
348
349
350
351
352
353 public List<OlePatronNotes> getNotes() {
354 return notes;
355 }
356
357
358
359
360 public void setNotes(List<OlePatronNotes> notes) {
361 this.notes = notes;
362 }
363
364
365
366
367 public String getBarcode() {
368 return barcode;
369 }
370
371
372
373
374 public void setBarcode(String barcode) {
375 this.barcode = barcode;
376 }
377
378
379
380
381 public String getBorrowerType() {
382 return borrowerType;
383 }
384
385
386
387
388 public void setBorrowerType(String borrowerType) {
389 this.borrowerType = borrowerType;
390 }
391
392
393
394
395 public boolean isActiveIndicator() {
396 return activeIndicator;
397 }
398
399
400
401
402 public void setActiveIndicator(boolean activeIndicator) {
403 this.activeIndicator = activeIndicator;
404 }
405
406
407
408
409 public String getOlePatronId() {
410 return olePatronId;
411 }
412
413
414
415
416 public void setOlePatronId(String olePatronId) {
417 this.olePatronId = olePatronId;
418 }
419
420
421
422
423 public boolean isGeneralBlock() {
424 return generalBlock;
425 }
426
427
428
429
430 public void setGeneralBlock(boolean generalBlock) {
431 this.generalBlock = generalBlock;
432 }
433
434
435
436
437 public boolean isCourtesyNotice() {
438 return courtesyNotice;
439 }
440
441
442
443
444 public void setCourtesyNotice(boolean courtesyNotice) {
445 this.courtesyNotice = courtesyNotice;
446 }
447
448
449
450
451 public boolean isDeliveryPrivilege() {
452 return deliveryPrivilege;
453 }
454
455
456
457
458 public void setDeliveryPrivilege(boolean deliveryPrivilege) {
459 this.deliveryPrivilege = deliveryPrivilege;
460 }
461
462
463
464
465 public boolean isPagingPrivilege() {
466 return pagingPrivilege;
467 }
468
469
470
471
472 public void setPagingPrivilege(boolean pagingPrivilege) {
473 this.pagingPrivilege = pagingPrivilege;
474 }
475
476
477
478
479 public Date getExpirationDate() {
480 return expirationDate;
481 }
482
483
484
485
486 public void setExpirationDate(Date expirationDate) {
487 this.expirationDate = expirationDate;
488 }
489
490
491
492
493 public String getFirstName() {
494 return firstName;
495 }
496
497
498
499
500 public void setFirstName(String firstName) {
501 this.firstName = firstName;
502 }
503
504
505
506
507 public String getMiddleName() {
508 return middleName;
509 }
510
511
512
513
514 public void setMiddleName(String middleName) {
515 this.middleName = middleName;
516 }
517
518
519
520
521 public String getLastName() {
522 return lastName;
523 }
524
525
526
527
528 public void setLastName(String lastName) {
529 this.lastName = lastName;
530 }
531
532
533
534
535 public String getEmailAddress() {
536 return emailAddress;
537 }
538
539
540
541
542 public void setEmailAddress(String emailAddress) {
543 this.emailAddress = emailAddress;
544 }
545
546
547
548
549 public String getPhoneNumber() {
550 return phoneNumber;
551 }
552
553
554
555
556 public void setPhoneNumber(String phoneNumber) {
557 this.phoneNumber = phoneNumber;
558 }
559
560
561
562
563 public List<EntityPhoneBo> getPhones() {
564 return phones;
565 }
566
567
568
569
570 public void setPhones(List<EntityPhoneBo> phones) {
571 this.phones = phones;
572 }
573
574
575
576
577 public List<EntityAddressBo> getAddresses() {
578 return addresses;
579 }
580
581
582
583
584 public void setAddresses(List<EntityAddressBo> addresses) {
585 this.addresses = addresses;
586 }
587
588
589
590
591 public EntityNameBo getName() {
592 return name;
593 }
594
595
596
597
598 public void setName(EntityNameBo name) {
599 this.name = name;
600 }
601
602
603
604
605 public List<EntityEmailBo> getEmails() {
606 return emails;
607 }
608
609
610
611
612 public void setEmails(List<EntityEmailBo> emails) {
613 this.emails = emails;
614 }
615
616
617
618
619 public OleBorrowerType getOleBorrowerType() {
620 return oleBorrowerType;
621 }
622
623
624
625
626 public void setOleBorrowerType(OleBorrowerType oleBorrowerType) {
627 this.oleBorrowerType = oleBorrowerType;
628 }
629
630
631
632
633 public String getProcessMessage() {
634 return processMessage;
635 }
636
637
638
639
640 public void setProcessMessage(String processMessage) {
641 this.processMessage = processMessage;
642 }
643
644 protected LinkedHashMap toStringMapper() {
645 LinkedHashMap toStringMap = new LinkedHashMap();
646 toStringMap.put("olePatronId", olePatronId);
647 return toStringMap;
648 }
649
650
651
652
653 @Override
654 public String getId() {
655 return this.getOlePatronId();
656 }
657 /* */
658
659
660 /*
661 public List<OlePatronDocument> getOlePatronDocuments() {
662 return olePatronDocuments;
663 }
664 */
665
666
667 /*
668 public void setOlePatronDocuments(List<OlePatronDocument> olePatronDocuments) {
669 this.olePatronDocuments = olePatronDocuments;
670 }*/
671
672
673
674
675 public String getProxyPatronId() {
676 return proxyPatronId;
677 }
678
679
680
681
682 public void setProxyPatronId(String proxyPatronId) {
683 this.proxyPatronId = proxyPatronId;
684 }
685
686
687
688
689 public List<OleProxyPatronDocument> getOleProxyPatronDocuments() {
690 return oleProxyPatronDocuments;
691 }
692
693
694
695
696 public void setOleProxyPatronDocuments(List<OleProxyPatronDocument> oleProxyPatronDocuments) {
697 this.oleProxyPatronDocuments = oleProxyPatronDocuments;
698 }
699
700
701
702
703 public Date getActivationDate() {
704 return activationDate;
705 }
706
707
708
709
710 public void setActivationDate(Date activationDate) {
711 this.activationDate = activationDate;
712 }
713
714
715
716
717 public String getGeneralBlockNotes() {
718 return generalBlockNotes;
719 }
720
721
722
723
724 public void setGeneralBlockNotes(String generalBlockNotes) {
725 this.generalBlockNotes = generalBlockNotes;
726 }
727
728
729
730
731 public List<OleEntityAddressBo> getOleEntityAddressBo() {
732 return oleEntityAddressBo;
733 }
734
735
736
737
738 public void setOleEntityAddressBo(List<OleEntityAddressBo> oleEntityAddressBo) {
739 this.oleEntityAddressBo = oleEntityAddressBo;
740 }
741
742
743
744
745 public List<OlePatronAffiliation> getPatronAffiliations() {
746 return patronAffiliations;
747 }
748
749
750
751
752 public void setPatronAffiliations(List<OlePatronAffiliation> patronAffiliations) {
753 this.patronAffiliations = patronAffiliations;
754 }
755
756
757
758
759 public OleSourceBo getSourceBo() {
760 return sourceBo;
761 }
762
763
764
765
766 public void setSourceBo(OleSourceBo sourceBo) {
767 this.sourceBo = sourceBo;
768 }
769
770
771
772
773 public OleStatisticalCategoryBo getStatisticalCategoryBo() {
774 return statisticalCategoryBo;
775 }
776
777
778
779
780 public void setStatisticalCategoryBo(OleStatisticalCategoryBo statisticalCategoryBo) {
781 this.statisticalCategoryBo = statisticalCategoryBo;
782 }
783
784
785
786
787 public List<EntityEmploymentBo> getEmployments() {
788 return employments;
789 }
790
791 public void setEmployments(List<EntityEmploymentBo> employments) {
792 this.employments = employments;
793 }
794
795
796
797
798 public String getSource() {
799 return source;
800 }
801
802 public void setSource(String source) {
803 if(source != null && source.equals("")) {
804 this.source = null;
805 } else {
806 this.source = source;
807 }
808 }
809
810
811
812
813 public String getStatisticalCategory() {
814 return statisticalCategory;
815 }
816
817 public void setStatisticalCategory(String statisticalCategory) {
818 if(statisticalCategory != null && statisticalCategory.equals("")) {
819 this.statisticalCategory = null;
820 } else {
821 this.statisticalCategory = statisticalCategory;
822 }
823 }
824
825
826
827
828 public String getOleSourceName() {
829 if(sourceBo != null) {
830 return sourceBo.getOleSourceName();
831 }
832 return null;
833 }
834
835
836
837
838 public String getOleStatisticalCategoryName() {
839 if(statisticalCategoryBo != null) {
840 return statisticalCategoryBo.getOleStatisticalCategoryName();
841 }
842 return null;
843 }
844
845
846
847
848 public boolean isPatronBillFlag() {
849 return patronBillFlag;
850 }
851
852
853
854
855 public void setPatronBillFlag(boolean patronBillFlag) {
856 this.patronBillFlag = patronBillFlag;
857 }
858 public List<OlePatronLostBarcode> getLostBarcodes() {
859 return lostBarcodes;
860 }
861
862 public void setLostBarcodes(List<OlePatronLostBarcode> lostBarcodes) {
863 this.lostBarcodes = lostBarcodes;
864 }
865
866 public List<OleAddressBo> getOleAddresses() {
867 return oleAddresses;
868 }
869
870 public void setOleAddresses(List<OleAddressBo> oleAddresses) {
871 this.oleAddresses = oleAddresses;
872 }
873
874 public byte[] getPatronPhotograph() {
875 return patronPhotograph;
876 }
877
878 public void setPatronPhotograph(byte[] patronPhotograph) {
879 this.patronPhotograph = patronPhotograph;
880 }
881
882 public List<OlePatronLocalIdentificationBo> getOlePatronLocalIds() {
883 return olePatronLocalIds;
884 }
885
886 public void setOlePatronLocalIds(List<OlePatronLocalIdentificationBo> olePatronLocalIds) {
887 this.olePatronLocalIds = olePatronLocalIds;
888 }
889
890 public boolean isLoanFlag() {
891 return loanFlag;
892 }
893
894 public void setLoanFlag(boolean loanFlag) {
895 this.loanFlag = loanFlag;
896 }
897
898 public boolean isTempCircHistoryFlag() {
899 return tempCircHistoryFlag;
900 }
901
902 public void setTempCircHistoryFlag(boolean tempCircHistoryFlag) {
903 this.tempCircHistoryFlag = tempCircHistoryFlag;
904 }
905
906 public boolean isRequestFlag() {
907 return requestFlag;
908 }
909
910 public void setRequestFlag(boolean requestFlag) {
911 this.requestFlag = requestFlag;
912 }
913 }