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