View Javadoc

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  @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  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     @SuppressWarnings("unused")
137     @XmlAnyElement
138     private final Collection<Element> _futureElements = null;
139 
140     /**
141      * Private constructor used only by JAXB.
142      * 
143      */
144     private Entity() {
145         this.principals = null;
146         this.entityTypeContactInfos = null;
147         this.externalIdentifiers = null;
148         this.affiliations = null;
149         this.names = null;
150         this.employmentInformation = null;
151         this.privacyPreferences = null;
152         this.bioDemographics = null;
153         this.citizenships = null;
154         this.primaryEmployment = null;
155         this.defaultAffiliation = null;
156         this.defaultName = null;
157         this.ethnicities = null;
158         this.residencies = null;
159         this.visas = null;
160         this.versionNumber = null;
161         this.objectId = null;
162         this.active = false;
163         this.id = null;
164     }
165 
166     private Entity(Builder builder) {
167         this.principals = new ArrayList<Principal>();
168         if (CollectionUtils.isNotEmpty(builder.getPrincipals())) {
169             for (Principal.Builder principal : builder.getPrincipals()) {
170                 this.principals.add(principal.build());
171             }
172         }
173         this.entityTypeContactInfos = new ArrayList<EntityTypeContactInfo>();
174         if (CollectionUtils.isNotEmpty(builder.getEntityTypeContactInfos())) {
175             for (EntityTypeContactInfo.Builder entityTypeData : builder.getEntityTypeContactInfos()) {
176                 this.entityTypeContactInfos.add(entityTypeData.build());
177             }
178         }
179         this.externalIdentifiers = new ArrayList<EntityExternalIdentifier>();
180         if (CollectionUtils.isNotEmpty(builder.getExternalIdentifiers())) {
181             for (EntityExternalIdentifier.Builder externalId : builder.getExternalIdentifiers()) {
182                 this.externalIdentifiers.add(externalId.build());
183             }
184         }
185         this.affiliations = new ArrayList<EntityAffiliation>();
186         if (CollectionUtils.isNotEmpty(builder.getAffiliations())) {
187             for (EntityAffiliation.Builder affiliation : builder.getAffiliations()) {
188                 this.affiliations.add(affiliation.build());
189             }
190         }
191         this.names = new ArrayList<EntityName>();
192         if (CollectionUtils.isNotEmpty(builder.getNames())) {
193             for (EntityName.Builder name : builder.getNames()) {
194                 this.names.add(name.build());
195             }
196         }
197         this.employmentInformation = new ArrayList<EntityEmployment>();
198         if (CollectionUtils.isNotEmpty(builder.getEmploymentInformation())) {
199             for (EntityEmployment.Builder employment : builder.getEmploymentInformation()) {
200                 this.employmentInformation.add(employment.build());
201             }
202         }
203         this.privacyPreferences = builder.getPrivacyPreferences() == null ? null : builder.getPrivacyPreferences().build();
204         this.bioDemographics = builder.getBioDemographics() == null ? null : builder.getBioDemographics().build();
205         this.citizenships = new ArrayList<EntityCitizenship>();
206         if (CollectionUtils.isNotEmpty(builder.getCitizenships())) {
207             for (EntityCitizenship.Builder citizenship : builder.getCitizenships()) {
208                 this.citizenships.add(citizenship.build());
209             }
210         }
211         this.primaryEmployment = builder.getPrimaryEmployment() == null ? null : builder.getPrimaryEmployment().build();
212         this.defaultAffiliation = builder.getDefaultAffiliation() == null ? null : builder.getDefaultAffiliation().build();
213         this.defaultName = builder.getDefaultName() == null ? null : builder.getDefaultName().build();
214         this.ethnicities = new ArrayList<EntityEthnicity>();
215         if (CollectionUtils.isNotEmpty(builder.getEthnicities())) {
216             for (EntityEthnicity.Builder ethnicity : builder.getEthnicities()) {
217                 this.ethnicities.add(ethnicity.build());
218             }
219         }
220         this.residencies = new ArrayList<EntityResidency>();
221         if (CollectionUtils.isNotEmpty(builder.getResidencies())) {
222             for (EntityResidency.Builder residency : builder.getResidencies()) {
223                 this.residencies.add(residency.build());
224             }
225         }
226         this.visas = new ArrayList<EntityVisa>();
227         if (CollectionUtils.isNotEmpty(builder.getVisas())) {
228             for (EntityVisa.Builder visa : builder.getVisas()) {
229                 this.visas.add(visa.build());
230             }
231         }
232         this.versionNumber = builder.getVersionNumber();
233         this.objectId = builder.getObjectId();
234         this.active = builder.isActive();
235         this.id = builder.getId();
236     }
237 
238     @Override
239     public List<Principal> getPrincipals() {
240         return this.principals;
241     }
242 
243     @Override
244     public List<EntityTypeContactInfo> getEntityTypeContactInfos() {
245         return this.entityTypeContactInfos;
246     }
247 
248     @Override
249     public List<EntityExternalIdentifier> getExternalIdentifiers() {
250         return this.externalIdentifiers;
251     }
252 
253     @Override
254     public List<EntityAffiliation> getAffiliations() {
255         return this.affiliations;
256     }
257 
258     @Override
259     public List<EntityName> getNames() {
260         return this.names;
261     }
262 
263     @Override
264     public List<EntityEmployment> getEmploymentInformation() {
265         return this.employmentInformation;
266     }
267 
268     @Override
269     public EntityPrivacyPreferences getPrivacyPreferences() {
270         return this.privacyPreferences;
271     }
272 
273     @Override
274     public EntityBioDemographics getBioDemographics() {
275         return this.bioDemographics;
276     }
277 
278     @Override
279     public List<EntityCitizenship> getCitizenships() {
280         return this.citizenships;
281     }
282 
283     @Override
284     public EntityEmployment getPrimaryEmployment() {
285         return this.primaryEmployment;
286     }
287 
288     @Override
289     public EntityAffiliation getDefaultAffiliation() {
290         return this.defaultAffiliation;
291     }
292 
293     @Override
294     public EntityExternalIdentifier getEntityExternalIdentifier(String externalIdentifierTypeCode) {
295         if (externalIdentifiers == null) {
296             return null;
297         }
298         for (EntityExternalIdentifier externalId : externalIdentifiers) {
299             if (externalId.getExternalIdentifierTypeCode().equals(externalIdentifierTypeCode)) {
300                 return externalId;
301             }
302         }
303         return null;
304     }
305 
306     @Override
307     public EntityNameContract getDefaultName() {
308         return this.defaultName;
309     }
310 
311     @Override
312     public List<EntityEthnicity> getEthnicities() {
313         return this.ethnicities;
314     }
315 
316     @Override
317     public List<EntityResidency> getResidencies() {
318         return this.residencies;
319     }
320 
321     @Override
322     public List<EntityVisa> getVisas() {
323         return this.visas;
324     }
325 
326     @Override
327     public Long getVersionNumber() {
328         return this.versionNumber;
329     }
330 
331     @Override
332     public String getObjectId() {
333         return this.objectId;
334     }
335 
336     @Override
337     public boolean isActive() {
338         return this.active;
339     }
340 
341     @Override
342     public String getId() {
343         return this.id;
344     }
345 
346     public EntityTypeContactInfo getEntityTypeContactInfoByTypeCode(String entityTypeCode) {
347         if (entityTypeContactInfos == null) {
348             return null;
349         }
350         for (EntityTypeContactInfo entType : entityTypeContactInfos) {
351             if (entType.getEntityTypeCode().equals(entityTypeCode)) {
352                 return entType;
353             }
354         }
355         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     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         private Builder() { }
384 
385         public static Builder create() {
386             return new Builder();
387         }
388 
389         public static Builder create(EntityContract contract) {
390             if (contract == null) {
391                 throw new IllegalArgumentException("contract was null");
392             }
393             Builder builder = create();
394             if (contract.getPrincipals() != null) {
395                 List<Principal.Builder> tempPrincipals = new ArrayList<Principal.Builder>();
396                 for (PrincipalContract principal : contract.getPrincipals()) {
397                     tempPrincipals.add(Principal.Builder.create(principal));
398                 }
399                 builder.setPrincipals(tempPrincipals);
400             }
401             if (contract.getEntityTypeContactInfos() != null) {
402                 List<EntityTypeContactInfo.Builder> tempTypeData = new ArrayList<EntityTypeContactInfo.Builder>();
403                 for (EntityTypeContactInfoContract typeData : contract.getEntityTypeContactInfos()) {
404                     tempTypeData.add(EntityTypeContactInfo.Builder.create(typeData));
405                 }
406                 builder.setEntityTypes(tempTypeData);
407             }
408             if (contract.getExternalIdentifiers() != null) {
409                 List<EntityExternalIdentifier.Builder> externalIds = new ArrayList<EntityExternalIdentifier.Builder>();
410                 for (EntityExternalIdentifierContract externalId : contract.getExternalIdentifiers()) {
411                     externalIds.add(EntityExternalIdentifier.Builder.create(externalId));
412                 }
413                 builder.setExternalIdentifiers(externalIds);
414             }
415             if (contract.getAffiliations() != null) {
416                 List<EntityAffiliation.Builder> affils = new ArrayList<EntityAffiliation.Builder>();
417                 for (EntityAffiliationContract affil : contract.getAffiliations()) {
418                     affils.add(EntityAffiliation.Builder.create(affil));
419                 }
420                 builder.setAffiliations(affils);
421             }
422             if (contract.getNames() != null) {
423                 List<EntityName.Builder> nms = new ArrayList<EntityName.Builder>();
424                 for (EntityNameContract nm : contract.getNames()) {
425                     nms.add(EntityName.Builder.create(nm));
426                 }
427                 builder.setNames(nms);
428             }
429             if (contract.getEmploymentInformation() != null) {
430                 List<EntityEmployment.Builder> emps = new ArrayList<EntityEmployment.Builder>();
431                 for (EntityEmploymentContract emp : contract.getEmploymentInformation()) {
432                     emps.add(EntityEmployment.Builder.create(emp));
433                 }
434                 builder.setEmploymentInformation(emps);
435             }
436             builder.setPrivacyPreferences(contract.getPrivacyPreferences() == null ? null : EntityPrivacyPreferences.Builder.create(contract.getPrivacyPreferences()));
437             builder.setBioDemographics(contract.getBioDemographics() == null ? null : EntityBioDemographics.Builder.create(contract.getBioDemographics()));
438             if (contract.getCitizenships() != null) {
439                 List<EntityCitizenship.Builder> cits = new ArrayList<EntityCitizenship.Builder>();
440                 for (EntityCitizenshipContract cit : contract.getCitizenships()) {
441                     cits.add(EntityCitizenship.Builder.create(cit));
442                 }
443                 builder.setCitizenships(cits);
444             }
445             if (contract.getEthnicities() != null) {
446                 List<EntityEthnicity.Builder> ethnctys = new ArrayList<EntityEthnicity.Builder>();
447                 for (EntityEthnicityContract ethncty : contract.getEthnicities()) {
448                     ethnctys.add(EntityEthnicity.Builder.create(ethncty));
449                 }
450                 builder.setEthnicities(ethnctys);
451             }
452             if (contract.getResidencies() != null) {
453                 List<EntityResidency.Builder> residencyBuilders = new ArrayList<EntityResidency.Builder>();
454                 for (EntityResidencyContract residency : contract.getResidencies()) {
455                     residencyBuilders.add(EntityResidency.Builder.create(residency));
456                 }
457                 builder.setResidencies(residencyBuilders);
458             }
459             if (contract.getVisas() != null) {
460                 List<EntityVisa.Builder> visaBuilders = new ArrayList<EntityVisa.Builder>();
461                 for (EntityVisaContract visa : contract.getVisas()) {
462                     visaBuilders.add(EntityVisa.Builder.create(visa));
463                 }
464                 builder.setVisas(visaBuilders);
465             }
466             builder.setVersionNumber(contract.getVersionNumber());
467             builder.setObjectId(contract.getObjectId());
468             builder.setActive(contract.isActive());
469             builder.setId(contract.getId());
470             return builder;
471         }
472 
473         public Entity build() {
474             return new Entity(this);
475         }
476 
477         @Override
478         public List<Principal.Builder> getPrincipals() {
479             return this.principals;
480         }
481 
482         @Override
483         public List<EntityTypeContactInfo.Builder> getEntityTypeContactInfos() {
484             return this.entityTypeContactInfos;
485         }
486 
487         @Override
488         public List<EntityExternalIdentifier.Builder> getExternalIdentifiers() {
489             return this.externalIdentifiers;
490         }
491 
492         @Override
493         public List<EntityAffiliation.Builder> getAffiliations() {
494             return this.affiliations;
495         }
496 
497         @Override
498         public List<EntityName.Builder> getNames() {
499             return this.names;
500         }
501 
502         @Override
503         public List<EntityEmployment.Builder> getEmploymentInformation() {
504             return this.employmentInformation;
505         }
506 
507         @Override
508         public EntityPrivacyPreferences.Builder getPrivacyPreferences() {
509             return this.privacyPreferences;
510         }
511 
512         @Override
513         public EntityBioDemographics.Builder getBioDemographics() {
514             return this.bioDemographics;
515         }
516 
517         @Override
518         public List<EntityCitizenship.Builder> getCitizenships() {
519             return this.citizenships;
520         }
521 
522         @Override
523         public EntityTypeContactInfo.Builder getEntityTypeContactInfoByTypeCode(String entityTypeCode) {
524             if (CollectionUtils.isEmpty(this.entityTypeContactInfos)) {
525                 return null;
526             }
527             for (EntityTypeContactInfo.Builder builder : this.entityTypeContactInfos) {
528                 if (builder.getEntityTypeCode().equals(entityTypeCode) && builder.isActive()) {
529                     return builder;
530                 }
531             }
532             return null;
533         }
534 
535         @Override
536         public EntityEmployment.Builder getPrimaryEmployment() {
537             if (CollectionUtils.isEmpty(this.employmentInformation)) {
538                 return null;
539             }
540             for (EntityEmployment.Builder builder : this.employmentInformation) {
541                 if (builder.isPrimary()
542                         && builder.isActive()) {
543                     return builder;
544                 }
545             }
546             return null;
547         }
548 
549         @Override
550         public EntityAffiliation.Builder getDefaultAffiliation() {
551             if (CollectionUtils.isEmpty(this.affiliations)) {
552                 return null;
553             }
554             for (EntityAffiliation.Builder builder : this.affiliations) {
555                 if (builder.isDefaultValue()
556                         && builder.isActive()) {
557                     return builder;
558                 }
559             }
560             return null;
561         }
562 
563         @Override
564         public EntityExternalIdentifier.Builder getEntityExternalIdentifier(String externalIdentifierTypeCode) {
565             if (CollectionUtils.isEmpty(this.externalIdentifiers)) {
566                 return null;
567             }
568             for (EntityExternalIdentifier.Builder builder : this.externalIdentifiers) {
569                 if (builder.getExternalIdentifierTypeCode().equals(externalIdentifierTypeCode)) {
570                     return builder;
571                 }
572             }
573             return null;
574         }
575 
576         @Override
577         public EntityName.Builder getDefaultName() {
578             if (CollectionUtils.isEmpty(this.names)) {
579                 return null;
580             }
581             for (EntityName.Builder builder : this.names) {
582                 if (builder.isDefaultValue()
583                         && builder.isActive()) {
584                     return builder;
585                 }
586             }
587             return null;
588         }
589 
590         @Override
591         public List<EntityEthnicity.Builder> getEthnicities() {
592             return this.ethnicities;
593         }
594 
595         @Override
596         public List<EntityResidency.Builder> getResidencies() {
597             return this.residencies;
598         }
599 
600         @Override
601         public List<EntityVisa.Builder> getVisas() {
602             return this.visas;
603         }
604 
605         @Override
606         public Long getVersionNumber() {
607             return this.versionNumber;
608         }
609 
610         @Override
611         public String getObjectId() {
612             return this.objectId;
613         }
614 
615         @Override
616         public boolean isActive() {
617             return this.active;
618         }
619 
620         @Override
621         public String getId() {
622             return this.id;
623         }
624 
625         public void setPrincipals(List<Principal.Builder> principals) {
626             this.principals = principals;
627         }
628 
629         public void setEntityTypes(List<EntityTypeContactInfo.Builder> entityTypeContactInfos) {
630             this.entityTypeContactInfos = entityTypeContactInfos;
631         }
632 
633         public void setExternalIdentifiers(List<EntityExternalIdentifier.Builder> externalIdentifiers) {
634             this.externalIdentifiers = externalIdentifiers;
635         }
636 
637         public void setAffiliations(List<EntityAffiliation.Builder> affiliations) {
638             this.affiliations = affiliations;
639         }
640 
641         public void setNames(List<EntityName.Builder> names) {
642             this.names = names;
643         }
644 
645         public void setEmploymentInformation(List<EntityEmployment.Builder> employmentInformation) {
646             this.employmentInformation = employmentInformation;
647         }
648 
649         public void setPrivacyPreferences(EntityPrivacyPreferences.Builder privacyPreferences) {
650             this.privacyPreferences = privacyPreferences;
651         }
652 
653         public void setBioDemographics(EntityBioDemographics.Builder bioDemographics) {
654             this.bioDemographics = bioDemographics;
655         }
656 
657         public void setCitizenships(List<EntityCitizenship.Builder> citizenships) {
658             this.citizenships = citizenships;
659         }
660 
661         public void setEthnicities(List<EntityEthnicity.Builder> ethnicities) {
662             this.ethnicities = ethnicities;
663         }
664 
665         public void setResidencies(List<EntityResidency.Builder> residencies) {
666             this.residencies = residencies;
667         }
668 
669         public void setVisas(List<EntityVisa.Builder> visas) {
670             this.visas = visas;
671         }
672 
673         public void setVersionNumber(Long versionNumber) {
674             this.versionNumber = versionNumber;
675         }
676 
677         public void setObjectId(String objectId) {
678             this.objectId = objectId;
679         }
680 
681         public void setActive(boolean active) {
682             this.active = active;
683         }
684 
685         public void setId(String id) {
686             if (StringUtils.isWhitespace(id)) {
687                 throw new IllegalArgumentException("id is blank");
688             }
689             this.id = id;
690         }
691 
692     }
693 
694 
695     /**
696      * Defines some internal constants used on this class.
697      * 
698      */
699     static class Constants {
700 
701         final static String ROOT_ELEMENT_NAME = "entity";
702         final static String TYPE_NAME = "EntityType";
703         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     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     public static class Cache {
745         public static final String NAME = KimConstants.Namespaces.KIM_NAMESPACE_2_0 + "/" + Entity.Constants.TYPE_NAME;
746     }
747 }