View Javadoc

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.patron.api.*;
6   import org.kuali.rice.kim.api.KimConstants;
7   import org.kuali.rice.kim.api.identity.address.EntityAddress;
8   import org.kuali.rice.kim.api.identity.email.EntityEmail;
9   import org.kuali.rice.kim.api.identity.phone.EntityPhone;
10  import org.kuali.rice.kim.impl.identity.address.EntityAddressBo;
11  import org.kuali.rice.kim.impl.identity.email.EntityEmailBo;
12  import org.kuali.rice.kim.impl.identity.employment.EntityEmploymentBo;
13  import org.kuali.rice.kim.impl.identity.entity.EntityBo;
14  import org.kuali.rice.kim.impl.identity.name.EntityNameBo;
15  import org.kuali.rice.kim.impl.identity.phone.EntityPhoneBo;
16  import org.kuali.rice.kim.impl.identity.type.EntityTypeContactInfoBo;
17  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
18  
19  import java.util.*;
20  
21  /**
22   OlePatronDocument provides OlePatronDocument information through getter and setter.
23   */
24  public class OlePatronDocument extends PersistableBusinessObjectBase implements OlePatronContract {
25  
26      private String olePatronId;
27      private String barcode;
28      private String borrowerType;
29      private String affiliationType;
30      private boolean activeIndicator;
31      private boolean generalBlock;
32      private String generalBlockNotes;
33      private boolean pagingPrivilege;
34      private boolean courtesyNotice;
35      private boolean deliveryPrivilege;
36      private Date expirationDate;
37      private Date activationDate;
38      private String firstName;
39      private String middleName;
40      private String lastName;
41      private String emailAddress;
42      private String phoneNumber;
43      private String borrowerTypeName;
44      private String processMessage;
45      private String invalidBarcodeNumber;
46      private Date invalidBarcodeNumEffDate;
47  
48      private List<OleLoanDocument> oleLoanDocuments = new ArrayList<OleLoanDocument>();
49      private List<EntityPhoneBo> phones = new ArrayList<EntityPhoneBo>();
50      private List<EntityAddressBo> addresses = new ArrayList<EntityAddressBo>();
51      private List<OleEntityAddressBo> oleEntityAddressBo = new ArrayList<OleEntityAddressBo>();
52      private EntityNameBo name = new EntityNameBo();
53      private List<EntityEmailBo> emails = new ArrayList<EntityEmailBo>();
54      private List<OlePatronNotes> notes = new ArrayList<OlePatronNotes>();
55      private OleBorrowerType oleBorrowerType;
56      private EntityBo entity = new EntityBo();
57  
58      private List<OlePatronAffiliation> patronAffiliations = new ArrayList<OlePatronAffiliation>();
59      private List<EntityEmploymentBo> employments =  new ArrayList<EntityEmploymentBo>();
60  
61    /*public List<EntityEmploymentBo>  getEmploymentDetails(){
62        List<EntityEmploymentBo> entity = new ArrayList<EntityEmploymentBo>();
63                      for(int i=0;i<patronAffiliations.size();i++){
64                          entity=((List<EntityEmploymentBo>) patronAffiliations.get(i).getEmployments());
65                      }
66        return entity;
67    }
68  */
69  
70  
71      public List<EntityEmploymentBo> getEmployments() {
72          return employments;
73      }
74  
75      public void setEmployments(List<EntityEmploymentBo> employments) {
76          this.employments = employments;
77      }
78  
79      private List<OleProxyPatronDocument> oleProxyPatronDocuments = new ArrayList<OleProxyPatronDocument>();
80      private List<OlePatronDocument> olePatronDocuments = new ArrayList<OlePatronDocument>();
81      private String proxyPatronId;
82  
83  
84      /**
85       * This method converts the PersistableBusinessObjectBase OlePatronDocument into immutable object OlePatronDefinition
86       * @param bo
87       * @return OlePatronDefinition
88       */
89      public static OlePatronDefinition to(OlePatronDocument bo) {
90          if (bo == null) {
91              return null;
92          }
93          return OlePatronDefinition.Builder.create(bo).build();
94      }
95  
96      /**
97       * This method converts the immutable object OlePatronDefinition into PersistableBusinessObjectBase OlePatronDocument
98       * @param immutable
99       * @return OlePatronDocument
100      */
101     public static OlePatronDocument from(OlePatronDefinition immutable) {
102         return fromAndUpdate(immutable, null);
103     }
104 
105     /**
106      * This method will set the PersistableBusinessObjectBase OlePatronDocument from immutable object OlePatronDefinition
107      * @param immutable
108      * @param toUpdate
109      * @return bo(OlePatronDocument)
110      */
111     static OlePatronDocument fromAndUpdate(OlePatronDefinition immutable, OlePatronDocument toUpdate) {
112         if (immutable == null) {
113             return null;
114         }
115         OlePatronDocument bo = toUpdate;
116         if (toUpdate == null) {
117             bo = new OlePatronDocument();
118         }
119         // bo.activeIndicator = immutable.isActiveIndicator();
120         bo.olePatronId = immutable.getOlePatronId();
121 
122         bo.name = new EntityNameBo();
123 
124         if (immutable.getName() != null) {
125             bo.name = EntityNameBo.from(immutable.getName());
126         }
127 
128         bo.barcode = immutable.getBarcode();
129         bo.borrowerType = immutable.getBorrowerType();
130         bo.courtesyNotice = immutable.isCourtesyNotice();
131         bo.generalBlock = immutable.isGeneralBlock();
132         bo.deliveryPrivilege = immutable.isDeliveryPrivilege();
133         bo.pagingPrivilege = immutable.isPagingPrivilege();
134         bo.expirationDate = immutable.getExpirationDate();
135         bo.activationDate = immutable.getActivationDate();
136         bo.activeIndicator = immutable.isActiveIndicator();
137         bo.generalBlockNotes = immutable.getGeneralBlockNotes();
138         bo.invalidBarcodeNumber = immutable.getInvalidBarcodeNumber();
139         bo.invalidBarcodeNumEffDate = immutable.getInvalidBarcodeNumEffDate();
140         if (immutable.getEntity() != null) {
141             bo.entity = EntityBo.from(immutable.getEntity());
142         }
143         if (CollectionUtils.isNotEmpty(immutable.getAddresses())) {
144             for (EntityAddress entityAddr : immutable.getAddresses()) {
145                 bo.addresses.add(EntityAddressBo.from(entityAddr));
146             }
147         }
148         if (CollectionUtils.isNotEmpty(immutable.getEmails())) {
149             for (EntityEmail entityEmail : immutable.getEmails()) {
150                 bo.emails.add(EntityEmailBo.from(entityEmail));
151             }
152         }
153         if (CollectionUtils.isNotEmpty(immutable.getPhones())) {
154             for (EntityPhone entityPhone : immutable.getPhones()) {
155                 bo.phones.add(EntityPhoneBo.from(entityPhone));
156             }
157         }
158 
159         if (CollectionUtils.isNotEmpty(immutable.getNotes())) {
160             for (OlePatronNotesDefinition note : immutable.getNotes()) {
161                 bo.notes.add(OlePatronNotes.from(note));
162             }
163         }
164         if (CollectionUtils.isNotEmpty(immutable.getOleEntityAddressBo())) {
165             for (OleEntityAddressDefinition address : immutable.getOleEntityAddressBo()) {
166                 bo.oleEntityAddressBo.add(OleEntityAddressBo.from(address));
167             }
168         }
169         if (CollectionUtils.isNotEmpty(immutable.getPatronAffiliations())) {
170             for (OlePatronAffiliationDefinition affiliation : immutable.getPatronAffiliations()) {
171                 bo.patronAffiliations.add(OlePatronAffiliation.from(affiliation));
172             }
173         }
174         if (CollectionUtils.isNotEmpty(immutable.getOleProxyPatronDocuments())) {
175             for (OleProxyPatronDefinition proxyPatron : immutable.getOleProxyPatronDocuments()) {
176                 bo.oleProxyPatronDocuments.add(OleProxyPatronDocument.from(proxyPatron));
177             }
178         }
179         /*if (CollectionUtils.isNotEmpty(immutable.getOlePatronDocuments())) {
180             for (OlePatronDefinition olePatron : immutable.getOlePatronDocuments()) {
181                 bo.olePatronDocuments.add(OlePatronDocument.from(olePatron));
182             }
183         }*/
184         bo.versionNumber = immutable.getVersionNumber();
185         //bo.setObjectId(immutable.getObjectId());
186         EntityBo entityBo = new EntityBo();
187         entityBo.setActive(true);
188 
189         if (null != bo.getEntity()) {
190             entityBo = bo.getEntity();
191             entityBo.setActive(true);
192         }
193         entityBo.setNames(Arrays.asList(bo.getName()));
194         EntityTypeContactInfoBo entityTypeContactInfoBo = new EntityTypeContactInfoBo();
195         if(null != bo.getEntity().getEntityTypeContactInfos() && bo.getEntity().getEntityTypeContactInfos().size() > 0){
196             entityTypeContactInfoBo = bo.getEntity().getEntityTypeContactInfos().get(0);
197         }
198         entityTypeContactInfoBo.setAddresses(bo.getAddresses());
199         entityTypeContactInfoBo.setEmailAddresses(bo.getEmails());
200         entityTypeContactInfoBo.setPhoneNumbers(bo.getPhones());
201         entityTypeContactInfoBo.setEntityTypeCode(KimConstants.EntityTypes.PERSON);
202         entityBo.setEntityTypeContactInfos(Arrays.asList(entityTypeContactInfoBo));
203         bo.setEntity(entityBo);
204         return bo;
205     }
206 
207     /**
208      * Gets the value of oleLoanDocuments which is a list of OleLoanDocument
209      * @return oleLoanDocuments(list of type OleLoanDocument)
210      */
211     public List<OleLoanDocument> getOleLoanDocuments() {
212         return oleLoanDocuments;
213     }
214     /**
215      * Sets the value for oleLoanDocuments which is a list of OleLoanDocument
216      * @param oleLoanDocuments(list of type OleLoanDocument)
217      */
218     public void setOleLoanDocuments(List<OleLoanDocument> oleLoanDocuments) {
219         this.oleLoanDocuments = oleLoanDocuments;
220     }
221     /**
222      * Gets the value of borrowerTypeName property
223      * @return borrowerTypeName
224      */
225     public String getBorrowerTypeName() {
226         return oleBorrowerType.getBorrowerTypeName();
227     }
228     /**
229      * Gets the value of entity of type EntityBo
230      * @return entity(EntityBo)
231      */
232     public EntityBo getEntity() {
233         return entity;
234     }
235     /**
236      * Sets the value for entity of type EntityBo
237      * @param entity(EntityBo)
238      */
239     public void setEntity(EntityBo entity) {
240         this.entity = entity;
241     }
242 
243     public String getAffiliationType() {
244         return affiliationType;
245     }
246 
247     public void setAffiliationType(String affiliationType) {
248         this.affiliationType = affiliationType;
249     }
250 
251     /**
252      * Gets the value of notes which is a list of OlePatronNotes
253      * @return notes(list of type OlePatronNotes)
254      */
255     public List<OlePatronNotes> getNotes() {
256         return notes;
257     }
258     /**
259      * Sets the value for notes which is a list of OlePatronNotes
260      * @param notes(list of type OlePatronNotes)
261      */
262     public void setNotes(List<OlePatronNotes> notes) {
263         this.notes = notes;
264     }
265     /**
266      * Gets the value of barcode property
267      * @return barcode
268      */
269     public String getBarcode() {
270         return barcode;
271     }
272     /**
273      * Sets the value for barcode property
274      * @param barcode
275      */
276     public void setBarcode(String barcode) {
277         this.barcode = barcode;
278     }
279     /**
280      * Gets the value of borrowerType property
281      * @return borrowerType
282      */
283     public String getBorrowerType() {
284         return borrowerType;
285     }
286     /**
287      * Sets the value for borrowerType property
288      * @param borrowerType
289      */
290     public void setBorrowerType(String borrowerType) {
291         this.borrowerType = borrowerType;
292     }
293     /**
294      * Gets the boolean value of activeIndicator property
295      * @return activeIndicator
296      */
297     public boolean isActiveIndicator() {
298         return activeIndicator;
299     }
300     /**
301      * Sets the boolean value for activeIndicator property
302      * @param activeIndicator
303      */
304     public void setActiveIndicator(boolean activeIndicator) {
305         this.activeIndicator = activeIndicator;
306     }
307     /**
308      * Gets the value of olePatronId property
309      * @return olePatronId
310      */
311     public String getOlePatronId() {
312         return olePatronId;
313     }
314     /**
315      * Sets the value for olePatronId property
316      * @param olePatronId
317      */
318     public void setOlePatronId(String olePatronId) {
319         this.olePatronId = olePatronId;
320     }
321     /**
322      * Gets the boolean value of generalBlock property
323      * @return generalBlock
324      */
325     public boolean isGeneralBlock() {
326         return generalBlock;
327     }
328     /**
329      * Sets the boolean value for generalBlock property
330      * @param generalBlock
331      */
332     public void setGeneralBlock(boolean generalBlock) {
333         this.generalBlock = generalBlock;
334     }
335     /**
336      * Gets the boolean value of courtesyNotice property
337      * @return courtesyNotice
338      */
339     public boolean isCourtesyNotice() {
340         return courtesyNotice;
341     }
342     /**
343      * Sets the boolean value for courtesyNotice property
344      * @param courtesyNotice
345      */
346     public void setCourtesyNotice(boolean courtesyNotice) {
347         this.courtesyNotice = courtesyNotice;
348     }
349     /**
350      * Gets the boolean value of deliveryPrivilege property
351      * @return deliveryPrivilege
352      */
353     public boolean isDeliveryPrivilege() {
354         return deliveryPrivilege;
355     }
356     /**
357      * Sets the boolean value for deliveryPrivilege property
358      * @param deliveryPrivilege
359      */
360     public void setDeliveryPrivilege(boolean deliveryPrivilege) {
361         this.deliveryPrivilege = deliveryPrivilege;
362     }
363     /**
364      * Gets the boolean value of pagingPrivilege property
365      * @return pagingPrivilege
366      */
367     public boolean isPagingPrivilege() {
368         return pagingPrivilege;
369     }
370     /**
371      * Sets the boolean value for pagingPrivilege property
372      * @param pagingPrivilege
373      */
374     public void setPagingPrivilege(boolean pagingPrivilege) {
375         this.pagingPrivilege = pagingPrivilege;
376     }
377     /**
378      * Gets the value of expirationDate which is of type Date
379      * @return expirationDate(Date)
380      */
381     public Date getExpirationDate() {
382         return expirationDate;
383     }
384     /**
385      * Sets the value for expirationDate which is of type Date
386      * @param expirationDate
387      */
388     public void setExpirationDate(Date expirationDate) {
389         this.expirationDate = expirationDate;
390     }
391     /**
392      * Gets the value of firstName property
393      * @return firstName
394      */
395     public String getFirstName() {
396         return firstName;
397     }
398     /**
399      * Sets the value for firstName property
400      * @param firstName
401      */
402     public void setFirstName(String firstName) {
403         this.firstName = firstName;
404     }
405     /**
406      * Gets the value of middleName property
407      * @return middleName
408      */
409     public String getMiddleName() {
410         return middleName;
411     }
412     /**
413      * Sets the value for middleName property
414      * @param middleName
415      */
416     public void setMiddleName(String middleName) {
417         this.middleName = middleName;
418     }
419     /**
420      * Gets the value of lastName property
421      * @return lastName
422      */
423     public String getLastName() {
424         return lastName;
425     }
426     /**
427      * Sets the value for lastName property
428      * @param lastName
429      */
430     public void setLastName(String lastName) {
431         this.lastName = lastName;
432     }
433     /**
434      * Gets the value of emailAddress property
435      * @return emailAddress
436      */
437     public String getEmailAddress() {
438         return emailAddress;
439     }
440     /**
441      * Sets the value for emailAddress property
442      * @param emailAddress
443      */
444     public void setEmailAddress(String emailAddress) {
445         this.emailAddress = emailAddress;
446     }
447     /**
448      * Gets the value of phoneNumber property
449      * @return phoneNumber
450      */
451     public String getPhoneNumber() {
452         return phoneNumber;
453     }
454     /**
455      * Sets the value for phoneNumber property
456      * @param phoneNumber
457      */
458     public void setPhoneNumber(String phoneNumber) {
459         this.phoneNumber = phoneNumber;
460     }
461     /**
462      * Gets the value of phones which is a list of EntityPhoneBo
463      * @return phones(list of type EntityPhoneBo)
464      */
465     public List<EntityPhoneBo> getPhones() {
466         return phones;
467     }
468     /**
469      * Sets the value for phones which is a list of EntityPhoneBo
470      * @param phones(list of type EntityPhoneBo)
471      */
472     public void setPhones(List<EntityPhoneBo> phones) {
473         this.phones = phones;
474     }
475     /**
476      * Gets the value of addresses which is a list of EntityAddressBo
477      * @return addresses(list of type EntityAddressBo)
478      */
479     public List<EntityAddressBo> getAddresses() {
480         return addresses;
481     }
482     /**
483      * Sets the value for addresses which is a list of EntityAddressBo
484      * @param addresses(list of type EntityAddressBo)
485      */
486     public void setAddresses(List<EntityAddressBo> addresses) {
487         this.addresses = addresses;
488     }
489     /**
490      * Gets the value of name which is of type EntityNameBo
491      * @return name(EntityNameBo)
492      */
493     public EntityNameBo getName() {
494         return name;
495     }
496     /**
497      * Sets the value for name which is of type EntityNameBo
498      * @param name(EntityNameBo)
499      */
500     public void setName(EntityNameBo name) {
501         this.name = name;
502     }
503     /**
504      * Gets the value of emails which is a list of EntityEmailBo
505      * @return emails(list of type EntityEmailBo)
506      */
507     public List<EntityEmailBo> getEmails() {
508         return emails;
509     }
510     /**
511      * Sets the value for emails which is a list of EntityEmailBo
512      * @param emails(list of type EntityEmailBo)
513      */
514     public void setEmails(List<EntityEmailBo> emails) {
515         this.emails = emails;
516     }
517     /**
518      * Gets the value of oleBorrowerType which is of type OleBorrowerType
519      * @return oleBorrowerType(OleBorrowerType)
520      */
521     public OleBorrowerType getOleBorrowerType() {
522         return oleBorrowerType;
523     }
524     /**
525      * Sets the value for oleBorrowerType which is of type OleBorrowerType
526      * @param oleBorrowerType(OleBorrowerType)
527      */
528     public void setOleBorrowerType(OleBorrowerType oleBorrowerType) {
529         this.oleBorrowerType = oleBorrowerType;
530     }
531     /**
532      * Gets the value of processMessage property
533      * @return processMessage
534      */
535     public String getProcessMessage() {
536         return processMessage;
537     }
538     /**
539      * Sets the value for processMessage property
540      * @param processMessage
541      */
542     public void setProcessMessage(String processMessage) {
543         this.processMessage = processMessage;
544     }
545 
546     protected LinkedHashMap toStringMapper() {
547         LinkedHashMap toStringMap = new LinkedHashMap();
548         toStringMap.put("olePatronId", olePatronId);
549         return toStringMap;
550     }
551     /**
552      * Gets the value of olePatronId property
553      * @return olePatronId
554      */
555     @Override
556     public String getId() {
557         return this.getOlePatronId();
558     }
559     /**
560      * Gets the value of olePatronDocuments property
561      * @return olePatronDocuments
562      */
563     public List<OlePatronDocument> getOlePatronDocuments() {
564         return olePatronDocuments;
565     }
566     /**
567      * Sets the value for olePatronDocuments property
568      * @param olePatronDocuments
569      */
570     public void setOlePatronDocuments(List<OlePatronDocument> olePatronDocuments) {
571         this.olePatronDocuments = olePatronDocuments;
572     }
573     /**
574      * Gets the value of proxyPatronId property
575      * @return proxyPatronId
576      */
577     public String getProxyPatronId() {
578         return proxyPatronId;
579     }
580     /**
581      * Sets the value for proxyPatronId property
582      * @param proxyPatronId
583      */
584     public void setProxyPatronId(String proxyPatronId) {
585         this.proxyPatronId = proxyPatronId;
586     }
587     /**
588      * Gets the value of oleProxyPatronDocuments property
589      * @return oleProxyPatronDocuments
590      */
591     public List<OleProxyPatronDocument> getOleProxyPatronDocuments() {
592         return oleProxyPatronDocuments;
593     }
594     /**
595      * Sets the value for oleProxyPatronDocuments property
596      * @param oleProxyPatronDocuments
597      */
598     public void setOleProxyPatronDocuments(List<OleProxyPatronDocument> oleProxyPatronDocuments) {
599         this.oleProxyPatronDocuments = oleProxyPatronDocuments;
600     }
601     /**
602      * Gets the value of activationDate property
603      * @return activationDate
604      */
605     public Date getActivationDate() {
606         return activationDate;
607     }
608     /**
609      * Sets the value for activationDate property
610      * @param activationDate
611      */
612     public void setActivationDate(Date activationDate) {
613         this.activationDate = activationDate;
614     }
615     /**
616      * Gets the value of generalBlockNotes property
617      * @return generalBlockNotes
618      */
619     public String getGeneralBlockNotes() {
620         return generalBlockNotes;
621     }
622     /**
623      * Sets the value for generalBlockNotes property
624      * @param generalBlockNotes
625      */
626     public void setGeneralBlockNotes(String generalBlockNotes) {
627         this.generalBlockNotes = generalBlockNotes;
628     }
629     /**
630      * Gets the value of invalidBarcodeNumber property
631      * @return invalidBarcodeNumber
632      */
633     public String getInvalidBarcodeNumber() {
634         return invalidBarcodeNumber;
635     }
636     /**
637      * Sets the value for invalidBarcodeNumber property
638      * @param invalidBarcodeNumber
639      */
640     public void setInvalidBarcodeNumber(String invalidBarcodeNumber) {
641         this.invalidBarcodeNumber = invalidBarcodeNumber;
642     }
643     /**
644      * Gets the value of invalidBarcodeNumEffDate property
645      * @return invalidBarcodeNumEffDate
646      */
647     public Date getInvalidBarcodeNumEffDate() {
648         return invalidBarcodeNumEffDate;
649     }
650     /**
651      * Sets the value for invalidBarcodeNumEffDate property
652      * @param invalidBarcodeNumEffDate
653      */
654     public void setInvalidBarcodeNumEffDate(Date invalidBarcodeNumEffDate) {
655         this.invalidBarcodeNumEffDate = invalidBarcodeNumEffDate;
656     }
657     /**
658      * Gets the value of oleEntityAddressBo property
659      * @return oleEntityAddressBo
660      */
661     public List<OleEntityAddressBo> getOleEntityAddressBo() {
662         return oleEntityAddressBo;
663     }
664     /**
665      * Sets the value for oleEntityAddressBo property
666      * @param oleEntityAddressBo
667      */
668     public void setOleEntityAddressBo(List<OleEntityAddressBo> oleEntityAddressBo) {
669         this.oleEntityAddressBo = oleEntityAddressBo;
670     }
671     /**
672      * Gets the value of patronAffiliations property
673      * @return patronAffiliations
674      */
675     public List<OlePatronAffiliation> getPatronAffiliations() {
676         return patronAffiliations;
677     }
678     /**
679      * Sets the value for patronAffiliations property
680      * @param patronAffiliations
681      */
682     public void setPatronAffiliations(List<OlePatronAffiliation> patronAffiliations) {
683         this.patronAffiliations = patronAffiliations;
684     }
685 }