Java tutorial
/******************************************************************************* * Copyright (c) 2009 David Harrison. * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Public License v3.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/gpl-3.0.html * * Contributors: * David Harrison - initial API and implementation ******************************************************************************/ package com.sfs.whichdoctor.beans; import java.util.ArrayList; import java.util.Collection; import java.util.TreeMap; import org.apache.commons.lang.StringUtils; /** * The Class WhichDoctorCoreIdentityBean. */ public class WhichDoctorCoreIdentityBean extends WhichDoctorCoreBean { /** The unique serial version UID for the class. */ private static final long serialVersionUID = 3182350105017598921L; /** The region. */ private String region; /** The resident country. */ private String residentCountry; /** The addresses. */ private Collection<AddressBean> addresses; /** The primary address. */ private AddressBean primaryAddress; /** The phone numbers. */ private Collection<PhoneBean> phoneNumbers; /** The primary phone. */ private PhoneBean primaryPhone; /** The email addresses. */ private Collection<EmailBean> emailAddresses; /** The primary email. */ private EmailBean primaryEmail; /** The specialty list. */ private Collection<SpecialtyBean> specialtyList; /** The financial summary. */ private FinancialSummaryBean financialSummary; /** The restricted financial summary. */ private FinancialSummaryBean restrictedFinancialSummary; /** The debits. */ private Collection<DebitBean> debits; /** The reimbursements. */ private Collection<ReimbursementBean> reimbursements; /** The relationships. */ private Collection<RelationshipBean> relationships; /** The isb entities. */ private Collection<IsbEntityBean> isbEntities; /** * Sets the region. * * @param regionVal the new region */ public final void setRegion(final String regionVal) { this.region = regionVal; } /** * Gets the region. * * @return the region */ public final String getRegion() { if (StringUtils.isBlank(this.region)) { this.region = "Unknown?"; } return this.region; } /** * Sets the resident country. * * @param residentCountryVal the new resident country */ public final void setResidentCountry(final String residentCountryVal) { this.residentCountry = residentCountryVal; } /** * Gets the region. * * @return the region */ public final String getResidentCountry() { if (StringUtils.isBlank(this.residentCountry)) { this.residentCountry = "Unknown?"; } return this.residentCountry; } /** * Sets the address. * * @param addressesVal the new address */ public final void setAddress(final Collection<AddressBean> addressesVal) { if (addressesVal != null && addressesVal.size() > 0) { Object[] addressArray = addressesVal.toArray(); this.primaryAddress = (AddressBean) addressArray[0]; } this.addresses = addressesVal; } /** * Gets the address. * * @return the address */ public final Collection<AddressBean> getAddress() { if (this.addresses == null) { this.addresses = new ArrayList<AddressBean>(); } return this.addresses; } /** * Sets the phone. * * @param phoneNumbersVal the new phone */ public final void setPhone(final Collection<PhoneBean> phoneNumbersVal) { if (phoneNumbersVal != null && phoneNumbersVal.size() > 0) { Object[] phoneArray = phoneNumbersVal.toArray(); this.primaryPhone = (PhoneBean) phoneArray[0]; } this.phoneNumbers = phoneNumbersVal; } /** * Gets the phone. * * @return the phone */ public final Collection<PhoneBean> getPhone() { if (this.phoneNumbers == null) { this.phoneNumbers = new ArrayList<PhoneBean>(); } return this.phoneNumbers; } /** * Sets the email. * * @param emailAddressesVal the new email */ public final void setEmail(final Collection<EmailBean> emailAddressesVal) { if (emailAddressesVal != null && emailAddressesVal.size() > 0) { Object[] emailArray = emailAddressesVal.toArray(); this.primaryEmail = (EmailBean) emailArray[0]; } this.emailAddresses = emailAddressesVal; } /** * Gets the email. * * @return the email */ public final Collection<EmailBean> getEmail() { if (this.emailAddresses == null) { this.emailAddresses = new ArrayList<EmailBean>(); } return this.emailAddresses; } /** * Sets the specialty list. * * @param specialtyListVal the new specialty list */ public final void setSpecialtyList(final Collection<SpecialtyBean> specialtyListVal) { this.specialtyList = specialtyListVal; } /** * Gets the specialty list. * * @return the specialty list */ public final Collection<SpecialtyBean> getSpecialtyList() { if (this.specialtyList == null) { this.specialtyList = new ArrayList<SpecialtyBean>(); } return this.specialtyList; } /** * Gets the first email address. * * @return the first email address */ public final EmailBean getFirstEmailAddress() { return this.primaryEmail; } /** * Gets the first phone no. * * @return the first phone no */ public final PhoneBean getFirstPhoneNo() { return this.primaryPhone; } /** * Gets the first address. * * @return the first address */ public final AddressBean getFirstAddress() { return this.primaryAddress; } /** * Sets the financial summary. * * @param financialSummaryRef the new financial summary */ public final void setFinancialSummary(final FinancialSummaryBean financialSummaryRef) { this.financialSummary = financialSummaryRef; } /** * Gets the financial summary. * * @return the financial summary */ public final FinancialSummaryBean getFinancialSummary() { if (this.financialSummary == null) { this.financialSummary = new FinancialSummaryBean(); } return this.financialSummary; } /** * Sets the restricted financial summary. * * @param financialSummaryRef the new restricted financial summary */ public final void setRestrictedFinancialSummary(final FinancialSummaryBean financialSummaryRef) { this.restrictedFinancialSummary = financialSummaryRef; } /** * Gets the restricted financial summary. * * @return the restricted financial summary */ public final FinancialSummaryBean getRestrictedFinancialSummary() { if (this.restrictedFinancialSummary == null) { this.restrictedFinancialSummary = new FinancialSummaryBean(); } return this.restrictedFinancialSummary; } /** * Sets the debits. * * @param debitsVal the new debits */ public final void setDebits(final Collection<DebitBean> debitsVal) { this.debits = debitsVal; } /** * Gets the debits. * * @return the debits */ public final Collection<DebitBean> getDebits() { if (this.debits == null) { this.debits = new ArrayList<DebitBean>(); } return this.debits; } /** * Sets the reimbursements. * * @param reimbursementsVal the new reimbursements */ public final void setReimbursements(final Collection<ReimbursementBean> reimbursementsVal) { this.reimbursements = reimbursementsVal; } /** * Gets the reimbursements. * * @return the reimbursements */ public final Collection<ReimbursementBean> getReimbursements() { if (this.reimbursements == null) { this.reimbursements = new ArrayList<ReimbursementBean>(); } return this.reimbursements; } /** * Sets the relationships. * * @param relationshipsVal the new relationships */ public final void setRelationships(final Collection<RelationshipBean> relationshipsVal) { this.relationships = relationshipsVal; } /** * Gets the relationships. * * @return the relationships */ public final Collection<RelationshipBean> getRelationships() { if (this.relationships == null) { this.relationships = new ArrayList<RelationshipBean>(); } return this.relationships; } /** * Gets the grouped relationships. * * @return the grouped relationships */ public final TreeMap<String, Collection<RelationshipBean>> getGroupedRelationships() { TreeMap<String, Collection<RelationshipBean>> groupedRelationships = new TreeMap<String, Collection<RelationshipBean>>(); if (this.getRelationships() != null) { for (RelationshipBean relationship : this.getRelationships()) { String key = "Unnamed"; Collection<RelationshipBean> rels = new ArrayList<RelationshipBean>(); if (relationship.getRelatedPerson() != null) { PersonBean person = relationship.getRelatedPerson(); key = person.getLastName() + " " + person.getFirstName() + " " + person.getPersonIdentifier(); } if (groupedRelationships.containsKey(key)) { rels = groupedRelationships.get(key); } rels.add(relationship); groupedRelationships.put(key, rels); } } return groupedRelationships; } /** * Sets the ISB entities for this identity. * * @param isbEntitiesVal the new ISB entity array */ public final void setIsbEntities(final Collection<IsbEntityBean> isbEntitiesVal) { this.isbEntities = isbEntitiesVal; } /** * Gets the ISB entity collection. * * @return the ISB entity collection */ public final Collection<IsbEntityBean> getIsbEntities() { if (this.isbEntities == null) { this.isbEntities = new ArrayList<IsbEntityBean>(); } return this.isbEntities; } /** * Gets the isb entity names. * * @return the isb entity names */ public final String getIsbEntityNames() { final StringBuffer isbNames = new StringBuffer(); if (this.isbEntities.size() > 0) { for (IsbEntityBean isbEntity : this.isbEntities) { if (isbNames.length() > 0) { isbNames.append(", "); } isbNames.append(isbEntity.getTarget()); } } return isbNames.toString(); } }