1 package org.kuali.ole.deliver.bo;
2
3 import org.apache.commons.collections.CollectionUtils;
4 import org.apache.commons.lang3.StringUtils;
5 import org.kuali.ole.OLEConstants;
6 import org.kuali.ole.deliver.api.*;
7 import org.kuali.ole.docstore.engine.service.storage.rdbms.pojo.ItemRecord;
8 import org.kuali.rice.kim.api.KimConstants;
9 import org.kuali.rice.kim.api.identity.IdentityService;
10 import org.kuali.rice.kim.api.identity.address.EntityAddress;
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.api.services.KimApiServiceLocator;
15 import org.kuali.rice.kim.impl.identity.address.EntityAddressBo;
16 import org.kuali.rice.kim.impl.identity.affiliation.EntityAffiliationBo;
17 import org.kuali.rice.kim.impl.identity.affiliation.EntityAffiliationTypeBo;
18 import org.kuali.rice.kim.impl.identity.email.EntityEmailBo;
19 import org.kuali.rice.kim.impl.identity.employment.EntityEmploymentBo;
20 import org.kuali.rice.kim.impl.identity.entity.EntityBo;
21 import org.kuali.rice.kim.impl.identity.name.EntityNameBo;
22 import org.kuali.rice.kim.impl.identity.phone.EntityPhoneBo;
23 import org.kuali.rice.kim.impl.identity.type.EntityTypeContactInfoBo;
24 import org.kuali.rice.krad.bo.PersistableBusinessObject;
25 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
26 import org.kuali.rice.krad.service.BusinessObjectService;
27 import org.kuali.rice.krad.service.KRADServiceLocator;
28
29 import java.util.*;
30 import java.util.concurrent.TimeUnit;
31
32
33
34
35 public class OlePatronDocument extends PersistableBusinessObjectBase implements OlePatronContract {
36
37 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OlePatronDocument.class);
38
39 private String olePatronId;
40 private String patronRecordURL;
41 private String barcode;
42 private String borrowerType;
43 private String affiliationType;
44 private boolean activeIndicator;
45 private boolean generalBlock;
46 private String generalBlockNotes;
47 private boolean pagingPrivilege;
48 private boolean courtesyNotice;
49 private boolean deliveryPrivilege;
50 private boolean realPatronCheck;
51 private boolean selfCheckOut;
52 private Date expirationDate;
53 private Date activationDate;
54 private String firstName;
55 private String middleName;
56 private String lastName;
57 private String emailAddress;
58 private String phoneNumber;
59 private String borrowerTypeName;
60 private String processMessage;
61 private String source;
62 private String statisticalCategory;
63 private String oleSourceName;
64 private String oleStatisticalCategoryName;
65 private boolean patronBillFlag;
66 private String proxyPatronId;
67 private byte[] patronPhotograph;
68 private boolean loanFlag;
69 private boolean tempCircHistoryFlag;
70 private boolean requestFlag;
71 private boolean upload = true;
72 private boolean patronHomePage;
73 private boolean pointing;
74 private boolean startingIndexExecuted;
75 private boolean activateBarcode;
76 private boolean deactivateBarcode;
77 private String lostStatus;
78 private String lostDescription;
79 private boolean invalidateBarcode;
80 private boolean reinstateBarcode;
81 private boolean skipBarcodeValidation;
82 private boolean barcodeChanged;
83 private boolean barcodeEditable;
84 private boolean expirationFlag = true;
85 private boolean popupDialog;
86 private String patronMessage;
87 private String uiMessageType;
88 private boolean reinstated;
89 private int numberOfClaimsReturned;
90 private boolean showLoanedRecords;
91 private boolean showRequestedItems;
92 private boolean showTemporaryCirculationHistoryRecords;
93 private boolean showBillUrlsFlag;
94 private OlePatronDocument selectedProxyForPatron;
95
96 private HashMap<String, String> errorsAndPermission = new HashMap<>();
97 private String errorMessage;
98 private boolean blockPatron;
99 private String realPatronFirstName;
100
101 private String realPatronLastName;
102 private int loanCount;
103 private int requestedItemRecordsCount;
104 private int tempCirculationHistoryCount;
105
106 private transient IdentityService identityService;
107 private boolean lostPatron = false;
108 private BusinessObjectService businessObjectService;
109 private boolean addressVerified;
110 private String preferredAddress;
111 private String email;
112 private Integer overdueFineAmt;
113 private Integer replacementFeeAmt;
114 private Integer allCharges;
115 private List<FeeType> feeTypeList;
116
117 public IdentityService getIdentityService() {
118 if (identityService == null) {
119 identityService = KimApiServiceLocator.getIdentityService();
120 }
121 return identityService;
122 }
123
124 public boolean isPatronHomePage() {
125 return patronHomePage;
126 }
127
128 public boolean isExpirationFlag() {
129 return expirationFlag;
130 }
131
132 public void setExpirationFlag(boolean expirationFlag) {
133 this.expirationFlag = expirationFlag;
134 }
135
136 public void setPatronHomePage(boolean patronHomePage) {
137 this.patronHomePage = patronHomePage;
138 }
139
140 private List<OleLoanDocument> oleLoanDocuments = new ArrayList<OleLoanDocument>();
141 private List<EntityPhoneBo> phones = new ArrayList<EntityPhoneBo>();
142 private List<EntityPhoneBo> deletedPhones = new ArrayList<EntityPhoneBo>();
143 private List<EntityAddressBo> addresses = new ArrayList<EntityAddressBo>();
144 private List<OleEntityAddressBo> oleEntityAddressBo = new ArrayList<OleEntityAddressBo>();
145 private List<OleEntityAddressBo> deletedOleEntityAddressBo = new ArrayList<OleEntityAddressBo>();
146 private EntityNameBo name = new EntityNameBo();
147 private List<OleAddressBo> oleAddresses = new ArrayList<OleAddressBo>();
148 private List<EntityEmailBo> emails = new ArrayList<EntityEmailBo>();
149 private List<EntityEmailBo> deletedEmails = new ArrayList<EntityEmailBo>();
150 private List<OlePatronNotes> notes = new ArrayList<OlePatronNotes>();
151 private List<OlePatronNotes> deletedNotes = new ArrayList<OlePatronNotes>();
152 private List<OlePatronLostBarcode> lostBarcodes = new ArrayList<OlePatronLostBarcode>();
153 private OleBorrowerType oleBorrowerType;
154 private EntityBo entity = new EntityBo();
155 private OleSourceBo sourceBo;
156 private OleStatisticalCategoryBo statisticalCategoryBo;
157 private List<OlePatronAffiliation> patronAffiliations = new ArrayList<OlePatronAffiliation>();
158 private List<OlePatronAffiliation> deletedPatronAffiliations = new ArrayList<OlePatronAffiliation>();
159 private List<EntityEmploymentBo> employments = new ArrayList<EntityEmploymentBo>();
160 private List<EntityEmploymentBo> deletedEmployments = new ArrayList<EntityEmploymentBo>();
161 private List<OleDeliverRequestBo> oleDeliverRequestBos = new ArrayList<OleDeliverRequestBo>();
162 private List<OleProxyPatronDocument> oleProxyPatronDocuments = new ArrayList<OleProxyPatronDocument>();
163 private List<OleProxyPatronDocument> deletedOleProxyPatronDocuments = new ArrayList<OleProxyPatronDocument>();
164 private List<OleTemporaryCirculationHistory> oleTemporaryCirculationHistoryRecords = new ArrayList<OleTemporaryCirculationHistory>();
165 private List<OlePatronLocalIdentificationBo> olePatronLocalIds = new ArrayList<OlePatronLocalIdentificationBo>();
166 private List<OlePatronLocalIdentificationBo> deletedOlePatronLocalIds = new ArrayList<OlePatronLocalIdentificationBo>();
167 private List<OleProxyPatronDocument> oleProxyPatronDocumentList = new ArrayList<OleProxyPatronDocument>();
168 private List<OlePatronDocument> currentPatronList = new ArrayList<OlePatronDocument>();
169 private List<PatronBillPayment> patronBillPayments = new ArrayList<>();
170 private OLEPatronEntityViewBo olePatronEntityViewBo;
171 private String patronBillFileName;
172 private String viewBillUrl;
173 private String createBillUrl;
174 private String namePrefix;
175 private String nameSuffix;
176 private OleDeliverRequestBo oleDeliverRequestBo;
177 private boolean checkoutForSelf;
178 private List<OlePatronNotes> olePatronUserNotes = new ArrayList<>();
179
180 public HashMap<String, String> getErrorsAndPermission() {
181 return errorsAndPermission;
182 }
183
184 public void setErrorsAndPermission(HashMap<String, String> errorsAndPermission) {
185 this.errorsAndPermission = errorsAndPermission;
186 }
187
188 public String getErrorMessage() {
189 return errorMessage;
190 }
191
192 public void setErrorMessage(String errorMessage) {
193 this.errorMessage = errorMessage;
194 }
195
196 public boolean isBlockPatron() {
197 return blockPatron;
198 }
199
200 public void setBlockPatron(boolean blockPatron) {
201 this.blockPatron = blockPatron;
202 }
203
204 public void setBorrowerTypeName(String borrowerTypeName) {
205 this.borrowerTypeName = borrowerTypeName;
206 }
207
208 private String patronName;
209
210 private String borrowerTypeCode;
211
212 public List<PatronBillPayment> getPatronBillPayments() {
213 return patronBillPayments;
214 }
215
216 public void setPatronBillPayments(List<PatronBillPayment> patronBillPayments) {
217 this.patronBillPayments = patronBillPayments;
218 }
219
220 public int getNumberOfClaimsReturned() {
221 return numberOfClaimsReturned;
222 }
223
224 public void setNumberOfClaimsReturned(int numberOfClaimsReturned) {
225 this.numberOfClaimsReturned = numberOfClaimsReturned;
226 }
227
228 public String getBorrowerTypeCode() {
229 if (borrowerTypeCode == null) {
230 borrowerTypeCode = getOleBorrowerType().getBorrowerTypeCode();
231 }
232 return borrowerTypeCode;
233 }
234
235 public void setBorrowerTypeCode(String borrowerTypeCode) {
236 this.borrowerTypeCode = borrowerTypeCode;
237 }
238
239 public boolean isSelfCheckOut() {
240 return selfCheckOut;
241 }
242
243 public void setSelfCheckOut(boolean selfCheckOut) {
244 this.selfCheckOut = selfCheckOut;
245 }
246
247 public String getPatronName() {
248 if (null == patronName) {
249 List<EntityNameBo> names = getEntity().getNames();
250 if (CollectionUtils.isNotEmpty(names)) {
251 EntityNameBo entityNameBo = names.get(0);
252 patronName = entityNameBo.getLastName() + "," + entityNameBo.getFirstName();
253 }
254 }
255 return patronName;
256 }
257
258 public void setPatronName(String patronName) {
259 this.patronName = patronName;
260 }
261
262 public OlePatronDocument() {
263 this.setActivationDate(new Date());
264 this.setDeliveryPrivilege(true);
265 this.setPagingPrivilege(true);
266 this.setCourtesyNotice(true);
267 this.setBarcodeEditable(true);
268 }
269
270 public boolean isUpload() {
271 return upload;
272 }
273
274 public void setUpload(boolean upload) {
275 this.upload = upload;
276 }
277
278 public List<OleTemporaryCirculationHistory> getOleTemporaryCirculationHistoryRecords() {
279 return oleTemporaryCirculationHistoryRecords;
280 }
281
282 public void setOleTemporaryCirculationHistoryRecords(List<OleTemporaryCirculationHistory> oleTemporaryCirculationHistoryRecords) {
283 this.oleTemporaryCirculationHistoryRecords = oleTemporaryCirculationHistoryRecords;
284 }
285
286 public List<OleDeliverRequestBo> getOleDeliverRequestBos() {
287 return oleDeliverRequestBos;
288 }
289
290 public void setOleDeliverRequestBos(List<OleDeliverRequestBo> oleDeliverRequestBos) {
291 this.oleDeliverRequestBos = oleDeliverRequestBos;
292 }
293
294
295
296
297
298
299
300 public static OlePatronDefinition to(org.kuali.ole.deliver.bo.OlePatronDocument bo) {
301 if (bo == null) {
302 return null;
303 }
304 return OlePatronDefinition.Builder.create(bo).build();
305 }
306
307
308
309
310
311
312
313 public static org.kuali.ole.deliver.bo.OlePatronDocument from(OlePatronDefinition immutable) {
314 return fromAndUpdate(immutable, null);
315 }
316
317
318
319
320
321
322
323
324 static org.kuali.ole.deliver.bo.OlePatronDocument fromAndUpdate(OlePatronDefinition immutable, org.kuali.ole.deliver.bo.OlePatronDocument toUpdate) {
325 if (immutable == null) {
326 return null;
327 }
328 org.kuali.ole.deliver.bo.OlePatronDocument bo = toUpdate;
329 if (toUpdate == null) {
330 bo = new org.kuali.ole.deliver.bo.OlePatronDocument();
331 }
332
333 bo.olePatronId = immutable.getOlePatronId();
334
335 bo.name = new EntityNameBo();
336
337 if (immutable.getName() != null) {
338 bo.name = EntityNameBo.from(immutable.getName());
339 }
340
341 bo.barcode = immutable.getBarcode();
342 bo.borrowerType = immutable.getBorrowerType();
343 bo.courtesyNotice = immutable.isCourtesyNotice();
344 bo.generalBlock = immutable.isGeneralBlock();
345 bo.deliveryPrivilege = immutable.isDeliveryPrivilege();
346 bo.pagingPrivilege = immutable.isPagingPrivilege();
347 bo.expirationDate = immutable.getExpirationDate();
348 bo.activationDate = immutable.getActivationDate();
349 bo.activeIndicator = immutable.isActiveIndicator();
350 bo.generalBlockNotes = immutable.getGeneralBlockNotes();
351 bo.source = immutable.getSource();
352 bo.statisticalCategory = immutable.getStatisticalCategory();
353
354
355
356
357
358
359
360
361
362 if (immutable.getEntity() != null) {
363 bo.entity = EntityBo.from(immutable.getEntity());
364 }
365 if (immutable.getOleBorrowerType() != null) {
366 bo.oleBorrowerType = OleBorrowerType.from(immutable.getOleBorrowerType());
367 }
368 if (CollectionUtils.isNotEmpty(immutable.getAddresses())) {
369 for (EntityAddress entityAddr : immutable.getAddresses()) {
370 bo.addresses.add(EntityAddressBo.from(entityAddr));
371 }
372 }
373 if (CollectionUtils.isNotEmpty(immutable.getEmails())) {
374 for (EntityEmail entityEmail : immutable.getEmails()) {
375 bo.emails.add(EntityEmailBo.from(entityEmail));
376 }
377 }
378 if (CollectionUtils.isNotEmpty(immutable.getPhones())) {
379 for (EntityPhone entityPhone : immutable.getPhones()) {
380 bo.phones.add(EntityPhoneBo.from(entityPhone));
381 }
382 }
383
384 if (CollectionUtils.isNotEmpty(immutable.getNotes())) {
385 for (OlePatronNotesDefinition note : immutable.getNotes()) {
386 bo.notes.add(OlePatronNotes.from(note));
387 }
388 }
389 if (CollectionUtils.isNotEmpty(immutable.getLostBarcodes())) {
390 for (OlePatronLostBarcodeDefinition lostBarcode : immutable.getLostBarcodes()) {
391 bo.lostBarcodes.add(OlePatronLostBarcode.from(lostBarcode));
392 }
393 }
394 if (CollectionUtils.isNotEmpty(immutable.getOleEntityAddressBo())) {
395 for (OleEntityAddressDefinition address : immutable.getOleEntityAddressBo()) {
396 bo.oleEntityAddressBo.add(OleEntityAddressBo.from(address));
397 }
398 }
399
400 if (CollectionUtils.isNotEmpty(immutable.getPatronAffiliations())) {
401 for (OlePatronAffiliationDefinition affiliation : immutable.getPatronAffiliations()) {
402 bo.patronAffiliations.add(OlePatronAffiliation.from(affiliation));
403 }
404 }
405 if (CollectionUtils.isNotEmpty(immutable.getOleProxyPatronDocuments())) {
406 for (OleProxyPatronDefinition proxyPatron : immutable.getOleProxyPatronDocuments()) {
407 bo.oleProxyPatronDocuments.add(OleProxyPatronDocument.from(proxyPatron));
408 }
409 }
410 if (CollectionUtils.isNotEmpty(immutable.getOleAddresses())) {
411 for (OleAddressDefinition oleAddress : immutable.getOleAddresses()) {
412 bo.oleAddresses.add(OleAddressBo.from(oleAddress));
413 }
414 }
415 if (CollectionUtils.isNotEmpty(immutable.getOlePatronLocalIds())) {
416 for (OlePatronLocalIdentificationDefinition olePatronLocalId : immutable.getOlePatronLocalIds()) {
417 bo.olePatronLocalIds.add(OlePatronLocalIdentificationBo.from(olePatronLocalId));
418 }
419 }
420
421 bo.versionNumber = immutable.getVersionNumber();
422
423 EntityBo entityBo = new EntityBo();
424 entityBo.setActive(true);
425
426 if (null != bo.getEntity()) {
427 entityBo = bo.getEntity();
428 entityBo.setActive(true);
429 }
430 if (CollectionUtils.isNotEmpty(immutable.getPatronAffiliations())) {
431 for (OlePatronAffiliationDefinition affiliation : immutable.getPatronAffiliations()) {
432 EntityAffiliationBo entityAffiliationBo = new EntityAffiliationBo();
433 entityAffiliationBo.setId(affiliation.getEntityAffiliationId());
434 entityAffiliationBo.setAffiliationTypeCode(affiliation.getAffiliationTypeCode());
435 entityAffiliationBo.setAffiliationType(EntityAffiliationTypeBo.from(affiliation.getAffiliationType()));
436 entityAffiliationBo.setActive(affiliation.isActive());
437 entityAffiliationBo.setDefaultValue(affiliation.isDefaultValue());
438 entityAffiliationBo.setCampusCode(affiliation.getCampusCode());
439 entityAffiliationBo.setObjectId(affiliation.getObjectId());
440 entityAffiliationBo.setVersionNumber(affiliation.getVersionNumber());
441 entityAffiliationBo.setEntityId(affiliation.getEntityId());
442
443 entityBo.getAffiliations().add(entityAffiliationBo);
444 for (EntityEmployment entityEmployment : affiliation.getEmployments()) {
445 entityBo.getEmploymentInformation().add(EntityEmploymentBo.from(entityEmployment));
446 }
447
448 bo.patronAffiliations.add(OlePatronAffiliation.from(affiliation));
449 }
450 }
451 entityBo.setNames(Arrays.asList(bo.getName()));
452 EntityTypeContactInfoBo entityTypeContactInfoBo = new EntityTypeContactInfoBo();
453 if (bo.getEntity() != null && null != bo.getEntity().getEntityTypeContactInfos() && bo.getEntity().getEntityTypeContactInfos().size() > 0) {
454 entityTypeContactInfoBo = bo.getEntity().getEntityTypeContactInfos().get(0);
455 }
456 entityTypeContactInfoBo.setAddresses(bo.getAddresses());
457 entityTypeContactInfoBo.setEmailAddresses(bo.getEmails());
458 entityTypeContactInfoBo.setPhoneNumbers(bo.getPhones());
459 entityTypeContactInfoBo.setEntityTypeCode(KimConstants.EntityTypes.PERSON);
460 entityBo.setEntityTypeContactInfos(Arrays.asList(entityTypeContactInfoBo));
461 bo.setEntity(entityBo);
462 return bo;
463 }
464
465 public boolean isRealPatronCheck() {
466 return realPatronCheck;
467 }
468
469 public void setRealPatronCheck(boolean realPatronCheck) {
470 this.realPatronCheck = realPatronCheck;
471 }
472
473
474
475
476
477
478 public List<OleLoanDocument> getOleLoanDocuments() {
479 return oleLoanDocuments;
480 }
481
482
483
484
485
486
487 public void setOleLoanDocuments(List<OleLoanDocument> oleLoanDocuments) {
488 List<OleLoanDocument> LoanDocumentList = new ArrayList<>();
489 List<OleLoanDocument> indefiniteLoanDocumentList = new ArrayList<>();
490 for (OleLoanDocument loanDoc : oleLoanDocuments) {
491 if (loanDoc.getLoanDueDate() != null && !(loanDoc.getLoanDueDate().toString().isEmpty())) {
492 LoanDocumentList.add(loanDoc);
493 } else {
494
495 indefiniteLoanDocumentList.add(loanDoc);
496 }
497 }
498 Collections.sort(LoanDocumentList, new Comparator<OleLoanDocument>() {
499 public int compare(OleLoanDocument o1, OleLoanDocument o2) {
500 return o1.getLoanDueDate().compareTo(o2.getLoanDueDate());
501 }
502 });
503 LoanDocumentList.addAll(indefiniteLoanDocumentList);
504 this.oleLoanDocuments = LoanDocumentList;
505 }
506
507
508
509
510
511
512 public String getBorrowerTypeName() {
513 if (getOleBorrowerType() != null) {
514 return oleBorrowerType.getBorrowerTypeName();
515 }
516 return null;
517 }
518
519
520
521
522
523
524 public EntityBo getEntity() {
525 if (getOlePatronId() != null) {
526 EntityBo entityBo = (EntityBo) EntityBo.from(getIdentityService().getEntity(getOlePatronId()));
527 if (entityBo != null) {
528 return entityBo;
529 }
530
531 return entity;
532 } else {
533 return entity;
534 }
535 }
536
537
538
539
540
541
542 public void setEntity(EntityBo entity) {
543 this.entity = entity;
544 }
545
546 public String getAffiliationType() {
547 return affiliationType;
548 }
549
550 public void setAffiliationType(String affiliationType) {
551 this.affiliationType = affiliationType;
552 }
553
554
555
556
557
558
559 public List<OlePatronNotes> getNotes() {
560 return notes;
561 }
562
563
564
565
566
567
568 public void setNotes(List<OlePatronNotes> notes) {
569 this.notes = notes;
570 }
571
572
573
574
575
576
577 public String getBarcode() {
578 return barcode;
579 }
580
581
582
583
584
585
586 public void setBarcode(String barcode) {
587 this.barcode = barcode;
588 }
589
590
591
592
593
594
595 public String getBorrowerType() {
596 return borrowerType;
597 }
598
599
600
601
602
603
604 public void setBorrowerType(String borrowerType) {
605 this.borrowerType = borrowerType;
606 }
607
608
609
610
611
612
613 public boolean isActiveIndicator() {
614 return activeIndicator;
615 }
616
617
618
619
620
621
622 public void setActiveIndicator(boolean activeIndicator) {
623 this.activeIndicator = activeIndicator;
624 }
625
626
627
628
629
630
631 public String getOlePatronId() {
632 return olePatronId;
633 }
634
635
636
637
638
639
640 public void setOlePatronId(String olePatronId) {
641 this.olePatronId = olePatronId;
642 }
643
644
645
646
647
648
649 @Override
650 public boolean isGeneralBlock() {
651 return generalBlock;
652 }
653
654
655
656
657
658
659 public void setGeneralBlock(boolean generalBlock) {
660 this.generalBlock = generalBlock;
661 }
662
663
664
665
666
667
668 public boolean isCourtesyNotice() {
669 return courtesyNotice;
670 }
671
672
673
674
675
676
677 public void setCourtesyNotice(boolean courtesyNotice) {
678 this.courtesyNotice = courtesyNotice;
679 }
680
681
682
683
684
685
686 public boolean isDeliveryPrivilege() {
687 return deliveryPrivilege;
688 }
689
690
691
692
693
694
695 public void setDeliveryPrivilege(boolean deliveryPrivilege) {
696 this.deliveryPrivilege = deliveryPrivilege;
697 }
698
699
700
701
702
703
704 public boolean isPagingPrivilege() {
705 return pagingPrivilege;
706 }
707
708
709
710
711
712
713 public void setPagingPrivilege(boolean pagingPrivilege) {
714 this.pagingPrivilege = pagingPrivilege;
715 }
716
717
718
719
720
721
722 public Date getExpirationDate() {
723 return expirationDate;
724 }
725
726
727
728
729
730
731 public void setExpirationDate(Date expirationDate) {
732 this.expirationDate = expirationDate;
733 }
734
735
736
737
738
739
740 public String getFirstName() {
741 return firstName;
742 }
743
744
745
746
747
748
749 public void setFirstName(String firstName) {
750 this.firstName = firstName;
751 }
752
753
754
755
756
757
758 public String getMiddleName() {
759 return middleName;
760 }
761
762
763
764
765
766
767 public void setMiddleName(String middleName) {
768 this.middleName = middleName;
769 }
770
771
772
773
774
775
776 public String getLastName() {
777 return lastName;
778 }
779
780
781
782
783
784
785 public void setLastName(String lastName) {
786 this.lastName = lastName;
787 }
788
789
790
791
792
793
794 public String getEmailAddress() {
795 return emailAddress;
796 }
797
798
799
800
801
802
803 public void setEmailAddress(String emailAddress) {
804 this.emailAddress = emailAddress;
805 }
806
807
808
809
810
811
812 public String getPhoneNumber() {
813 return phoneNumber;
814 }
815
816
817
818
819
820
821 public void setPhoneNumber(String phoneNumber) {
822 this.phoneNumber = phoneNumber;
823 }
824
825
826
827
828
829
830 public List<EntityPhoneBo> getPhones() {
831 return phones;
832 }
833
834
835
836
837
838
839 public void setPhones(List<EntityPhoneBo> phones) {
840 this.phones = phones;
841 }
842
843
844
845
846
847
848 public List<EntityAddressBo> getAddresses() {
849 return addresses;
850 }
851
852
853
854
855
856
857 public void setAddresses(List<EntityAddressBo> addresses) {
858 this.addresses = addresses;
859 }
860
861
862
863
864
865
866 public EntityNameBo getName() {
867 return name;
868 }
869
870
871
872
873
874
875 public void setName(EntityNameBo name) {
876 this.name = name;
877 }
878
879
880
881
882
883
884 public List<EntityEmailBo> getEmails() {
885 return emails;
886 }
887
888
889
890
891
892
893 public void setEmails(List<EntityEmailBo> emails) {
894 this.emails = emails;
895 }
896
897
898
899
900
901
902 public OleBorrowerType getOleBorrowerType() {
903 return oleBorrowerType;
904 }
905
906
907
908
909
910
911 public void setOleBorrowerType(OleBorrowerType oleBorrowerType) {
912 this.oleBorrowerType = oleBorrowerType;
913 }
914
915
916
917
918
919
920 public String getProcessMessage() {
921 return processMessage;
922 }
923
924
925
926
927
928
929 public void setProcessMessage(String processMessage) {
930 this.processMessage = processMessage;
931 }
932
933 protected LinkedHashMap toStringMapper() {
934 LinkedHashMap toStringMap = new LinkedHashMap();
935 toStringMap.put("olePatronId", olePatronId);
936 return toStringMap;
937 }
938
939
940
941
942
943
944 @Override
945 public String getId() {
946 return this.getOlePatronId();
947 }
948
949
950
951
952
953
954 public String getProxyPatronId() {
955 return proxyPatronId;
956 }
957
958
959
960
961
962
963 public void setProxyPatronId(String proxyPatronId) {
964 this.proxyPatronId = proxyPatronId;
965 }
966
967
968
969
970
971
972 public List<OleProxyPatronDocument> getOleProxyPatronDocuments() {
973 return oleProxyPatronDocuments;
974 }
975
976
977
978
979
980
981 public void setOleProxyPatronDocuments(List<OleProxyPatronDocument> oleProxyPatronDocuments) {
982 this.oleProxyPatronDocuments = oleProxyPatronDocuments;
983 }
984
985 public OlePatronDocument getSelectedProxyForPatron() {
986 return selectedProxyForPatron;
987 }
988
989 public void setSelectedProxyForPatron(OlePatronDocument selectedProxyForPatron) {
990 this.selectedProxyForPatron = selectedProxyForPatron;
991 }
992
993
994
995
996
997
998 public Date getActivationDate() {
999 return activationDate;
1000 }
1001
1002
1003
1004
1005
1006
1007 public void setActivationDate(Date activationDate) {
1008 this.activationDate = activationDate;
1009 }
1010
1011
1012
1013
1014
1015
1016 public String getGeneralBlockNotes() {
1017 return generalBlockNotes;
1018 }
1019
1020
1021
1022
1023
1024
1025 public void setGeneralBlockNotes(String generalBlockNotes) {
1026 this.generalBlockNotes = generalBlockNotes;
1027 }
1028
1029
1030
1031
1032
1033
1034 public List<OleEntityAddressBo> getOleEntityAddressBo() {
1035 return oleEntityAddressBo;
1036 }
1037
1038
1039
1040
1041
1042
1043 public void setOleEntityAddressBo(List<OleEntityAddressBo> oleEntityAddressBo) {
1044 this.oleEntityAddressBo = oleEntityAddressBo;
1045 }
1046
1047
1048
1049
1050
1051
1052 public List<OlePatronAffiliation> getPatronAffiliations() {
1053 return patronAffiliations;
1054 }
1055
1056
1057
1058
1059
1060
1061 public void setPatronAffiliations(List<OlePatronAffiliation> patronAffiliations) {
1062 this.patronAffiliations = patronAffiliations;
1063 }
1064
1065
1066
1067
1068
1069
1070 public OleSourceBo getSourceBo() {
1071 return sourceBo;
1072 }
1073
1074
1075
1076
1077
1078
1079 public void setSourceBo(OleSourceBo sourceBo) {
1080 this.sourceBo = sourceBo;
1081 }
1082
1083
1084
1085
1086
1087
1088 public OleStatisticalCategoryBo getStatisticalCategoryBo() {
1089 return statisticalCategoryBo;
1090 }
1091
1092
1093
1094
1095
1096
1097 public void setStatisticalCategoryBo(OleStatisticalCategoryBo statisticalCategoryBo) {
1098 this.statisticalCategoryBo = statisticalCategoryBo;
1099 }
1100
1101
1102
1103
1104
1105
1106 public List<EntityEmploymentBo> getEmployments() {
1107 return employments;
1108 }
1109
1110 public void setEmployments(List<EntityEmploymentBo> employments) {
1111 this.employments = employments;
1112 }
1113
1114
1115
1116
1117
1118
1119 public String getSource() {
1120 return source;
1121 }
1122
1123 public void setSource(String source) {
1124 if (source != null && source.equals("")) {
1125 this.source = null;
1126 } else {
1127 this.source = source;
1128 }
1129 }
1130
1131
1132
1133
1134
1135
1136 public String getStatisticalCategory() {
1137 return statisticalCategory;
1138 }
1139
1140 public void setStatisticalCategory(String statisticalCategory) {
1141 if (statisticalCategory != null && statisticalCategory.equals("")) {
1142 this.statisticalCategory = null;
1143 } else {
1144 this.statisticalCategory = statisticalCategory;
1145 }
1146 }
1147
1148
1149
1150
1151
1152
1153 public String getOleSourceName() {
1154 if (sourceBo != null) {
1155 return sourceBo.getOleSourceName();
1156 }
1157 return null;
1158 }
1159
1160
1161
1162
1163
1164
1165 public String getOleStatisticalCategoryName() {
1166 if (statisticalCategoryBo != null) {
1167 return statisticalCategoryBo.getOleStatisticalCategoryName();
1168 }
1169 return null;
1170 }
1171
1172
1173
1174
1175
1176
1177 public boolean isPatronBillFlag() {
1178 return patronBillFlag;
1179 }
1180
1181
1182
1183
1184
1185
1186 public void setPatronBillFlag(boolean patronBillFlag) {
1187 this.patronBillFlag = patronBillFlag;
1188 }
1189
1190 public List<OlePatronLostBarcode> getLostBarcodes() {
1191 return lostBarcodes;
1192 }
1193
1194 public void setLostBarcodes(List<OlePatronLostBarcode> lostBarcodes) {
1195 this.lostBarcodes = lostBarcodes;
1196 }
1197
1198 public List<OleAddressBo> getOleAddresses() {
1199 return oleAddresses;
1200 }
1201
1202 public void setOleAddresses(List<OleAddressBo> oleAddresses) {
1203 this.oleAddresses = oleAddresses;
1204 }
1205
1206 public byte[] getPatronPhotograph() {
1207 return patronPhotograph;
1208 }
1209
1210 public void setPatronPhotograph(byte[] patronPhotograph) {
1211 this.patronPhotograph = patronPhotograph;
1212 }
1213
1214 public List<OlePatronLocalIdentificationBo> getOlePatronLocalIds() {
1215 return olePatronLocalIds;
1216 }
1217
1218 public void setOlePatronLocalIds(List<OlePatronLocalIdentificationBo> olePatronLocalIds) {
1219 this.olePatronLocalIds = olePatronLocalIds;
1220 }
1221
1222 public boolean isLoanFlag() {
1223 return loanFlag;
1224 }
1225
1226 public void setLoanFlag(boolean loanFlag) {
1227 this.loanFlag = loanFlag;
1228 }
1229
1230 public boolean isTempCircHistoryFlag() {
1231 return tempCircHistoryFlag;
1232 }
1233
1234 public void setTempCircHistoryFlag(boolean tempCircHistoryFlag) {
1235 this.tempCircHistoryFlag = tempCircHistoryFlag;
1236 }
1237
1238 public boolean isRequestFlag() {
1239 return requestFlag;
1240 }
1241
1242 public void setRequestFlag(boolean requestFlag) {
1243 this.requestFlag = requestFlag;
1244 }
1245
1246 public List<OleProxyPatronDocument> getOleProxyPatronDocumentList() {
1247 return oleProxyPatronDocumentList;
1248 }
1249
1250 public void setOleProxyPatronDocumentList(List<OleProxyPatronDocument> oleProxyPatronDocumentList) {
1251 this.oleProxyPatronDocumentList = oleProxyPatronDocumentList;
1252 }
1253
1254 public boolean isPointing() {
1255 return pointing;
1256 }
1257
1258 public void setPointing(boolean pointing) {
1259 this.pointing = pointing;
1260 }
1261
1262 public boolean isStartingIndexExecuted() {
1263 return startingIndexExecuted;
1264 }
1265
1266 public void setStartingIndexExecuted(boolean startingIndexExecuted) {
1267 this.startingIndexExecuted = startingIndexExecuted;
1268 }
1269
1270 public boolean isActivateBarcode() {
1271 return activateBarcode;
1272 }
1273
1274 public void setActivateBarcode(boolean activateBarcode) {
1275 this.activateBarcode = activateBarcode;
1276 }
1277
1278 public boolean isDeactivateBarcode() {
1279 return deactivateBarcode;
1280 }
1281
1282 public void setDeactivateBarcode(boolean deactivateBarcode) {
1283 this.deactivateBarcode = deactivateBarcode;
1284 }
1285
1286 public String getLostStatus() {
1287 return lostStatus;
1288 }
1289
1290 public void setLostStatus(String lostStatus) {
1291 this.lostStatus = lostStatus;
1292 }
1293
1294 public String getLostDescription() {
1295 return lostDescription;
1296 }
1297
1298 public void setLostDescription(String lostDescription) {
1299 this.lostDescription = lostDescription;
1300 }
1301
1302 public boolean isInvalidateBarcode() {
1303 return invalidateBarcode;
1304 }
1305
1306 public void setInvalidateBarcode(boolean invalidateBarcode) {
1307 this.invalidateBarcode = invalidateBarcode;
1308 }
1309
1310 public boolean isReinstateBarcode() {
1311 return reinstateBarcode;
1312 }
1313
1314 public void setReinstateBarcode(boolean reinstateBarcode) {
1315 this.reinstateBarcode = reinstateBarcode;
1316 }
1317
1318 public boolean isSkipBarcodeValidation() {
1319 return skipBarcodeValidation;
1320 }
1321
1322 public void setSkipBarcodeValidation(boolean skipBarcodeValidation) {
1323 this.skipBarcodeValidation = skipBarcodeValidation;
1324 }
1325
1326 public boolean isBarcodeChanged() {
1327 return barcodeChanged;
1328 }
1329
1330 public void setBarcodeChanged(boolean barcodeChanged) {
1331 this.barcodeChanged = barcodeChanged;
1332 }
1333
1334 public boolean isBarcodeEditable() {
1335 return barcodeEditable;
1336 }
1337
1338 public void setBarcodeEditable(boolean barcodeEditable) {
1339 this.barcodeEditable = barcodeEditable;
1340 }
1341
1342 public boolean isPopupDialog() {
1343 return popupDialog;
1344 }
1345
1346 public void setPopupDialog(boolean popupDialog) {
1347 this.popupDialog = popupDialog;
1348 }
1349
1350 public String getPatronMessage() {
1351 return patronMessage;
1352 }
1353
1354 public void setPatronMessage(String patronMessage) {
1355 this.patronMessage = patronMessage;
1356 }
1357
1358 public String getUiMessageType() {
1359 return uiMessageType;
1360 }
1361
1362 public void setUiMessageType(String uiMessageType) {
1363 this.uiMessageType = uiMessageType;
1364 }
1365
1366 public boolean isReinstated() {
1367 return reinstated;
1368 }
1369
1370 public void setReinstated(boolean reinstated) {
1371 this.reinstated = reinstated;
1372 }
1373
1374 public OLEPatronEntityViewBo getOlePatronEntityViewBo() {
1375 return olePatronEntityViewBo;
1376 }
1377
1378 public void setOlePatronEntityViewBo(OLEPatronEntityViewBo olePatronEntityViewBo) {
1379 this.olePatronEntityViewBo = olePatronEntityViewBo;
1380 }
1381
1382 public String getPatronBillFileName() {
1383 return patronBillFileName;
1384 }
1385
1386 public void setPatronBillFileName(String patronBillFileName) {
1387 this.patronBillFileName = patronBillFileName;
1388 }
1389
1390 public String getViewBillUrl() {
1391 return viewBillUrl;
1392 }
1393
1394 public void setViewBillUrl(String viewBillUrl) {
1395 this.viewBillUrl = viewBillUrl;
1396 }
1397
1398 public String getCreateBillUrl() {
1399 return createBillUrl;
1400 }
1401
1402 public void setCreateBillUrl(String createBillUrl) {
1403 this.createBillUrl = createBillUrl;
1404 }
1405
1406 public String getNamePrefix() {
1407 return namePrefix;
1408 }
1409
1410 public void setNamePrefix(String namePrefix) {
1411 this.namePrefix = namePrefix;
1412 }
1413
1414 public String getNameSuffix() {
1415 return nameSuffix;
1416 }
1417
1418 public void setNameSuffix(String nameSuffix) {
1419 this.nameSuffix = nameSuffix;
1420 }
1421
1422 public List<EntityPhoneBo> getDeletedPhones() {
1423 return deletedPhones;
1424 }
1425
1426 public void setDeletedPhones(List<EntityPhoneBo> deletedPhones) {
1427 this.deletedPhones = deletedPhones;
1428 }
1429
1430 public List<OleEntityAddressBo> getDeletedOleEntityAddressBo() {
1431 return deletedOleEntityAddressBo;
1432 }
1433
1434 public void setDeletedOleEntityAddressBo(List<OleEntityAddressBo> deletedOleEntityAddressBo) {
1435 this.deletedOleEntityAddressBo = deletedOleEntityAddressBo;
1436 }
1437
1438 public List<EntityEmailBo> getDeletedEmails() {
1439 return deletedEmails;
1440 }
1441
1442 public void setDeletedEmails(List<EntityEmailBo> deletedEmails) {
1443 this.deletedEmails = deletedEmails;
1444 }
1445
1446 public List<OleProxyPatronDocument> getDeletedOleProxyPatronDocuments() {
1447 return deletedOleProxyPatronDocuments;
1448 }
1449
1450 public void setDeletedOleProxyPatronDocuments(List<OleProxyPatronDocument> deletedOleProxyPatronDocuments) {
1451 this.deletedOleProxyPatronDocuments = deletedOleProxyPatronDocuments;
1452 }
1453
1454 public List<OlePatronAffiliation> getDeletedPatronAffiliations() {
1455 return deletedPatronAffiliations;
1456 }
1457
1458 public void setDeletedPatronAffiliations(List<OlePatronAffiliation> deletedPatronAffiliations) {
1459 this.deletedPatronAffiliations = deletedPatronAffiliations;
1460 }
1461
1462 public List<EntityEmploymentBo> getDeletedEmployments() {
1463 return deletedEmployments;
1464 }
1465
1466 public void setDeletedEmployments(List<EntityEmploymentBo> deletedEmployments) {
1467 this.deletedEmployments = deletedEmployments;
1468 }
1469
1470 public List<OlePatronNotes> getDeletedNotes() {
1471 return deletedNotes;
1472 }
1473
1474 public void setDeletedNotes(List<OlePatronNotes> deletedNotes) {
1475 this.deletedNotes = deletedNotes;
1476 }
1477
1478 public List<OlePatronLocalIdentificationBo> getDeletedOlePatronLocalIds() {
1479 return deletedOlePatronLocalIds;
1480 }
1481
1482 public void setDeletedOlePatronLocalIds(List<OlePatronLocalIdentificationBo> deletedOlePatronLocalIds) {
1483 this.deletedOlePatronLocalIds = deletedOlePatronLocalIds;
1484 }
1485
1486 public boolean isShowLoanedRecords() {
1487 return showLoanedRecords;
1488 }
1489
1490 public void setShowLoanedRecords(boolean showLoanedRecords) {
1491 this.showLoanedRecords = showLoanedRecords;
1492 }
1493
1494 public boolean isShowRequestedItems() {
1495 return showRequestedItems;
1496 }
1497
1498 public void setShowRequestedItems(boolean showRequestedItems) {
1499 this.showRequestedItems = showRequestedItems;
1500 }
1501
1502 public boolean isShowTemporaryCirculationHistoryRecords() {
1503 return showTemporaryCirculationHistoryRecords;
1504 }
1505
1506 public void setShowTemporaryCirculationHistoryRecords(boolean showTemporaryCirculationHistoryRecords) {
1507 this.showTemporaryCirculationHistoryRecords = showTemporaryCirculationHistoryRecords;
1508 }
1509
1510 public String getRealPatronFirstName() {
1511 if (entity != null && entity.getNames() != null && entity.getNames().size() > 0) {
1512 this.realPatronFirstName = entity.getNames().get(0).getFirstName().replaceAll("'", "\'");
1513 }
1514 return realPatronFirstName;
1515 }
1516
1517 public void setRealPatronFirstName(String realPatronFirstName) {
1518 this.realPatronFirstName = realPatronFirstName;
1519 }
1520
1521 public String getRealPatronLastName() {
1522 if (entity != null && entity.getNames() != null && entity.getNames().size() > 0) {
1523 this.realPatronLastName = entity.getNames().get(0).getLastName().replaceAll("'", "\'");
1524 }
1525 return realPatronLastName;
1526 }
1527
1528 public void setRealPatronLastName(String realPatronLastName) {
1529 this.realPatronLastName = realPatronLastName;
1530 }
1531
1532 public boolean isShowBillUrlsFlag() {
1533 return showBillUrlsFlag;
1534 }
1535
1536 public void setShowBillUrlsFlag(boolean showBillUrlsFlag) {
1537 this.showBillUrlsFlag = showBillUrlsFlag;
1538 }
1539
1540 public int getLoanCount() {
1541 return loanCount;
1542 }
1543
1544 public void setLoanCount(int loanCount) {
1545 this.loanCount = loanCount;
1546 }
1547
1548 public int getRequestedItemRecordsCount() {
1549 return requestedItemRecordsCount;
1550 }
1551
1552 public void setRequestedItemRecordsCount(int requestedItemRecordsCount) {
1553 this.requestedItemRecordsCount = requestedItemRecordsCount;
1554 }
1555
1556 public int getTempCirculationHistoryCount() {
1557 return tempCirculationHistoryCount;
1558 }
1559
1560 public void setTempCirculationHistoryCount(int tempCirculationHistoryCount) {
1561 this.tempCirculationHistoryCount = tempCirculationHistoryCount;
1562 }
1563
1564 public String getPatronRecordURL() {
1565 return patronRecordURL;
1566 }
1567
1568 public void setPatronRecordURL(String patronRecordURL) {
1569 this.patronRecordURL = patronRecordURL;
1570 }
1571
1572 public boolean isLostPatron() {
1573 LOG.debug("Inside the checkLostPatronBarcode method");
1574 Map barMap = new HashMap();
1575 barMap.put("invalidOrLostBarcodeNumber", barcode);
1576 List<OlePatronLostBarcode> olePatronLostBarcodes = (List<OlePatronLostBarcode>) getBusinessObjectService().findMatching(OlePatronLostBarcode.class, barMap);
1577
1578 return olePatronLostBarcodes.size() > 0;
1579 }
1580
1581 public BusinessObjectService getBusinessObjectService() {
1582 if (null == businessObjectService) {
1583 businessObjectService = KRADServiceLocator.getBusinessObjectService();
1584 }
1585 return businessObjectService;
1586 }
1587
1588 public boolean isAddressVerified() {
1589 Map<String, String> addressCriteria = new HashMap<String, String>();
1590 EntityBo entityBo = getEntity();
1591 if (null != entityBo) {
1592 List<EntityTypeContactInfoBo> entityTypeContactInfos = entityBo.getEntityTypeContactInfos();
1593 if (null != entityTypeContactInfos && entityTypeContactInfos.size() > 0) {
1594 List<EntityAddressBo> addresses = entityTypeContactInfos.get(0).getAddresses();
1595 if (addresses != null && addresses
1596 .size() > 0) {
1597 for (int address = 0; address < addresses.size(); address++) {
1598 addressCriteria.put("id", addresses.get(address).getId());
1599 List<OleAddressBo> oleAddressBos = (List<OleAddressBo>) KRADServiceLocator.getBusinessObjectService().findMatching(OleAddressBo.class, addressCriteria);
1600 if (oleAddressBos != null && oleAddressBos.size() > 0 && addresses.get(address).isDefaultValue() && oleAddressBos.get(0).isAddressVerified()) {
1601 return true;
1602 }
1603 }
1604 }
1605 }
1606 }
1607 return false;
1608 }
1609
1610 public String getPreferredAddress() {
1611 StringBuilder stringBuilder = new StringBuilder();
1612 if (null == preferredAddress) {
1613 EntityTypeContactInfoBo entityTypeContactInfoBo = getEntity().getEntityTypeContactInfos().get(0);
1614 if (entityTypeContactInfoBo.getAddresses() != null) {
1615 for (EntityAddressBo entityAddressBo : entityTypeContactInfoBo.getAddresses()) {
1616 if (entityAddressBo.isDefaultValue()) {
1617 String address = "";
1618 if (entityAddressBo.getLine1() != null) {
1619 if (!entityAddressBo.getLine1().isEmpty()) {
1620 stringBuilder.append(entityAddressBo.getLine1() + OLEConstants.COMMA);
1621 }
1622 }
1623
1624 if (entityAddressBo.getLine2() != null) {
1625 if (!entityAddressBo.getLine2().isEmpty()) {
1626 stringBuilder.append(entityAddressBo.getLine2() + OLEConstants.COMMA);
1627 }
1628 }
1629
1630 if (entityAddressBo.getLine3() != null) {
1631 if (!entityAddressBo.getLine3().isEmpty()) {
1632 stringBuilder.append(entityAddressBo.getLine3() + OLEConstants.COMMA);
1633 }
1634 }
1635
1636 if (entityAddressBo.getCity() != null) {
1637 if (!entityAddressBo.getCity().isEmpty()) {
1638 stringBuilder.append(entityAddressBo.getCity() + OLEConstants.COMMA);
1639 }
1640 }
1641
1642 if (entityAddressBo.getStateProvinceCode() != null) {
1643 if (!entityAddressBo.getStateProvinceCode().isEmpty()) {
1644 stringBuilder.append(entityAddressBo.getStateProvinceCode() + OLEConstants.COMMA);
1645 }
1646 }
1647
1648 if (entityAddressBo.getCountryCode() != null) {
1649 if (!entityAddressBo.getCountryCode().isEmpty()) {
1650 stringBuilder.append(entityAddressBo.getCountryCode() + OLEConstants.COMMA);
1651 }
1652 }
1653
1654 if (entityAddressBo.getPostalCode() != null) {
1655 if (!entityAddressBo.getPostalCode().isEmpty()) {
1656 stringBuilder.append(entityAddressBo.getPostalCode());
1657 }
1658 }
1659 preferredAddress = stringBuilder.toString();
1660 break;
1661 }
1662 }
1663 }
1664 }
1665 return preferredAddress;
1666 }
1667
1668 public String getEmail() {
1669 if (null == email) {
1670 EntityTypeContactInfoBo entityTypeContactInfoBo = getEntity().getEntityTypeContactInfos().get(0);
1671 if (entityTypeContactInfoBo.getEmailAddresses() != null) {
1672 for (EntityEmailBo entityEmailBo : entityTypeContactInfoBo.getEmailAddresses()) {
1673 if (entityEmailBo.isDefaultValue()) {
1674 email = entityEmailBo.getEmailAddress();
1675 break;
1676 }
1677 }
1678 }
1679
1680 }
1681 return email;
1682 }
1683
1684 public List<OlePatronDocument> getCurrentPatronList() {
1685 if (CollectionUtils.isEmpty(currentPatronList)) {
1686 currentPatronList.add(this);
1687 }
1688 return currentPatronList;
1689 }
1690
1691 public void setCurrentPatronList(List<OlePatronDocument> currentPatronList) {
1692 this.currentPatronList = currentPatronList;
1693 }
1694
1695 public int getLoanedItemsCountByItemType(String itemType) {
1696 Integer itemCount = 0;
1697 List<OleLoanDocument> oleLoanDocuments = getOleLoanDocuments();
1698 for (Iterator<OleLoanDocument> iterator = oleLoanDocuments.iterator(); iterator.hasNext(); ) {
1699 OleLoanDocument oleLoanDocument = iterator.next();
1700 String itemId = oleLoanDocument.getItemId();
1701 String itemTypeCode = getItemTypeFromItemId(itemId);
1702 if (itemTypeCode.equalsIgnoreCase(itemType)) {
1703 itemCount = itemCount + 1;
1704 }
1705 }
1706 return itemCount;
1707 }
1708
1709 private String getItemTypeFromItemId(String itemId) {
1710 HashMap<String, Object> map = new HashMap<String, Object>();
1711 map.put("barCode", itemId);
1712 List<ItemRecord> itemRecords = (List<ItemRecord>) getBusinessObjectService().findMatching(ItemRecord.class, map);
1713 ItemRecord itemRecord = itemRecords.get(0);
1714 return itemRecord.getItemTypeRecord().getCode();
1715 }
1716
1717 public int getTotalLoanedItemsCount() {
1718 return getOleLoanDocuments().size();
1719 }
1720
1721 public String getRequestTypeCode(String itemUUID) {
1722 OleDeliverRequestBo prioritizedRequest = getPrioritizedRequest(itemUUID);
1723 return prioritizedRequest.getRequestTypeCode();
1724 }
1725
1726 public OleDeliverRequestBo getPrioritizedRequest(String itemUuid) {
1727 LOG.debug("Inside the getPrioritizedRequest method");
1728 Map requestMap = new HashMap();
1729 requestMap.put("itemUuid", itemUuid);
1730 requestMap.put("borrowerQueuePosition", 1);
1731 List<OleDeliverRequestBo> oleDeliverRequestBos = (List<OleDeliverRequestBo>) getBusinessObjectService().findMatching(OleDeliverRequestBo.class, requestMap);
1732 return oleDeliverRequestBos != null && oleDeliverRequestBos.size() > 0 ?
1733 oleDeliverRequestBos.get(0) : null;
1734 }
1735
1736 public Integer getAllCharges(String... feeTypes) {
1737 allCharges = 0;
1738 if (feeTypes.length == 0) {
1739 Integer overdueFineAmount = getFeeAmountBasedOnFeeType(OLEConstants.FEE_TYPE_CODE_OVERDUE);
1740 Integer replacementFineAmount = getFeeAmountBasedOnFeeType(OLEConstants.FEE_TYPE_CODE_REPL_FEE);
1741 if (null != overdueFineAmount && null != replacementFineAmount) {
1742 allCharges = overdueFineAmount + replacementFineAmount;
1743 } else {
1744 allCharges = 0;
1745 }
1746 } else {
1747 for(String individualFeeType : feeTypes){
1748 Integer feeAmountBasedOnFeeType = getFeeAmountBasedOnFeeType(individualFeeType);
1749 allCharges += feeAmountBasedOnFeeType;
1750 }
1751 }
1752 return allCharges;
1753 }
1754
1755 private Integer getFeeAmountBasedOnFeeType(String feeType) {
1756 Integer feeAmount = 0;
1757 List<FeeType> feeTypeList = getPatronFeeTypes();
1758 if(CollectionUtils.isNotEmpty(feeTypeList)){
1759 for (Iterator<FeeType> iterator = feeTypeList.iterator(); iterator.hasNext(); ) {
1760 FeeType patronFeeType = iterator.next();
1761 if(patronFeeType.getOleFeeType().getFeeTypeCode().equalsIgnoreCase(feeType)){
1762 feeAmount += patronFeeType.getBalFeeAmount().intValue();
1763 }
1764 }
1765 }
1766 return feeAmount;
1767 }
1768
1769 public Integer getOverdueFineAmount() {
1770 if (null == overdueFineAmt) {
1771 overdueFineAmt = getFeeAmountBasedOnFeeType(OLEConstants.FEE_TYPE_CODE_OVERDUE);
1772 }
1773 return overdueFineAmt;
1774 }
1775
1776 public List<FeeType> getPatronFeeTypes() {
1777 if (null == feeTypeList) {
1778 feeTypeList = new ArrayList<FeeType>();
1779 Map<String, String> criteria = new HashMap<String, String>();
1780 criteria.put("patronId", olePatronId);
1781 List<PatronBillPayment> patronBillPayments = (List<PatronBillPayment>) KRADServiceLocator.getBusinessObjectService().findMatching(PatronBillPayment.class, criteria);
1782 for (PatronBillPayment patronBillPayment : patronBillPayments) {
1783 feeTypeList.addAll(patronBillPayment.getFeeType());
1784 }
1785 }
1786 return feeTypeList;
1787 }
1788
1789 public Integer getReplacementFineAmount() {
1790 if (null == replacementFeeAmt) {
1791 replacementFeeAmt = getFeeAmountBasedOnFeeType(OLEConstants.FEE_TYPE_CODE_REPL_FEE);
1792 }
1793 return replacementFeeAmt;
1794 }
1795
1796 public List<OleLoanDocument> getOleLoanDocumentsFromDb() {
1797 if (StringUtils.isNotEmpty(getOlePatronId())) {
1798 if (StringUtils.isNotEmpty(getOlePatronId())) {
1799 Map<String, String> parameterMap = new HashMap<>();
1800 parameterMap.put("patronId", getOlePatronId());
1801 List<OleLoanDocument> oleLoanDocumentList = (List<OleLoanDocument>) KRADServiceLocator.getBusinessObjectService().findMatching(OleLoanDocument.class, parameterMap);
1802 if (CollectionUtils.isNotEmpty(oleLoanDocumentList)) {
1803 oleLoanDocuments = oleLoanDocumentList;
1804 }
1805 }
1806 }
1807 return oleLoanDocuments;
1808 }
1809
1810 public Boolean isOverDueDays(Integer allowedOverDueDays) {
1811 List<OleLoanDocument> oleLoanDocuments = getOleLoanDocuments();
1812 for (Iterator<OleLoanDocument> iterator = oleLoanDocuments.iterator(); iterator.hasNext(); ) {
1813 OleLoanDocument oleLoanDocument = iterator.next();
1814 if (oleLoanDocument.getLoanDueDate() != null) {
1815 Integer timeDiff = new Integer(getTimeDiff(oleLoanDocument.getLoanDueDate(), new Date()));
1816 if (timeDiff > allowedOverDueDays) {
1817 return true;
1818 }
1819 }
1820 }
1821 return false;
1822 }
1823
1824 public Boolean isRecalledAndOverDue(Integer days) {
1825 List<OleLoanDocument> oleLoanDocuments = getOleLoanDocuments();
1826 for (Iterator<OleLoanDocument> iterator = oleLoanDocuments.iterator(); iterator.hasNext(); ) {
1827 OleLoanDocument oleLoanDocument = iterator.next();
1828 if (oleLoanDocument.getLoanDueDate() != null) {
1829 Integer timeDiff = new Integer(getTimeDiff(oleLoanDocument.getLoanDueDate(), new Date()));
1830 if (timeDiff > days && recallRequestExists(oleLoanDocument)) {
1831 return true;
1832 }
1833 }
1834 }
1835 return false;
1836 }
1837
1838 private boolean recallRequestExists(OleLoanDocument oleLoanDocument) {
1839
1840 List<OleDeliverRequestBo> oleDeliverRequestBos = getOleDeliverRequestBos();
1841 for (Iterator<OleDeliverRequestBo> iterator = oleDeliverRequestBos.iterator(); iterator.hasNext(); ) {
1842 OleDeliverRequestBo oleDeliverRequestBo = iterator.next();
1843 if(oleDeliverRequestBo.getOleDeliverRequestType().getRequestTypeCode().equals("Recall") &&
1844 oleDeliverRequestBo.getLoanTransactionRecordNumber().equals(oleLoanDocument.getLoanId())){
1845 return true;
1846 }
1847 }
1848 return false;
1849 }
1850
1851 public String getTimeDiff(Date dateOne, Date dateTwo) {
1852 String diff = "";
1853 long timeDiff = Math.abs(dateOne.getTime() - dateTwo.getTime());
1854 diff = String.format("%d", TimeUnit.MILLISECONDS.toDays(timeDiff),
1855 -TimeUnit.HOURS.toDays(timeDiff));
1856 return diff;
1857 }
1858
1859 public boolean isCheckoutForSelf() {
1860 return checkoutForSelf;
1861 }
1862
1863 public void setCheckoutForSelf(boolean checkoutForSelf) {
1864 this.checkoutForSelf = checkoutForSelf;
1865 }
1866
1867 public List<OlePatronNotes> getOlePatronUserNotes() {
1868 List<OlePatronNotes> olePatronUserNoteList = new ArrayList<>();
1869 if(CollectionUtils.isNotEmpty(this.getNotes())) {
1870 for(OlePatronNotes olePatronNotes : this.getNotes()) {
1871 if(olePatronNotes.getOlePatronNoteType() != null && (OLEConstants.USER).equalsIgnoreCase(olePatronNotes.getOlePatronNoteType().getPatronNoteTypeCode())) {
1872 olePatronUserNoteList.add(olePatronNotes);
1873 }
1874 }
1875 this.olePatronUserNotes = olePatronUserNoteList;
1876 }
1877 return olePatronUserNotes;
1878 }
1879
1880 public void setOlePatronUserNotes(List<OlePatronNotes> olePatronUserNotes) {
1881 this.olePatronUserNotes = olePatronUserNotes;
1882 }
1883
1884 @Override
1885 public List<Collection<PersistableBusinessObject>> buildListOfDeletionAwareLists() {
1886 List managedLists = super.buildListOfDeletionAwareLists();
1887 managedLists.add(getNotes());
1888 return managedLists;
1889 }
1890 }