Coverage Report - org.kuali.rice.kim.api.identity.entity.Entity
 
Classes in this File Line Coverage Branch Coverage Complexity
Entity
0%
0/106
0%
0/62
2.406
Entity$1
N/A
N/A
2.406
Entity$Builder
0%
0/144
0%
0/86
2.406
Entity$Cache
0%
0/1
N/A
2.406
Entity$Constants
0%
0/2
N/A
2.406
Entity$Elements
0%
0/1
N/A
2.406
 
 1  
 /**
 2  
  * Copyright 2005-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.kim.api.identity.entity;
 17  
 
 18  
 import org.apache.commons.collections.CollectionUtils;
 19  
 import org.apache.commons.lang.StringUtils;
 20  
 import org.kuali.rice.core.api.CoreConstants;
 21  
 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
 22  
 import org.kuali.rice.core.api.mo.ModelBuilder;
 23  
 import org.kuali.rice.kim.api.KimConstants;
 24  
 import org.kuali.rice.kim.api.identity.affiliation.EntityAffiliation;
 25  
 import org.kuali.rice.kim.api.identity.affiliation.EntityAffiliationContract;
 26  
 import org.kuali.rice.kim.api.identity.citizenship.EntityCitizenship;
 27  
 import org.kuali.rice.kim.api.identity.citizenship.EntityCitizenshipContract;
 28  
 import org.kuali.rice.kim.api.identity.employment.EntityEmployment;
 29  
 import org.kuali.rice.kim.api.identity.employment.EntityEmploymentContract;
 30  
 import org.kuali.rice.kim.api.identity.external.EntityExternalIdentifier;
 31  
 import org.kuali.rice.kim.api.identity.external.EntityExternalIdentifierContract;
 32  
 import org.kuali.rice.kim.api.identity.name.EntityName;
 33  
 import org.kuali.rice.kim.api.identity.name.EntityNameContract;
 34  
 import org.kuali.rice.kim.api.identity.personal.EntityBioDemographics;
 35  
 import org.kuali.rice.kim.api.identity.personal.EntityEthnicity;
 36  
 import org.kuali.rice.kim.api.identity.personal.EntityEthnicityContract;
 37  
 import org.kuali.rice.kim.api.identity.principal.Principal;
 38  
 import org.kuali.rice.kim.api.identity.principal.PrincipalContract;
 39  
 import org.kuali.rice.kim.api.identity.privacy.EntityPrivacyPreferences;
 40  
 import org.kuali.rice.kim.api.identity.residency.EntityResidency;
 41  
 import org.kuali.rice.kim.api.identity.residency.EntityResidencyContract;
 42  
 import org.kuali.rice.kim.api.identity.type.EntityTypeContactInfo;
 43  
 import org.kuali.rice.kim.api.identity.type.EntityTypeContactInfoContract;
 44  
 import org.kuali.rice.kim.api.identity.visa.EntityVisa;
 45  
 import org.kuali.rice.kim.api.identity.visa.EntityVisaContract;
 46  
 import org.w3c.dom.Element;
 47  
 
 48  
 import javax.xml.bind.annotation.XmlAccessType;
 49  
 import javax.xml.bind.annotation.XmlAccessorType;
 50  
 import javax.xml.bind.annotation.XmlAnyElement;
 51  
 import javax.xml.bind.annotation.XmlElement;
 52  
 import javax.xml.bind.annotation.XmlElementWrapper;
 53  
 import javax.xml.bind.annotation.XmlRootElement;
 54  
 import javax.xml.bind.annotation.XmlType;
 55  
 import java.io.Serializable;
 56  
 import java.util.ArrayList;
 57  
 import java.util.Collection;
 58  
 import java.util.List;
 59  
 
 60  0
 @XmlRootElement(name = Entity.Constants.ROOT_ELEMENT_NAME)
 61  
 @XmlAccessorType(XmlAccessType.NONE)
 62  
 @XmlType(name = Entity.Constants.TYPE_NAME, propOrder = {
 63  
     Entity.Elements.ID,
 64  
     Entity.Elements.PRINCIPALS,
 65  
     Entity.Elements.ENTITY_TYPE_CONTACT_INFOS,
 66  
     Entity.Elements.EXTERNAL_IDENTIFIERS,
 67  
     Entity.Elements.AFFILIATIONS,
 68  
     Entity.Elements.NAMES,
 69  
     Entity.Elements.EMPLOYMENT_INFORMATION,
 70  
     Entity.Elements.PRIVACY_PREFERENCES,
 71  
     Entity.Elements.BIO_DEMOGRAPHICS,
 72  
     Entity.Elements.CITIZENSHIPS,
 73  
     Entity.Elements.PRIMARY_EMPLOYMENT,
 74  
     Entity.Elements.DEFAULT_AFFILIATION,
 75  
     Entity.Elements.DEFAULT_NAME,
 76  
     Entity.Elements.ETHNICITIES,
 77  
     Entity.Elements.RESIDENCIES,
 78  
     Entity.Elements.VISAS,
 79  
     CoreConstants.CommonElements.VERSION_NUMBER,
 80  
     CoreConstants.CommonElements.OBJECT_ID,
 81  
     Entity.Elements.ACTIVE,
 82  
     CoreConstants.CommonElements.FUTURE_ELEMENTS
 83  
 })
 84  0
 public final class Entity extends AbstractDataTransferObject
 85  
     implements EntityContract
 86  
 {
 87  
     @XmlElement(name = Elements.ID, required = false)
 88  
     private final String id;
 89  
     @XmlElementWrapper(name = Elements.PRINCIPALS, required = false)
 90  
     @XmlElement(name = Elements.PRINCIPAL, required = false)
 91  
     private final List<Principal> principals;
 92  
     @XmlElementWrapper(name = Elements.ENTITY_TYPE_CONTACT_INFOS, required = false)
 93  
     @XmlElement(name = Elements.ENTITY_TYPE_CONTACT_INFO, required = false)
 94  
     private final List<EntityTypeContactInfo> entityTypeContactInfos;
 95  
     @XmlElementWrapper(name = Elements.EXTERNAL_IDENTIFIERS, required = false)
 96  
     @XmlElement(name = Elements.EXTERNAL_IDENTIFIER, required = false)
 97  
     private final List<EntityExternalIdentifier> externalIdentifiers;
 98  
     @XmlElementWrapper(name = Elements.AFFILIATIONS, required = false)
 99  
     @XmlElement(name = Elements.AFFILIATION, required = false)
 100  
     private final List<EntityAffiliation> affiliations;
 101  
     @XmlElementWrapper(name = Elements.NAMES, required = false)
 102  
     @XmlElement(name = Elements.NAME, required = false)
 103  
     private final List<EntityName> names;
 104  
     @XmlElementWrapper(name = Elements.EMPLOYMENT_INFORMATION, required = false)
 105  
     @XmlElement(name = Elements.EMPLOYMENT, required = false)
 106  
     private final List<EntityEmployment> employmentInformation;
 107  
     @XmlElement(name = Elements.PRIVACY_PREFERENCES, required = false)
 108  
     private final EntityPrivacyPreferences privacyPreferences;
 109  
     @XmlElement(name = Elements.BIO_DEMOGRAPHICS, required = false)
 110  
     private final EntityBioDemographics bioDemographics;
 111  
     @XmlElementWrapper(name = Elements.CITIZENSHIPS, required = false)
 112  
     @XmlElement(name = Elements.CITIZENSHIP, required = false)
 113  
     private final List<EntityCitizenship> citizenships;
 114  
     @XmlElement(name = Elements.PRIMARY_EMPLOYMENT, required = false)
 115  
     private final EntityEmployment primaryEmployment;
 116  
     @XmlElement(name = Elements.DEFAULT_AFFILIATION, required = false)
 117  
     private final EntityAffiliation defaultAffiliation;
 118  
     @XmlElement(name = Elements.DEFAULT_NAME, required = false)
 119  
     private final EntityName defaultName;
 120  
     @XmlElementWrapper(name = Elements.ETHNICITIES, required = false)
 121  
     @XmlElement(name = Elements.ETHNICITY, required = false)
 122  
     private final List<EntityEthnicity> ethnicities;
 123  
     @XmlElementWrapper(name = Elements.RESIDENCIES, required = false)
 124  
     @XmlElement(name = Elements.RESIDENCY, required = false)
 125  
     private final List<EntityResidency> residencies;
 126  
     @XmlElementWrapper(name = Elements.VISAS, required = false)
 127  
     @XmlElement(name = Elements.VISA, required = false)
 128  
     private final List<EntityVisa> visas;
 129  
     @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
 130  
     private final Long versionNumber;
 131  
     @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
 132  
     private final String objectId;
 133  
     @XmlElement(name = Elements.ACTIVE, required = false)
 134  
     private final boolean active;
 135  
 
 136  0
     @SuppressWarnings("unused")
 137  
     @XmlAnyElement
 138  
     private final Collection<Element> _futureElements = null;
 139  
 
 140  
     /**
 141  
      * Private constructor used only by JAXB.
 142  
      * 
 143  
      */
 144  0
     private Entity() {
 145  0
         this.principals = null;
 146  0
         this.entityTypeContactInfos = null;
 147  0
         this.externalIdentifiers = null;
 148  0
         this.affiliations = null;
 149  0
         this.names = null;
 150  0
         this.employmentInformation = null;
 151  0
         this.privacyPreferences = null;
 152  0
         this.bioDemographics = null;
 153  0
         this.citizenships = null;
 154  0
         this.primaryEmployment = null;
 155  0
         this.defaultAffiliation = null;
 156  0
         this.defaultName = null;
 157  0
         this.ethnicities = null;
 158  0
         this.residencies = null;
 159  0
         this.visas = null;
 160  0
         this.versionNumber = null;
 161  0
         this.objectId = null;
 162  0
         this.active = false;
 163  0
         this.id = null;
 164  0
     }
 165  
 
 166  0
     private Entity(Builder builder) {
 167  0
         this.principals = new ArrayList<Principal>();
 168  0
         if (CollectionUtils.isNotEmpty(builder.getPrincipals())) {
 169  0
             for (Principal.Builder principal : builder.getPrincipals()) {
 170  0
                 this.principals.add(principal.build());
 171  
             }
 172  
         }
 173  0
         this.entityTypeContactInfos = new ArrayList<EntityTypeContactInfo>();
 174  0
         if (CollectionUtils.isNotEmpty(builder.getEntityTypeContactInfos())) {
 175  0
             for (EntityTypeContactInfo.Builder entityTypeData : builder.getEntityTypeContactInfos()) {
 176  0
                 this.entityTypeContactInfos.add(entityTypeData.build());
 177  
             }
 178  
         }
 179  0
         this.externalIdentifiers = new ArrayList<EntityExternalIdentifier>();
 180  0
         if (CollectionUtils.isNotEmpty(builder.getExternalIdentifiers())) {
 181  0
             for (EntityExternalIdentifier.Builder externalId : builder.getExternalIdentifiers()) {
 182  0
                 this.externalIdentifiers.add(externalId.build());
 183  
             }
 184  
         }
 185  0
         this.affiliations = new ArrayList<EntityAffiliation>();
 186  0
         if (CollectionUtils.isNotEmpty(builder.getAffiliations())) {
 187  0
             for (EntityAffiliation.Builder affiliation : builder.getAffiliations()) {
 188  0
                 this.affiliations.add(affiliation.build());
 189  
             }
 190  
         }
 191  0
         this.names = new ArrayList<EntityName>();
 192  0
         if (CollectionUtils.isNotEmpty(builder.getNames())) {
 193  0
             for (EntityName.Builder name : builder.getNames()) {
 194  0
                 this.names.add(name.build());
 195  
             }
 196  
         }
 197  0
         this.employmentInformation = new ArrayList<EntityEmployment>();
 198  0
         if (CollectionUtils.isNotEmpty(builder.getEmploymentInformation())) {
 199  0
             for (EntityEmployment.Builder employment : builder.getEmploymentInformation()) {
 200  0
                 this.employmentInformation.add(employment.build());
 201  
             }
 202  
         }
 203  0
         this.privacyPreferences = builder.getPrivacyPreferences() == null ? null : builder.getPrivacyPreferences().build();
 204  0
         this.bioDemographics = builder.getBioDemographics() == null ? null : builder.getBioDemographics().build();
 205  0
         this.citizenships = new ArrayList<EntityCitizenship>();
 206  0
         if (CollectionUtils.isNotEmpty(builder.getCitizenships())) {
 207  0
             for (EntityCitizenship.Builder citizenship : builder.getCitizenships()) {
 208  0
                 this.citizenships.add(citizenship.build());
 209  
             }
 210  
         }
 211  0
         this.primaryEmployment = builder.getPrimaryEmployment() == null ? null : builder.getPrimaryEmployment().build();
 212  0
         this.defaultAffiliation = builder.getDefaultAffiliation() == null ? null : builder.getDefaultAffiliation().build();
 213  0
         this.defaultName = builder.getDefaultName() == null ? null : builder.getDefaultName().build();
 214  0
         this.ethnicities = new ArrayList<EntityEthnicity>();
 215  0
         if (CollectionUtils.isNotEmpty(builder.getEthnicities())) {
 216  0
             for (EntityEthnicity.Builder ethnicity : builder.getEthnicities()) {
 217  0
                 this.ethnicities.add(ethnicity.build());
 218  
             }
 219  
         }
 220  0
         this.residencies = new ArrayList<EntityResidency>();
 221  0
         if (CollectionUtils.isNotEmpty(builder.getResidencies())) {
 222  0
             for (EntityResidency.Builder residency : builder.getResidencies()) {
 223  0
                 this.residencies.add(residency.build());
 224  
             }
 225  
         }
 226  0
         this.visas = new ArrayList<EntityVisa>();
 227  0
         if (CollectionUtils.isNotEmpty(builder.getVisas())) {
 228  0
             for (EntityVisa.Builder visa : builder.getVisas()) {
 229  0
                 this.visas.add(visa.build());
 230  
             }
 231  
         }
 232  0
         this.versionNumber = builder.getVersionNumber();
 233  0
         this.objectId = builder.getObjectId();
 234  0
         this.active = builder.isActive();
 235  0
         this.id = builder.getId();
 236  0
     }
 237  
 
 238  
     @Override
 239  
     public List<Principal> getPrincipals() {
 240  0
         return this.principals;
 241  
     }
 242  
 
 243  
     @Override
 244  
     public List<EntityTypeContactInfo> getEntityTypeContactInfos() {
 245  0
         return this.entityTypeContactInfos;
 246  
     }
 247  
 
 248  
     @Override
 249  
     public List<EntityExternalIdentifier> getExternalIdentifiers() {
 250  0
         return this.externalIdentifiers;
 251  
     }
 252  
 
 253  
     @Override
 254  
     public List<EntityAffiliation> getAffiliations() {
 255  0
         return this.affiliations;
 256  
     }
 257  
 
 258  
     @Override
 259  
     public List<EntityName> getNames() {
 260  0
         return this.names;
 261  
     }
 262  
 
 263  
     @Override
 264  
     public List<EntityEmployment> getEmploymentInformation() {
 265  0
         return this.employmentInformation;
 266  
     }
 267  
 
 268  
     @Override
 269  
     public EntityPrivacyPreferences getPrivacyPreferences() {
 270  0
         return this.privacyPreferences;
 271  
     }
 272  
 
 273  
     @Override
 274  
     public EntityBioDemographics getBioDemographics() {
 275  0
         return this.bioDemographics;
 276  
     }
 277  
 
 278  
     @Override
 279  
     public List<EntityCitizenship> getCitizenships() {
 280  0
         return this.citizenships;
 281  
     }
 282  
 
 283  
     @Override
 284  
     public EntityEmployment getPrimaryEmployment() {
 285  0
         return this.primaryEmployment;
 286  
     }
 287  
 
 288  
     @Override
 289  
     public EntityAffiliation getDefaultAffiliation() {
 290  0
         return this.defaultAffiliation;
 291  
     }
 292  
 
 293  
     @Override
 294  
     public EntityExternalIdentifier getEntityExternalIdentifier(String externalIdentifierTypeCode) {
 295  0
         if (externalIdentifiers == null) {
 296  0
             return null;
 297  
         }
 298  0
         for (EntityExternalIdentifier externalId : externalIdentifiers) {
 299  0
             if (externalId.getExternalIdentifierTypeCode().equals(externalIdentifierTypeCode)) {
 300  0
                 return externalId;
 301  
             }
 302  
         }
 303  0
         return null;
 304  
     }
 305  
 
 306  
     @Override
 307  
     public EntityNameContract getDefaultName() {
 308  0
         return this.defaultName;
 309  
     }
 310  
 
 311  
     @Override
 312  
     public List<EntityEthnicity> getEthnicities() {
 313  0
         return this.ethnicities;
 314  
     }
 315  
 
 316  
     @Override
 317  
     public List<EntityResidency> getResidencies() {
 318  0
         return this.residencies;
 319  
     }
 320  
 
 321  
     @Override
 322  
     public List<EntityVisa> getVisas() {
 323  0
         return this.visas;
 324  
     }
 325  
 
 326  
     @Override
 327  
     public Long getVersionNumber() {
 328  0
         return this.versionNumber;
 329  
     }
 330  
 
 331  
     @Override
 332  
     public String getObjectId() {
 333  0
         return this.objectId;
 334  
     }
 335  
 
 336  
     @Override
 337  
     public boolean isActive() {
 338  0
         return this.active;
 339  
     }
 340  
 
 341  
     @Override
 342  
     public String getId() {
 343  0
         return this.id;
 344  
     }
 345  
 
 346  
     public EntityTypeContactInfo getEntityTypeContactInfoByTypeCode(String entityTypeCode) {
 347  0
         if (entityTypeContactInfos == null) {
 348  0
             return null;
 349  
         }
 350  0
         for (EntityTypeContactInfo entType : entityTypeContactInfos) {
 351  0
             if (entType.getEntityTypeCode().equals(entityTypeCode)) {
 352  0
                 return entType;
 353  
             }
 354  
         }
 355  0
         return null;
 356  
     }
 357  
 
 358  
     /**
 359  
      * A builder which can be used to construct {@link Entity} instances.  Enforces the constraints of the {@link EntityContract}.
 360  
      * 
 361  
      */
 362  0
     public final static class Builder
 363  
         implements Serializable, ModelBuilder, EntityContract
 364  
     {
 365  
 
 366  
         private List<Principal.Builder> principals;
 367  
         private List<EntityTypeContactInfo.Builder> entityTypeContactInfos;
 368  
         private List<EntityExternalIdentifier.Builder> externalIdentifiers;
 369  
         private List<EntityAffiliation.Builder> affiliations;
 370  
         private List<EntityName.Builder> names;
 371  
         private List<EntityEmployment.Builder> employmentInformation;
 372  
         private EntityPrivacyPreferences.Builder privacyPreferences;
 373  
         private EntityBioDemographics.Builder bioDemographics;
 374  
         private List<EntityCitizenship.Builder> citizenships;
 375  
         private List<EntityEthnicity.Builder> ethnicities;
 376  
         private List<EntityResidency.Builder> residencies;
 377  
         private List<EntityVisa.Builder> visas;
 378  
         private Long versionNumber;
 379  
         private String objectId;
 380  
         private boolean active;
 381  
         private String id;
 382  
 
 383  0
         private Builder() { }
 384  
 
 385  
         public static Builder create() {
 386  0
             return new Builder();
 387  
         }
 388  
 
 389  
         public static Builder create(EntityContract contract) {
 390  0
             if (contract == null) {
 391  0
                 throw new IllegalArgumentException("contract was null");
 392  
             }
 393  0
             Builder builder = create();
 394  0
             if (contract.getPrincipals() != null) {
 395  0
                 List<Principal.Builder> tempPrincipals = new ArrayList<Principal.Builder>();
 396  0
                 for (PrincipalContract principal : contract.getPrincipals()) {
 397  0
                     tempPrincipals.add(Principal.Builder.create(principal));
 398  
                 }
 399  0
                 builder.setPrincipals(tempPrincipals);
 400  
             }
 401  0
             if (contract.getEntityTypeContactInfos() != null) {
 402  0
                 List<EntityTypeContactInfo.Builder> tempTypeData = new ArrayList<EntityTypeContactInfo.Builder>();
 403  0
                 for (EntityTypeContactInfoContract typeData : contract.getEntityTypeContactInfos()) {
 404  0
                     tempTypeData.add(EntityTypeContactInfo.Builder.create(typeData));
 405  
                 }
 406  0
                 builder.setEntityTypes(tempTypeData);
 407  
             }
 408  0
             if (contract.getExternalIdentifiers() != null) {
 409  0
                 List<EntityExternalIdentifier.Builder> externalIds = new ArrayList<EntityExternalIdentifier.Builder>();
 410  0
                 for (EntityExternalIdentifierContract externalId : contract.getExternalIdentifiers()) {
 411  0
                     externalIds.add(EntityExternalIdentifier.Builder.create(externalId));
 412  
                 }
 413  0
                 builder.setExternalIdentifiers(externalIds);
 414  
             }
 415  0
             if (contract.getAffiliations() != null) {
 416  0
                 List<EntityAffiliation.Builder> affils = new ArrayList<EntityAffiliation.Builder>();
 417  0
                 for (EntityAffiliationContract affil : contract.getAffiliations()) {
 418  0
                     affils.add(EntityAffiliation.Builder.create(affil));
 419  
                 }
 420  0
                 builder.setAffiliations(affils);
 421  
             }
 422  0
             if (contract.getNames() != null) {
 423  0
                 List<EntityName.Builder> nms = new ArrayList<EntityName.Builder>();
 424  0
                 for (EntityNameContract nm : contract.getNames()) {
 425  0
                     nms.add(EntityName.Builder.create(nm));
 426  
                 }
 427  0
                 builder.setNames(nms);
 428  
             }
 429  0
             if (contract.getEmploymentInformation() != null) {
 430  0
                 List<EntityEmployment.Builder> emps = new ArrayList<EntityEmployment.Builder>();
 431  0
                 for (EntityEmploymentContract emp : contract.getEmploymentInformation()) {
 432  0
                     emps.add(EntityEmployment.Builder.create(emp));
 433  
                 }
 434  0
                 builder.setEmploymentInformation(emps);
 435  
             }
 436  0
             builder.setPrivacyPreferences(contract.getPrivacyPreferences() == null ? null : EntityPrivacyPreferences.Builder.create(contract.getPrivacyPreferences()));
 437  0
             builder.setBioDemographics(contract.getBioDemographics() == null ? null : EntityBioDemographics.Builder.create(contract.getBioDemographics()));
 438  0
             if (contract.getCitizenships() != null) {
 439  0
                 List<EntityCitizenship.Builder> cits = new ArrayList<EntityCitizenship.Builder>();
 440  0
                 for (EntityCitizenshipContract cit : contract.getCitizenships()) {
 441  0
                     cits.add(EntityCitizenship.Builder.create(cit));
 442  
                 }
 443  0
                 builder.setCitizenships(cits);
 444  
             }
 445  0
             if (contract.getEthnicities() != null) {
 446  0
                 List<EntityEthnicity.Builder> ethnctys = new ArrayList<EntityEthnicity.Builder>();
 447  0
                 for (EntityEthnicityContract ethncty : contract.getEthnicities()) {
 448  0
                     ethnctys.add(EntityEthnicity.Builder.create(ethncty));
 449  
                 }
 450  0
                 builder.setEthnicities(ethnctys);
 451  
             }
 452  0
             if (contract.getResidencies() != null) {
 453  0
                 List<EntityResidency.Builder> residencyBuilders = new ArrayList<EntityResidency.Builder>();
 454  0
                 for (EntityResidencyContract residency : contract.getResidencies()) {
 455  0
                     residencyBuilders.add(EntityResidency.Builder.create(residency));
 456  
                 }
 457  0
                 builder.setResidencies(residencyBuilders);
 458  
             }
 459  0
             if (contract.getVisas() != null) {
 460  0
                 List<EntityVisa.Builder> visaBuilders = new ArrayList<EntityVisa.Builder>();
 461  0
                 for (EntityVisaContract visa : contract.getVisas()) {
 462  0
                     visaBuilders.add(EntityVisa.Builder.create(visa));
 463  
                 }
 464  0
                 builder.setVisas(visaBuilders);
 465  
             }
 466  0
             builder.setVersionNumber(contract.getVersionNumber());
 467  0
             builder.setObjectId(contract.getObjectId());
 468  0
             builder.setActive(contract.isActive());
 469  0
             builder.setId(contract.getId());
 470  0
             return builder;
 471  
         }
 472  
 
 473  
         public Entity build() {
 474  0
             return new Entity(this);
 475  
         }
 476  
 
 477  
         @Override
 478  
         public List<Principal.Builder> getPrincipals() {
 479  0
             return this.principals;
 480  
         }
 481  
 
 482  
         @Override
 483  
         public List<EntityTypeContactInfo.Builder> getEntityTypeContactInfos() {
 484  0
             return this.entityTypeContactInfos;
 485  
         }
 486  
 
 487  
         @Override
 488  
         public List<EntityExternalIdentifier.Builder> getExternalIdentifiers() {
 489  0
             return this.externalIdentifiers;
 490  
         }
 491  
 
 492  
         @Override
 493  
         public List<EntityAffiliation.Builder> getAffiliations() {
 494  0
             return this.affiliations;
 495  
         }
 496  
 
 497  
         @Override
 498  
         public List<EntityName.Builder> getNames() {
 499  0
             return this.names;
 500  
         }
 501  
 
 502  
         @Override
 503  
         public List<EntityEmployment.Builder> getEmploymentInformation() {
 504  0
             return this.employmentInformation;
 505  
         }
 506  
 
 507  
         @Override
 508  
         public EntityPrivacyPreferences.Builder getPrivacyPreferences() {
 509  0
             return this.privacyPreferences;
 510  
         }
 511  
 
 512  
         @Override
 513  
         public EntityBioDemographics.Builder getBioDemographics() {
 514  0
             return this.bioDemographics;
 515  
         }
 516  
 
 517  
         @Override
 518  
         public List<EntityCitizenship.Builder> getCitizenships() {
 519  0
             return this.citizenships;
 520  
         }
 521  
 
 522  
         @Override
 523  
         public EntityTypeContactInfo.Builder getEntityTypeContactInfoByTypeCode(String entityTypeCode) {
 524  0
             if (CollectionUtils.isEmpty(this.entityTypeContactInfos)) {
 525  0
                 return null;
 526  
             }
 527  0
             for (EntityTypeContactInfo.Builder builder : this.entityTypeContactInfos) {
 528  0
                 if (builder.getEntityTypeCode().equals(entityTypeCode) && builder.isActive()) {
 529  0
                     return builder;
 530  
                 }
 531  
             }
 532  0
             return null;
 533  
         }
 534  
 
 535  
         @Override
 536  
         public EntityEmployment.Builder getPrimaryEmployment() {
 537  0
             if (CollectionUtils.isEmpty(this.employmentInformation)) {
 538  0
                 return null;
 539  
             }
 540  0
             for (EntityEmployment.Builder builder : this.employmentInformation) {
 541  0
                 if (builder.isPrimary()
 542  
                         && builder.isActive()) {
 543  0
                     return builder;
 544  
                 }
 545  
             }
 546  0
             return null;
 547  
         }
 548  
 
 549  
         @Override
 550  
         public EntityAffiliation.Builder getDefaultAffiliation() {
 551  0
             if (CollectionUtils.isEmpty(this.affiliations)) {
 552  0
                 return null;
 553  
             }
 554  0
             for (EntityAffiliation.Builder builder : this.affiliations) {
 555  0
                 if (builder.isDefaultValue()
 556  
                         && builder.isActive()) {
 557  0
                     return builder;
 558  
                 }
 559  
             }
 560  0
             return null;
 561  
         }
 562  
 
 563  
         @Override
 564  
         public EntityExternalIdentifier.Builder getEntityExternalIdentifier(String externalIdentifierTypeCode) {
 565  0
             if (CollectionUtils.isEmpty(this.externalIdentifiers)) {
 566  0
                 return null;
 567  
             }
 568  0
             for (EntityExternalIdentifier.Builder builder : this.externalIdentifiers) {
 569  0
                 if (builder.getExternalIdentifierTypeCode().equals(externalIdentifierTypeCode)) {
 570  0
                     return builder;
 571  
                 }
 572  
             }
 573  0
             return null;
 574  
         }
 575  
 
 576  
         @Override
 577  
         public EntityName.Builder getDefaultName() {
 578  0
             if (CollectionUtils.isEmpty(this.names)) {
 579  0
                 return null;
 580  
             }
 581  0
             for (EntityName.Builder builder : this.names) {
 582  0
                 if (builder.isDefaultValue()
 583  
                         && builder.isActive()) {
 584  0
                     return builder;
 585  
                 }
 586  
             }
 587  0
             return null;
 588  
         }
 589  
 
 590  
         @Override
 591  
         public List<EntityEthnicity.Builder> getEthnicities() {
 592  0
             return this.ethnicities;
 593  
         }
 594  
 
 595  
         @Override
 596  
         public List<EntityResidency.Builder> getResidencies() {
 597  0
             return this.residencies;
 598  
         }
 599  
 
 600  
         @Override
 601  
         public List<EntityVisa.Builder> getVisas() {
 602  0
             return this.visas;
 603  
         }
 604  
 
 605  
         @Override
 606  
         public Long getVersionNumber() {
 607  0
             return this.versionNumber;
 608  
         }
 609  
 
 610  
         @Override
 611  
         public String getObjectId() {
 612  0
             return this.objectId;
 613  
         }
 614  
 
 615  
         @Override
 616  
         public boolean isActive() {
 617  0
             return this.active;
 618  
         }
 619  
 
 620  
         @Override
 621  
         public String getId() {
 622  0
             return this.id;
 623  
         }
 624  
 
 625  
         public void setPrincipals(List<Principal.Builder> principals) {
 626  0
             this.principals = principals;
 627  0
         }
 628  
 
 629  
         public void setEntityTypes(List<EntityTypeContactInfo.Builder> entityTypeContactInfos) {
 630  0
             this.entityTypeContactInfos = entityTypeContactInfos;
 631  0
         }
 632  
 
 633  
         public void setExternalIdentifiers(List<EntityExternalIdentifier.Builder> externalIdentifiers) {
 634  0
             this.externalIdentifiers = externalIdentifiers;
 635  0
         }
 636  
 
 637  
         public void setAffiliations(List<EntityAffiliation.Builder> affiliations) {
 638  0
             this.affiliations = affiliations;
 639  0
         }
 640  
 
 641  
         public void setNames(List<EntityName.Builder> names) {
 642  0
             this.names = names;
 643  0
         }
 644  
 
 645  
         public void setEmploymentInformation(List<EntityEmployment.Builder> employmentInformation) {
 646  0
             this.employmentInformation = employmentInformation;
 647  0
         }
 648  
 
 649  
         public void setPrivacyPreferences(EntityPrivacyPreferences.Builder privacyPreferences) {
 650  0
             this.privacyPreferences = privacyPreferences;
 651  0
         }
 652  
 
 653  
         public void setBioDemographics(EntityBioDemographics.Builder bioDemographics) {
 654  0
             this.bioDemographics = bioDemographics;
 655  0
         }
 656  
 
 657  
         public void setCitizenships(List<EntityCitizenship.Builder> citizenships) {
 658  0
             this.citizenships = citizenships;
 659  0
         }
 660  
 
 661  
         public void setEthnicities(List<EntityEthnicity.Builder> ethnicities) {
 662  0
             this.ethnicities = ethnicities;
 663  0
         }
 664  
 
 665  
         public void setResidencies(List<EntityResidency.Builder> residencies) {
 666  0
             this.residencies = residencies;
 667  0
         }
 668  
 
 669  
         public void setVisas(List<EntityVisa.Builder> visas) {
 670  0
             this.visas = visas;
 671  0
         }
 672  
 
 673  
         public void setVersionNumber(Long versionNumber) {
 674  0
             this.versionNumber = versionNumber;
 675  0
         }
 676  
 
 677  
         public void setObjectId(String objectId) {
 678  0
             this.objectId = objectId;
 679  0
         }
 680  
 
 681  
         public void setActive(boolean active) {
 682  0
             this.active = active;
 683  0
         }
 684  
 
 685  
         public void setId(String id) {
 686  0
             if (StringUtils.isWhitespace(id)) {
 687  0
                 throw new IllegalArgumentException("id is blank");
 688  
             }
 689  0
             this.id = id;
 690  0
         }
 691  
 
 692  
     }
 693  
 
 694  
 
 695  
     /**
 696  
      * Defines some internal constants used on this class.
 697  
      * 
 698  
      */
 699  0
     static class Constants {
 700  
 
 701  
         final static String ROOT_ELEMENT_NAME = "entity";
 702  
         final static String TYPE_NAME = "EntityType";
 703  0
         final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[] {CoreConstants.CommonElements.FUTURE_ELEMENTS };
 704  
 
 705  
     }
 706  
 
 707  
 
 708  
     /**
 709  
      * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
 710  
      * 
 711  
      */
 712  0
     static class Elements {
 713  
 
 714  
         final static String PRINCIPALS = "principals";
 715  
         final static String PRINCIPAL = "principal";
 716  
         final static String ENTITY_TYPE_CONTACT_INFOS = "entityTypeContactInfos";
 717  
         final static String ENTITY_TYPE_CONTACT_INFO = "entityTypeContactInfo";
 718  
         final static String EXTERNAL_IDENTIFIERS = "externalIdentifiers";
 719  
         final static String EXTERNAL_IDENTIFIER = "externalIdentifier";
 720  
         final static String AFFILIATIONS = "affiliations";
 721  
         final static String AFFILIATION = "affiliation";
 722  
         final static String NAMES = "names";
 723  
         final static String NAME = "name";
 724  
         final static String EMPLOYMENT_INFORMATION = "employmentInformation";
 725  
         final static String EMPLOYMENT = "employment";
 726  
         final static String PRIVACY_PREFERENCES = "privacyPreferences";
 727  
         final static String BIO_DEMOGRAPHICS = "bioDemographics";
 728  
         final static String CITIZENSHIPS = "citizenships";
 729  
         final static String CITIZENSHIP = "citizenship";
 730  
         final static String PRIMARY_EMPLOYMENT = "primaryEmployment";
 731  
         final static String DEFAULT_AFFILIATION = "defaultAffiliation";
 732  
         final static String DEFAULT_NAME = "defaultName";
 733  
         final static String ETHNICITIES = "ethnicities";
 734  
         final static String ETHNICITY = "ethnicity";
 735  
         final static String RESIDENCIES = "residencies";
 736  
         final static String RESIDENCY = "residency";
 737  
         final static String VISAS = "visas";
 738  
         final static String VISA = "visa";
 739  
         final static String ACTIVE = "active";
 740  
         final static String ID = "id";
 741  
 
 742  
     }
 743  
 
 744  0
     public static class Cache {
 745  
         public static final String NAME = KimConstants.Namespaces.KIM_NAMESPACE_2_0 + "/" + Entity.Constants.TYPE_NAME;
 746  
     }
 747  
 }