001    package org.kuali.ole.patron.api;
002    
003    import org.apache.commons.collections.CollectionUtils;
004    import org.apache.commons.lang.StringUtils;
005    import org.kuali.api.jaxb.DateAdapter;
006    import org.kuali.rice.core.api.CoreConstants;
007    import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
008    import org.kuali.rice.core.api.mo.ModelBuilder;
009    import org.kuali.rice.kim.api.KimConstants;
010    import org.kuali.rice.kim.api.identity.address.EntityAddress;
011    import org.kuali.rice.kim.api.identity.address.EntityAddressContract;
012    import org.kuali.rice.kim.api.identity.email.EntityEmail;
013    import org.kuali.rice.kim.api.identity.email.EntityEmailContract;
014    import org.kuali.rice.kim.api.identity.entity.Entity;
015    import org.kuali.rice.kim.api.identity.name.EntityName;
016    import org.kuali.rice.kim.api.identity.phone.EntityPhone;
017    import org.kuali.rice.kim.api.identity.phone.EntityPhoneContract;
018    import org.w3c.dom.Element;
019    
020    import javax.xml.bind.annotation.*;
021    import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
022    import java.io.Serializable;
023    import java.util.ArrayList;
024    import java.util.Collection;
025    import java.util.Date;
026    import java.util.List;
027    
028    /**
029     * Created with IntelliJ IDEA.
030     * User: ?
031     * Date: 5/24/12
032     * Time: 8:26 PM
033     * To change this template use File | Settings | File Templates.
034     */
035    @XmlRootElement(name = OlePatronDefinition.Constants.ROOT_ELEMENT_NAME)
036    @XmlAccessorType(XmlAccessType.NONE)
037    @XmlType(name = OlePatronDefinition.Constants.TYPE_NAME, propOrder = {
038            OlePatronDefinition.Elements.PATRON_ID,
039            OlePatronDefinition.Elements.BARCODE,
040            OlePatronDefinition.Elements.BORROWER_TYPE,
041            OlePatronDefinition.Elements.ACITVE_INICATOR,
042            OlePatronDefinition.Elements.GENERAL_BLOCK,
043            OlePatronDefinition.Elements.PAGING_PRIVILEGE,
044            OlePatronDefinition.Elements.COURTESY_NOTICE,
045            OlePatronDefinition.Elements.DELIVERYPRIVILEGE,
046            OlePatronDefinition.Elements.EXPIRATION_DATE,
047            OlePatronDefinition.Elements.ACTIVATION_DATE,
048            OlePatronDefinition.Elements.OLE_BORROWER_TYPE,
049            OlePatronDefinition.Elements.PHONES,
050            OlePatronDefinition.Elements.ADDRESSES,
051            OlePatronDefinition.Elements.NAME,
052            OlePatronDefinition.Elements.EMAILS,
053            OlePatronDefinition.Elements.NOTES,
054            OlePatronDefinition.Elements.LOST_BARCODES,
055            OlePatronDefinition.Elements.OLE_ENTITY_ADDRESSES,
056            OlePatronDefinition.Elements.GENERAL_BLOCK_NOTES,
057            OlePatronDefinition.Elements.PATRON_AFFILIATIONS,
058            OlePatronDefinition.Elements.OLE_PROXY_PATRON_DOCS,
059           // OlePatronDefinition.Elements.OLE_PATRON_DOCS,
060            OlePatronDefinition.Elements.OLE_SOURCE,
061            OlePatronDefinition.Elements.OLE_STATISTICAL_CAT,
062            OlePatronDefinition.Elements.OLE_ADDRESSES,
063            OlePatronDefinition.Elements.OLE_PATRON_LOCAL_IDS,
064            CoreConstants.CommonElements.VERSION_NUMBER,
065            //CoreConstants.CommonElements.OBJECT_ID,
066            CoreConstants.CommonElements.FUTURE_ELEMENTS
067    })
068    public final class OlePatronDefinition extends AbstractDataTransferObject implements OlePatronContract{
069    
070        private static final long serialVersionUID = 1L;
071    
072        @XmlElement(name = Elements.PATRON_ID, required = false)
073        private final String olePatronId;
074    
075        @XmlElement(name = Elements.BARCODE, required = false)
076        private final String barcode;
077    
078        @XmlElement(name = Elements.BORROWER_TYPE, required = false)
079        private final String borrowerType;
080    
081        @XmlElement(name = Elements.ACITVE_INICATOR, required = false)
082        private final boolean activeIndicator;
083    
084        @XmlElement(name = Elements.GENERAL_BLOCK, required = false)
085        private final boolean generalBlock;
086    
087        @XmlElement(name = Elements.PAGING_PRIVILEGE, required = false)
088        private final boolean pagingPrivilege;
089    
090        @XmlElement(name = Elements.COURTESY_NOTICE, required = false)
091        private final boolean courtesyNotice;
092    
093        @XmlElement(name = Elements.DELIVERYPRIVILEGE, required = false)
094        private final boolean deliveryPrivilege;
095    
096        @XmlElement(name = Elements.EXPIRATION_DATE, required = false)
097        @XmlJavaTypeAdapter(value=DateAdapter.class, type=Date.class)
098        private final Date expirationDate;
099    
100        @XmlElement(name = Elements.ACTIVATION_DATE, required = false)
101        @XmlJavaTypeAdapter(value=DateAdapter.class, type=Date.class)
102        private final Date activationDate;
103    
104        @XmlElementWrapper(name = Elements.PHONES, required = false)
105        @XmlElement(name = Elements.PHONE, required = false)
106        private final List<EntityPhone> phones;
107    
108        @XmlElementWrapper(name = Elements.ADDRESSES, required = false)
109        @XmlElement(name = Elements.ADDRESS, required = false)
110        private final List<EntityAddress> addresses;
111    
112        @XmlElement(name = Elements.NAME, required = false)
113        private final EntityName name;
114    
115        @XmlElementWrapper(name = Elements.EMAILS, required = false)
116        @XmlElement(name = Elements.EMAIL, required = false)
117        private final List<EntityEmail> emails;
118    
119        @XmlElementWrapper(name = Elements.NOTES, required = false)
120        @XmlElement(name = Elements.NOTE, required = false)
121        private final List<OlePatronNotesDefinition> notes;
122    
123        @XmlElementWrapper(name = Elements.LOST_BARCODES, required = false)
124        @XmlElement(name = Elements.LOST_BARCODE, required = false)
125        private final List<OlePatronLostBarcodeDefinition> lostBarcodes;
126    
127        @XmlElementWrapper(name = Elements.OLE_ENTITY_ADDRESSES, required = false)
128        @XmlElement(name = Elements.OLE_ENTITY_ADDRESS, required = false)
129        private final List<OleEntityAddressDefinition> oleEntityAddressBo;
130    
131        @XmlElementWrapper(name = Elements.PATRON_AFFILIATIONS, required = false)
132        @XmlElement(name = Elements.PATRON_AFFILIATION, required = false)
133        private final List<OlePatronAffiliationDefinition> patronAffiliations;
134    
135        @XmlElementWrapper(name = Elements.OLE_PROXY_PATRON_DOCS, required = false)
136        @XmlElement(name = Elements.OLE_PROXY_PATRON_DOC, required = false)
137        private final List<OleProxyPatronDefinition> oleProxyPatronDocuments;
138    
139        @XmlElementWrapper(name = Elements.OLE_ADDRESSES, required = false)
140        @XmlElement(name = Elements.OLE_ADDRESS, required = false)
141        private final List<OleAddressDefinition> oleAddresses;
142    
143        @XmlElement(name = Elements.GENERAL_BLOCK_NOTES, required = false)
144        private final String generalBlockNotes;
145    
146        @XmlElement(name = Elements.OLE_SOURCE, required = false)
147        private final String source;
148    
149    
150        @XmlElement(name = Elements.OLE_STATISTICAL_CAT, required = false)
151        private final String statisticalCategory;
152    
153        @XmlElementWrapper(name = Elements.OLE_PATRON_LOCAL_IDS, required = false)
154        @XmlElement(name = Elements.OLE_PATRON_LOCAL_ID, required = false)
155        private final List<OlePatronLocalIdentificationDefinition> olePatronLocalIds;
156    
157        @XmlElement(name = Elements.OLE_BORROWER_TYPE, required = false)
158        private final OleBorrowerTypeDefinition oleBorrowerType;
159    
160        //@XmlElement(name = Elements.ENTITY, required = false)
161        private final Entity entity;
162    
163        @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
164        private final Long versionNumber;
165    
166        /*@XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
167        private final String objectId;*/
168        @SuppressWarnings("unused")
169        @XmlAnyElement
170        private final Collection<Element> _futureElements = null;
171    
172        public OlePatronDefinition() {
173            this.olePatronId = null;
174            this.barcode = null;
175            this.borrowerType = null;
176            this.activeIndicator = false;
177            this.generalBlock = false;
178            this.pagingPrivilege = false;
179            this.courtesyNotice = false;
180            this.deliveryPrivilege = false;
181            this.expirationDate = null;
182            this.activationDate = null;
183    
184            this.phones = null;
185            this.addresses = null;
186            this.name = null;
187            this.emails = null;
188            this.notes = null;
189            this.lostBarcodes = null;
190            this.oleEntityAddressBo = null;
191            this.patronAffiliations = null;
192            this.oleBorrowerType = null;
193            this.entity = null;
194            this.generalBlockNotes = null;
195            this.oleProxyPatronDocuments = null;
196            //this.olePatronDocuments = null;
197            this.source = null;
198            this.statisticalCategory = null;
199            this.oleAddresses = null;
200            this.olePatronLocalIds = null;
201            this.versionNumber = null;
202            //this.objectId = null;
203        }
204    
205    
206        private OlePatronDefinition(Builder builder) {
207            this.olePatronId = builder.getOlePatronId();
208            this.barcode = builder.getBarcode();
209            this.borrowerType = builder.getBorrowerType();
210            this.activeIndicator = builder.isActiveIndicator();
211            this.generalBlock = builder.isGeneralBlock();
212            this.pagingPrivilege = builder.isPagingPrivilege();
213            this.courtesyNotice = builder.isCourtesyNotice();
214            this.deliveryPrivilege = builder.isDeliveryPrivilege();
215            this.expirationDate = builder.getExpirationDate();
216            this.activationDate = builder.getActivationDate();
217            this.generalBlockNotes = builder.getGeneralBlockNotes();
218            this.source = builder.getSource();
219            this.statisticalCategory = builder.getStatisticalCategory();
220            this.oleBorrowerType = builder.getOleBorrowerType().build();
221    
222            this.addresses = new ArrayList<EntityAddress>();
223            if (!CollectionUtils.isEmpty(builder.getAddresses())) {
224                for (EntityAddress.Builder address : builder.getAddresses()) {
225                    this.addresses.add(address.build());
226                }
227            }
228    
229            this.emails = new ArrayList<EntityEmail>();
230            if (!CollectionUtils.isEmpty(builder.getEmails())) {
231                for (EntityEmail.Builder email : builder.getEmails()) {
232                    this.emails.add(email.build());
233                }
234            }
235            this.phones = new ArrayList<EntityPhone>();
236            if (!CollectionUtils.isEmpty(builder.getPhones())) {
237                for (EntityPhone.Builder phoneNumber : builder.getPhones()) {
238                    this.phones.add(phoneNumber.build());
239                }
240            }
241            this.name = builder.getName().build();
242    
243            this.notes = new ArrayList<OlePatronNotesDefinition>();
244            if (!CollectionUtils.isEmpty(builder.getNotes())) {
245                for (OlePatronNotesDefinition.Builder note : builder.getNotes()) {
246                    this.notes.add(note.build());
247                }
248            }
249    
250            this.lostBarcodes = new ArrayList<OlePatronLostBarcodeDefinition>();
251            if (!CollectionUtils.isEmpty(builder.getLostBarcodes())) {
252                for (OlePatronLostBarcodeDefinition.Builder lostBarcode : builder.getLostBarcodes()) {
253                    this.lostBarcodes.add(lostBarcode.build());
254                }
255            }
256    
257            this.oleEntityAddressBo = new ArrayList<OleEntityAddressDefinition>();
258            if (!CollectionUtils.isEmpty(builder.getOleEntityAddressBo())) {
259                for (OleEntityAddressDefinition.Builder oleEntityAddress : builder.getOleEntityAddressBo()) {
260                    this.oleEntityAddressBo.add(oleEntityAddress.build());
261                }
262            }
263    
264            this.patronAffiliations= new ArrayList<OlePatronAffiliationDefinition>();
265            if (!CollectionUtils.isEmpty(builder.getPatronAffiliations())) {
266                for (OlePatronAffiliationDefinition.Builder oleAffiliation : builder.getPatronAffiliations()) {
267                    this.patronAffiliations.add(oleAffiliation.build());
268                }
269            }
270    
271            this.oleProxyPatronDocuments= new ArrayList<OleProxyPatronDefinition>();
272            if (!CollectionUtils.isEmpty(builder.getOleProxyPatronDocuments())) {
273                for (OleProxyPatronDefinition.Builder oleProxyPatron : builder.getOleProxyPatronDocuments()) {
274                    this.oleProxyPatronDocuments.add(oleProxyPatron.build());
275                }
276            }
277    
278            this.oleAddresses= new ArrayList<OleAddressDefinition>();
279            if (!CollectionUtils.isEmpty(builder.getOleAddresses())) {
280                for (OleAddressDefinition.Builder oleAddress : builder.getOleAddresses()) {
281                    this.oleAddresses.add(oleAddress.build());
282                }
283            }
284    
285            this.olePatronLocalIds= new ArrayList<OlePatronLocalIdentificationDefinition>();
286            if (!CollectionUtils.isEmpty(builder.getOlePatronLocalIds())) {
287                for (OlePatronLocalIdentificationDefinition.Builder olePatronLocalIds: builder.getOlePatronLocalIds()) {
288                    this.olePatronLocalIds.add(olePatronLocalIds.build());
289                }
290            }
291    
292            this.entity = builder.getEntity().build();
293    
294            this.versionNumber = builder.getVersionNumber();
295            //this.objectId = builder.getObjectId();
296        }
297    
298        @Override
299        public String getOlePatronId() {
300            return this.olePatronId;
301        }
302    
303        @Override
304        public String getBarcode() {
305            return this.barcode;
306        }
307    
308        @Override
309        public String getBorrowerType() {
310            return this.borrowerType;
311        }
312    
313        @Override
314        public boolean isActiveIndicator() {
315            return this.activeIndicator;
316        }
317    
318        @Override
319        public boolean isGeneralBlock() {
320            return this.generalBlock;
321        }
322    
323        @Override
324        public boolean isPagingPrivilege() {
325            return this.pagingPrivilege;
326        }
327    
328        @Override
329        public boolean isCourtesyNotice() {
330            return this.courtesyNotice;
331        }
332    
333        @Override
334        public boolean isDeliveryPrivilege() {
335            return this.deliveryPrivilege;
336        }
337    
338        @Override
339        public Date getExpirationDate() {
340            return this.expirationDate;
341        }
342    
343        @Override
344        public Date getActivationDate() {
345            return this.activationDate;
346        }
347    
348        @Override
349        public List<EntityAddress> getAddresses() {
350            return this.addresses;
351        }
352    
353        @Override
354        public List<EntityEmail> getEmails() {
355            return this.emails;
356        }
357    
358        @Override
359        public EntityName getName() {
360            return this.name;
361        }
362    
363        @Override
364        public List<EntityPhone> getPhones() {
365            return this.phones;
366        }
367    
368        @Override
369        public List<OleEntityAddressDefinition> getOleEntityAddressBo() {
370            return this.oleEntityAddressBo;
371        }
372    
373        @Override
374        public List<OlePatronAffiliationDefinition> getPatronAffiliations() {
375            return this.patronAffiliations;
376        }
377    
378        @Override
379        public List<OleProxyPatronDefinition> getOleProxyPatronDocuments() {
380            return this.oleProxyPatronDocuments;
381        }
382    
383        @Override
384        public List<OleAddressDefinition> getOleAddresses() {
385            return this.oleAddresses;
386        }
387    
388        @Override
389        public List<OlePatronLocalIdentificationDefinition> getOlePatronLocalIds() {
390            return this.olePatronLocalIds;
391        }
392    
393        @Override
394        public String getGeneralBlockNotes() {
395            return this.generalBlockNotes;
396        }
397    
398        @Override
399        public String getSource() {
400            return this.source;
401        }
402    
403        @Override
404        public String getStatisticalCategory() {
405            return this.statisticalCategory;
406        }
407    
408        @Override
409        public Entity getEntity() {
410            return this.entity;
411        }
412    
413        @Override
414        public String getId() {
415            return this.olePatronId;
416        }
417    
418        /* @Override
419        public boolean isActive() {
420            return this.activeIndicator;
421        }*/
422    
423        @Override
424        public Long getVersionNumber() {
425            return this.versionNumber;
426        }
427    
428        @Override
429        public List<OlePatronNotesDefinition> getNotes() {
430            return this.notes;
431        }
432    
433        @Override
434        public List<OlePatronLostBarcodeDefinition> getLostBarcodes() {
435            return this.lostBarcodes;
436        }
437    
438        //@Override
439        public OleBorrowerTypeDefinition getOleBorrowerType() {
440            return this.oleBorrowerType;
441        }
442    
443        public static class Builder
444                implements Serializable, ModelBuilder, OlePatronContract
445        {
446            private String olePatronId;
447            private String barcode;
448            private String borrowerType;
449            private boolean activeIndicator;
450            private boolean generalBlock;
451            private boolean pagingPrivilege;
452            private boolean courtesyNotice;
453            private boolean deliveryPrivilege;
454            private Date expirationDate;
455            private Date activationDate;
456            private Date invalidBarcodeNumEffDate;
457            private String generalBlockNotes;
458            private String source;
459            private String statisticalCategory;
460            private String addressSource;
461    
462            private List<EntityPhone.Builder> phones;
463            private List<EntityAddress.Builder> addresses;
464            private EntityName.Builder name;
465            private List<EntityEmail.Builder> emails;
466            private List<OlePatronNotesDefinition.Builder> notes;
467            private List<OlePatronLostBarcodeDefinition.Builder> lostBarcodes;
468            private OleBorrowerTypeDefinition.Builder oleBorrowerType;
469            private OleSourceDefinition.Builder sourceBo;
470            private OleStatisticalCategoryDefinition.Builder statisticalCategoryBo;
471            private Entity.Builder entity;
472            private List<OleEntityAddressDefinition.Builder> oleEntityAddressBo;
473            private List<OlePatronAffiliationDefinition.Builder> patronAffiliations;
474            private List<OleProxyPatronDefinition.Builder> oleProxyPatronDocuments;
475            private List<OlePatronDefinition.Builder> olePatronDocuments;
476            private List<OlePatronLocalIdentificationDefinition.Builder> olePatronLocalIds;
477            private List<OleAddressDefinition.Builder> oleAddresses;
478    
479            private Long versionNumber;
480            private String objectId;
481    
482            private Builder() { }
483    
484            public static Builder create() {
485                return new Builder();
486            }
487    
488            public static Builder create(OlePatronContract contract) {
489                if(contract == null) {
490                    throw new IllegalArgumentException("contract was null");
491                }
492                Builder builder = create();
493                if (contract.getOlePatronId() != null) {
494                    builder.setOlePatronId(contract.getOlePatronId());
495                }
496                if(contract.getBarcode() != null) {
497                    builder.setBarcode(contract.getBarcode());
498                }
499                if(contract.getBorrowerType() != null) {
500                    builder.setBorrowerType(contract.getBorrowerType());
501                }
502                if(contract.isActiveIndicator()) {
503                    builder.setActiveIndicator(contract.isActiveIndicator());
504                    builder.setActive(contract.isActiveIndicator());
505                }
506                if(contract.isGeneralBlock()) {
507                    builder.setGeneralBlock(contract.isGeneralBlock());
508                }
509                if(contract.isDeliveryPrivilege()) {
510                    builder.setDeliveryPrivilege(contract.isDeliveryPrivilege());
511                }
512                if(contract.isPagingPrivilege()) {
513                    builder.setPagingPrivilege(contract.isPagingPrivilege());
514                }
515                if(contract.isCourtesyNotice()) {
516                    builder.setCourtesyNotice(contract.isCourtesyNotice());
517                }
518                if(contract.getExpirationDate() != null) {
519                    builder.setExpirationDate(contract.getExpirationDate());
520                }
521                if(contract.getActivationDate() != null) {
522                    builder.setActivationDate(contract.getActivationDate());
523                }
524                if(contract.getGeneralBlockNotes() != null) {
525                    builder.setGeneralBlockNotes(contract.getGeneralBlockNotes());
526                }
527                if(contract.getSource()!= null) {
528                    builder.setSource(contract.getSource());
529                }
530                if(contract.getStatisticalCategory()!= null) {
531                    builder.setStatisticalCategory(contract.getStatisticalCategory());
532                }
533                if (contract.getEntity() != null) {
534                    builder.setEntity(Entity.Builder.create(contract.getEntity()));
535                }
536                builder.addresses = new ArrayList<EntityAddress.Builder>();
537                if (!CollectionUtils.isEmpty(contract.getAddresses())) {
538                    for (EntityAddressContract addressContract : contract.getAddresses()) {
539                        builder.addresses.add(EntityAddress.Builder.create(addressContract));
540                    }
541                }
542                else if(contract.getEntity() != null) {
543                    if(!CollectionUtils.isEmpty(contract.getEntity().getEntityTypeContactInfos()) &&
544                            !CollectionUtils.isEmpty(contract.getEntity().getEntityTypeContactInfos().get(0).getAddresses())) {
545                        for (EntityAddressContract addressContract : contract.getEntity().getEntityTypeContactInfos().get(0).getAddresses()) {
546                            builder.addresses.add(EntityAddress.Builder.create(addressContract));
547                        }
548                    }
549    
550                }
551                builder.emails = new ArrayList<EntityEmail.Builder>();
552                if (!CollectionUtils.isEmpty(contract.getEmails())) {
553                    for (EntityEmailContract emailContract : contract.getEmails()) {
554                        builder.emails.add(EntityEmail.Builder.create(emailContract));
555                    }
556                }
557                else if(contract.getEntity() != null) {
558                    if(!CollectionUtils.isEmpty(contract.getEntity().getEntityTypeContactInfos()) &&
559                            !CollectionUtils.isEmpty(contract.getEntity().getEntityTypeContactInfos().get(0).getEmailAddresses())) {
560                        for (EntityEmailContract emailContract : contract.getEntity().getEntityTypeContactInfos().get(0).getEmailAddresses()) {
561                            builder.emails.add(EntityEmail.Builder.create(emailContract));
562                        }
563                    }
564    
565                }
566                builder.phones = new ArrayList<EntityPhone.Builder>();
567                if (!CollectionUtils.isEmpty(contract.getPhones())) {
568                    for (EntityPhoneContract phoneContract : contract.getPhones()) {
569                        builder.phones.add(EntityPhone.Builder.create(phoneContract));
570                    }
571                }
572                else if(contract.getEntity() != null) {
573                    if(!CollectionUtils.isEmpty(contract.getEntity().getEntityTypeContactInfos()) &&
574                            !CollectionUtils.isEmpty(contract.getEntity().getEntityTypeContactInfos().get(0).getPhoneNumbers())) {
575                        for (EntityPhoneContract phoneContract : contract.getEntity().getEntityTypeContactInfos().get(0).getPhoneNumbers()) {
576                            builder.phones.add(EntityPhone.Builder.create(phoneContract));
577                        }
578                    }
579    
580                }
581                builder.oleEntityAddressBo = new ArrayList<OleEntityAddressDefinition.Builder>();
582                if (!CollectionUtils.isEmpty(contract.getOleEntityAddressBo())) {
583                    for (OleEntityAddressContract oleEntityAddressContract : contract.getOleEntityAddressBo()) {
584                        builder.oleEntityAddressBo.add(OleEntityAddressDefinition.Builder.create(oleEntityAddressContract));
585                    }
586                }
587                builder.oleAddresses = new ArrayList<OleAddressDefinition.Builder>();
588                if (!CollectionUtils.isEmpty(contract.getOleAddresses())) {
589                    for (OleAddressContract oleAddressContract : contract.getOleAddresses()) {
590                        builder.oleAddresses.add(OleAddressDefinition.Builder.create(oleAddressContract));
591                    }
592                }
593                if (contract.getName() != null && contract.getName().getFirstName() != null) {
594                    builder.setName(EntityName.Builder.create(contract.getName()));
595                }
596                else if(contract.getEntity() != null) {
597                    if(!CollectionUtils.isEmpty(contract.getEntity().getNames())) {
598                        builder.setName(EntityName.Builder.create(contract.getEntity().getNames().get(0)));
599                    }
600    
601                }
602                if(contract.getOleBorrowerType() != null) {
603                    builder.setOleBorrowerType(OleBorrowerTypeDefinition.Builder.create(contract.getOleBorrowerType()));
604                }
605                builder.notes = new ArrayList<OlePatronNotesDefinition.Builder>();
606                if (!CollectionUtils.isEmpty(contract.getNotes())) {
607                    for(OlePatronNotesContract noteContract : contract.getNotes()) {
608                        builder.notes.add(OlePatronNotesDefinition.Builder.create(noteContract));
609                    }
610                }
611                builder.lostBarcodes = new ArrayList<OlePatronLostBarcodeDefinition.Builder>();
612                if (!CollectionUtils.isEmpty(contract.getLostBarcodes())) {
613                    for(OlePatronLostBarcodeContract lostBarcodeContract : contract.getLostBarcodes()) {
614                        builder.lostBarcodes.add(OlePatronLostBarcodeDefinition.Builder.create(lostBarcodeContract));
615                    }
616                }
617                builder.patronAffiliations = new ArrayList<OlePatronAffiliationDefinition.Builder>();
618                if (!CollectionUtils.isEmpty(contract.getPatronAffiliations())) {
619                    for(OlePatronAffiliationContract affiliationContract : contract.getPatronAffiliations()) {
620                        builder.patronAffiliations.add(OlePatronAffiliationDefinition.Builder.create(affiliationContract));
621                    }
622                }
623    
624                builder.oleProxyPatronDocuments = new ArrayList<OleProxyPatronDefinition.Builder>();
625                if (!CollectionUtils.isEmpty(contract.getOleProxyPatronDocuments())) {
626                    for(OleProxyPatronContract proxyContract : contract.getOleProxyPatronDocuments()) {
627                        builder.oleProxyPatronDocuments.add(OleProxyPatronDefinition.Builder.create(proxyContract));
628                    }
629                }
630                builder.olePatronLocalIds = new ArrayList<OlePatronLocalIdentificationDefinition.Builder>();
631                if (!CollectionUtils.isEmpty(contract.getOlePatronLocalIds())) {
632                    for(OlePatronLocalIdentificationContract patornLocalIdContract : contract.getOlePatronLocalIds()) {
633                        builder.olePatronLocalIds.add(OlePatronLocalIdentificationDefinition.Builder.create(patornLocalIdContract));
634                    }
635                }
636                builder.setVersionNumber(contract.getVersionNumber());
637                /*builder.setObjectId(contract.getObjectId());
638                builder.setActive(contract.isActive());*/
639                builder.setId(contract.getId());
640                return builder;
641            }
642    
643    
644            public OlePatronDefinition build() {
645                return new OlePatronDefinition(this);
646            }
647    
648            @Override
649            public String getOlePatronId() {
650                return olePatronId;
651            }
652    
653            public void setOlePatronId(String olePatronId) {
654                this.olePatronId = olePatronId;
655            }
656    
657            @Override
658            public String getBarcode() {
659                return barcode;
660            }
661    
662            public void setBarcode(String barcode) {
663                this.barcode = barcode;
664            }
665    
666            @Override
667            public String getBorrowerType() {
668                return borrowerType;
669            }
670    
671    
672            public void setBorrowerType(String borrowerType) {
673                this.borrowerType = borrowerType;
674            }
675    
676            @Override
677            public boolean isActiveIndicator() {
678                return activeIndicator;
679            }
680    
681            public void setActiveIndicator(boolean activeIndicator) {
682                this.activeIndicator = activeIndicator;
683            }
684    
685            @Override
686            public boolean isGeneralBlock() {
687                return generalBlock;
688            }
689    
690            public void setGeneralBlock(boolean generalBlock) {
691                this.generalBlock = generalBlock;
692            }
693    
694            @Override
695            public boolean isPagingPrivilege() {
696                return pagingPrivilege;
697            }
698    
699            public void setPagingPrivilege(boolean pagingPrivilege) {
700                this.pagingPrivilege = pagingPrivilege;
701            }
702    
703            @Override
704            public boolean isCourtesyNotice() {
705                return courtesyNotice;
706            }
707    
708            public void setCourtesyNotice(boolean courtesyNotice) {
709                this.courtesyNotice = courtesyNotice;
710            }
711    
712            @Override
713            public boolean isDeliveryPrivilege() {
714                return deliveryPrivilege;
715            }
716    
717            public void setDeliveryPrivilege(boolean deliveryPrivilege) {
718                this.deliveryPrivilege = deliveryPrivilege;
719            }
720    
721            @Override
722            public Date getExpirationDate() {
723                return expirationDate;
724            }
725    
726            public void setExpirationDate(Date expirationDate) {
727                this.expirationDate = expirationDate;
728            }
729    
730            @Override
731            public Date getActivationDate() {
732                return activationDate;
733            }
734    
735            public void setActivationDate(Date activationDate) {
736                this.activationDate = activationDate;
737            }
738    
739            @Override
740            public List<EntityPhone.Builder> getPhones() {
741                return phones;
742            }
743    
744            public void setPhones(List<EntityPhone.Builder> phones) {
745                this.phones = phones;
746            }
747    
748            @Override
749            public List<EntityAddress.Builder> getAddresses() {
750                return addresses;
751            }
752    
753            public void setAddresses(List<EntityAddress.Builder> addresses) {
754                this.addresses = addresses;
755            }
756    
757            public List<OleProxyPatronDefinition.Builder> getOleProxyPatronDocuments() {
758                return oleProxyPatronDocuments;
759            }
760    
761            public void setOleProxyPatronDocuments(List<OleProxyPatronDefinition.Builder> oleProxyPatronDocuments) {
762                this.oleProxyPatronDocuments = oleProxyPatronDocuments;
763            }
764    
765            @Override
766            public EntityName.Builder getName() {
767                return name;
768            }
769    
770            public void setName(EntityName.Builder name) {
771                this.name = name;
772            }
773    
774            @Override
775            public List<EntityEmail.Builder> getEmails() {
776                return emails;
777            }
778    
779            public void setEmails(List<EntityEmail.Builder> emails) {
780                this.emails = emails;
781            }
782    
783    
784            public List<OlePatronNotesDefinition.Builder> getNotes() {
785                return notes;
786            }
787    
788            public void setNotes(List<OlePatronNotesDefinition.Builder> notes) {
789                this.notes = notes;
790            }
791    
792            public List<OlePatronLostBarcodeDefinition.Builder> getLostBarcodes() {
793                return lostBarcodes;
794            }
795    
796            public void setLostBarcodes(List<OlePatronLostBarcodeDefinition.Builder> lostBarcodes) {
797                this.lostBarcodes = lostBarcodes;
798            }
799    
800            public OleBorrowerTypeDefinition.Builder getOleBorrowerType() {
801                return oleBorrowerType;
802            }
803    
804            public void setOleBorrowerType(OleBorrowerTypeDefinition.Builder oleBorrowerType) {
805                this.oleBorrowerType = oleBorrowerType;
806            }
807    
808            public Date getInvalidBarcodeNumEffDate() {
809                return invalidBarcodeNumEffDate;
810            }
811    
812            public void setInvalidBarcodeNumEffDate(Date invalidBarcodeNumEffDate) {
813                this.invalidBarcodeNumEffDate = invalidBarcodeNumEffDate;
814            }
815    
816            public String getGeneralBlockNotes() {
817                return generalBlockNotes;
818            }
819    
820            public void setGeneralBlockNotes(String generalBlockNotes) {
821                this.generalBlockNotes = generalBlockNotes;
822            }
823    
824            @Override
825            public Entity.Builder getEntity() {
826                return entity;
827            }
828    
829            public void setEntity(Entity.Builder entity) {
830                this.entity = entity;
831            }
832    
833            public List<OleEntityAddressDefinition.Builder> getOleEntityAddressBo() {
834                return oleEntityAddressBo;
835            }
836    
837            public void setOleEntityAddressBo(List<OleEntityAddressDefinition.Builder> oleEntityAddressBo) {
838                this.oleEntityAddressBo = oleEntityAddressBo;
839            }
840    
841            public List<OlePatronAffiliationDefinition.Builder> getPatronAffiliations() {
842                return patronAffiliations;
843            }
844    
845            public void setPatronAffiliations(List<OlePatronAffiliationDefinition.Builder> patronAffiliations) {
846                this.patronAffiliations = patronAffiliations;
847            }
848    
849            public List<OlePatronLocalIdentificationDefinition.Builder> getOlePatronLocalIds() {
850                return olePatronLocalIds;
851            }
852    
853            public void setOlePatronLocalIds(List<OlePatronLocalIdentificationDefinition.Builder> olePatronLocalIds) {
854                this.olePatronLocalIds = olePatronLocalIds;
855            }
856    
857            public List<OlePatronDefinition.Builder> getOlePatronDocuments() {
858                return olePatronDocuments;
859            }
860    
861            public void setOlePatronDocuments(List<OlePatronDefinition.Builder> olePatronDocuments) {
862                this.olePatronDocuments = olePatronDocuments;
863            }
864    
865            public String getSource() {
866                return source;
867            }
868    
869            public void setSource(String source) {
870                this.source = source;
871            }
872    
873            public String getStatisticalCategory() {
874                return statisticalCategory;
875            }
876    
877            public void setStatisticalCategory(String statisticalCategory) {
878                this.statisticalCategory = statisticalCategory;
879            }
880    
881            public OleSourceDefinition.Builder getSourceBo() {
882                return sourceBo;
883            }
884    
885            public void setSourceBo(OleSourceDefinition.Builder sourceBo) {
886                this.sourceBo = sourceBo;
887            }
888    
889            public OleStatisticalCategoryDefinition.Builder getStatisticalCategoryBo() {
890                return statisticalCategoryBo;
891            }
892    
893            public void setStatisticalCategoryBo(OleStatisticalCategoryDefinition.Builder statisticalCategoryBo) {
894                this.statisticalCategoryBo = statisticalCategoryBo;
895            }
896    
897            public String getAddressSource() {
898                return addressSource;
899            }
900    
901            public void setAddressSource(String addressSource) {
902                this.addressSource = addressSource;
903            }
904    
905            public List<OleAddressDefinition.Builder> getOleAddresses() {
906                return oleAddresses;
907            }
908    
909            public void setOleAddresses(List<OleAddressDefinition.Builder> oleAddresses) {
910                this.oleAddresses = oleAddresses;
911            }
912    
913            @Override
914            public Long getVersionNumber() {
915                return versionNumber;
916            }
917    
918            public void setVersionNumber(Long versionNumber) {
919                this.versionNumber = versionNumber;
920            }
921    
922            /*@Override
923            public String getObjectId() {
924                return objectId;
925            }*/
926    
927            public void setObjectId(String objectId) {
928                this.objectId = objectId;
929            }
930    
931            @Override
932            public String getId() {
933                return this.olePatronId;
934            }
935    
936            public boolean isActive() {
937                return this.activeIndicator;
938            }
939    
940            public void setActive(boolean active) {
941                this.activeIndicator = active;
942            }
943    
944            public void setId(String id) {
945                if (StringUtils.isWhitespace(id)) {
946                    throw new IllegalArgumentException("id is blank");
947                }
948                this.olePatronId = id;
949            }
950        }
951    
952        static class Constants {
953    
954            final static String ROOT_ELEMENT_NAME = "olePatron";
955            final static String TYPE_NAME = "OlePatronType";
956            final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[] {CoreConstants.CommonElements.FUTURE_ELEMENTS };
957        }
958    
959        static class Elements {
960            final static String PATRON_ID = "olePatronId";
961            //final static String ENTITY_ID = "entityId";
962            final static String BARCODE = "barcode";
963            final static String BORROWER_TYPE = "borrowerType";
964            final static String ACITVE_INICATOR = "activeIndicator";
965            final static String GENERAL_BLOCK = "generalBlock";
966            final static String PAGING_PRIVILEGE = "pagingPrivilege";
967            final static String COURTESY_NOTICE = "courtesyNotice";
968            final static String DELIVERYPRIVILEGE = "deliveryPrivilege";
969            final static String EXPIRATION_DATE ="expirationDate";
970            final static String ACTIVATION_DATE ="activationDate";
971    
972            final static String PHONES = "phones";
973            final static String PHONE = "phone";
974            final static String ADDRESSES = "addresses";
975            final static String ADDRESS = "address";
976            final static String NAME = "name";
977            final static String EMAILS = "emails";
978            final static String EMAIL = "email";
979            final static String NOTES = "notes";
980            final static String NOTE = "note";
981            final static String LOST_BARCODES = "lostBarcodes";
982            final static String LOST_BARCODE = "lostBarcode";
983            final static String OLE_BORROWER_TYPE = "oleBorrowerType";
984            final static String ENTITY = "entity";
985            final static String OLE_ENTITY_ADDRESSES = "oleEntityAddressBo";
986            final static String OLE_ENTITY_ADDRESS = "oleEntityAddress";
987            final static String GENERAL_BLOCK_NOTES = "generalBlockNotes";
988            final static String PATRON_AFFILIATIONS = "patronAffiliations";
989            final static String PATRON_AFFILIATION = "patronAffiliation";
990            final static String OLE_PROXY_PATRON_DOCS = "oleProxyPatronDocuments";
991            final static String OLE_PROXY_PATRON_DOC = "oleProxyPatronDocument";
992            //final static String OLE_PATRON_DOCS = "olePatronDocuments";
993            //final static String OLE_PATRON_DOC = "olePatronDocument";
994            final static String OLE_SOURCE = "source";
995            final static String OLE_STATISTICAL_CAT = "statisticalCategory";
996            final static String OLE_ADDRESSES = "oleAddresses";
997            final static String OLE_ADDRESS = "oleAddress";
998            final static String OLE_PATRON_LOCAL_IDS = "olePatronLocalIds";
999            final static String OLE_PATRON_LOCAL_ID = "olePatronLocalId";
1000    
1001        }
1002        public static class Cache {
1003            public static final String NAME = KimConstants.Namespaces.KIM_NAMESPACE_2_0 + "/" + OlePatronDefinition.Constants.TYPE_NAME;
1004        }
1005    }