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