View Javadoc

1   /**
2    * Copyright 2005-2013 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.personal;
17  
18  import org.apache.commons.collections.CollectionUtils;
19  import org.apache.commons.lang.StringUtils;
20  import org.apache.log4j.Logger;
21  import org.joda.time.DateTime;
22  import org.joda.time.Years;
23  import org.kuali.rice.core.api.CoreConstants;
24  import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
25  import org.kuali.rice.core.api.mo.ModelBuilder;
26  import org.kuali.rice.kim.api.KimConstants;
27  import org.w3c.dom.Element;
28  
29  import javax.xml.bind.annotation.XmlAccessType;
30  import javax.xml.bind.annotation.XmlAccessorType;
31  import javax.xml.bind.annotation.XmlAnyElement;
32  import javax.xml.bind.annotation.XmlElement;
33  import javax.xml.bind.annotation.XmlElementWrapper;
34  import javax.xml.bind.annotation.XmlRootElement;
35  import javax.xml.bind.annotation.XmlType;
36  import java.io.Serializable;
37  import java.text.ParseException;
38  import java.text.SimpleDateFormat;
39  import java.util.ArrayList;
40  import java.util.Collection;
41  import java.util.Collections;
42  import java.util.Date;
43  import java.util.List;
44  
45  @XmlRootElement(name = EntityBioDemographics.Constants.ROOT_ELEMENT_NAME)
46  @XmlAccessorType(XmlAccessType.NONE)
47  @XmlType(name = EntityBioDemographics.Constants.TYPE_NAME, propOrder = {
48      EntityBioDemographics.Elements.ENTITY_ID,
49      EntityBioDemographics.Elements.DECEASED_DATE,
50      EntityBioDemographics.Elements.BIRTH_DATE,
51      EntityBioDemographics.Elements.AGE,
52      EntityBioDemographics.Elements.GENDER_CODE,
53      EntityBioDemographics.Elements.GENDER_CHANGE_CODE,
54      EntityBioDemographics.Elements.MARITAL_STATUS_CODE,
55      EntityBioDemographics.Elements.PRIMARY_LANGUAGE_CODE,
56      EntityBioDemographics.Elements.SECONDARY_LANGUAGE_CODE,
57      EntityBioDemographics.Elements.BIRTH_COUNTRY,
58      EntityBioDemographics.Elements.BIRTH_STATE_PROVINCE_CODE,
59      EntityBioDemographics.Elements.BIRTH_CITY,
60      EntityBioDemographics.Elements.GEOGRAPHIC_ORIGIN,
61      EntityBioDemographics.Elements.BIRTH_DATE_UNMASKED,
62      EntityBioDemographics.Elements.GENDER_CODE_UNMASKED,
63      EntityBioDemographics.Elements.GENDER_CHANGE_CODE_UNMASKED,
64      EntityBioDemographics.Elements.MARITAL_STATUS_CODE_UNMASKED,
65      EntityBioDemographics.Elements.PRIMARY_LANGUAGE_CODE_UNMASKED,
66      EntityBioDemographics.Elements.SECONDARY_LANGUAGE_CODE_UNMASKED,
67      EntityBioDemographics.Elements.BIRTH_COUNTRY_UNMASKED,
68      EntityBioDemographics.Elements.BIRTH_STATE_PROVINCE_CODE_UNMASKED,
69      EntityBioDemographics.Elements.BIRTH_CITY_UNMASKED,
70      EntityBioDemographics.Elements.GEOGRAPHIC_ORIGIN_UNMASKED,
71      EntityBioDemographics.Elements.NOTE_MESSAGE,
72      EntityBioDemographics.Elements.SUPPRESS_PERSONAL,
73      EntityBioDemographics.Elements.DISABLED,
74      EntityBioDemographics.Elements.DISABILITIES,
75      EntityBioDemographics.Elements.VETERAN,
76      EntityBioDemographics.Elements.MILITARY_RECORDS,
77      CoreConstants.CommonElements.VERSION_NUMBER,
78      CoreConstants.CommonElements.OBJECT_ID,
79      CoreConstants.CommonElements.FUTURE_ELEMENTS
80  })
81  public final class EntityBioDemographics extends AbstractDataTransferObject
82      implements EntityBioDemographicsContract
83  {
84      private static final Logger LOG = Logger.getLogger(EntityBioDemographics.class);
85  
86      @XmlElement(name = Elements.ENTITY_ID, required = false)
87      private final String entityId;
88      @XmlElement(name = Elements.DECEASED_DATE, required = false)
89      private final String deceasedDate;
90      @XmlElement(name = Elements.BIRTH_DATE, required = false)
91      private final String birthDate;
92      @XmlElement(name = Elements.GENDER_CODE, required = false)
93      private final String genderCode;
94      @XmlElement(name = Elements.GENDER_CHANGE_CODE, required = false)
95      private final String genderChangeCode;
96      @XmlElement(name = Elements.MARITAL_STATUS_CODE, required = false)
97      private final String maritalStatusCode;
98      @XmlElement(name = Elements.PRIMARY_LANGUAGE_CODE, required = false)
99      private final String primaryLanguageCode;
100     @XmlElement(name = Elements.SECONDARY_LANGUAGE_CODE, required = false)
101     private final String secondaryLanguageCode;
102     @XmlElement(name = Elements.BIRTH_COUNTRY, required = false)
103     private final String birthCountry;
104     @XmlElement(name = Elements.BIRTH_STATE_PROVINCE_CODE, required = false)
105     private final String birthStateProvinceCode;
106     @XmlElement(name = Elements.BIRTH_CITY, required = false)
107     private final String birthCity;
108     @XmlElement(name = Elements.GEOGRAPHIC_ORIGIN, required = false)
109     private final String geographicOrigin;
110 
111     @XmlElement(name = Elements.BIRTH_DATE_UNMASKED, required = false)
112     private final String birthDateUnmasked;
113     @XmlElement(name = Elements.GENDER_CODE_UNMASKED, required = false)
114     private final String genderCodeUnmasked;
115     @XmlElement(name = Elements.GENDER_CHANGE_CODE_UNMASKED, required = false)
116     private final String genderChangeCodeUnmasked;
117     @XmlElement(name = Elements.MARITAL_STATUS_CODE_UNMASKED, required = false)
118     private final String maritalStatusCodeUnmasked;
119     @XmlElement(name = Elements.PRIMARY_LANGUAGE_CODE_UNMASKED, required = false)
120     private final String primaryLanguageCodeUnmasked;
121     @XmlElement(name = Elements.SECONDARY_LANGUAGE_CODE_UNMASKED, required = false)
122     private final String secondaryLanguageCodeUnmasked;
123     @XmlElement(name = Elements.BIRTH_COUNTRY_UNMASKED, required = false)
124     private final String birthCountryUnmasked;
125     @XmlElement(name = Elements.BIRTH_STATE_PROVINCE_CODE_UNMASKED, required = false)
126     private final String birthStateProvinceCodeUnmasked;
127     @XmlElement(name = Elements.BIRTH_CITY_UNMASKED, required = false)
128     private final String birthCityUnmasked;
129     @XmlElement(name = Elements.GEOGRAPHIC_ORIGIN_UNMASKED, required = false)
130     private final String geographicOriginUnmasked;
131 
132     @XmlElement(name = Elements.NOTE_MESSAGE, required = false)
133     private final String noteMessage;
134     @XmlElement(name = Elements.SUPPRESS_PERSONAL, required = false)
135     private final boolean suppressPersonal;
136 
137     @XmlElementWrapper(name = Elements.DISABILITIES, required = false)
138     @XmlElement(name = Elements.DISABILITY, required = false)
139     private final List<EntityDisability> disabilities;
140     @XmlElementWrapper(name = Elements.MILITARY_RECORDS, required = false)
141     @XmlElement(name = Elements.MILITARY_RECORD, required = false)
142     private final List<EntityMilitary> militaryRecords;
143 
144     @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
145     private final Long versionNumber;
146     @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
147     private final String objectId;
148     @SuppressWarnings("unused")
149     @XmlAnyElement
150     private final Collection<Element> _futureElements = null;
151 
152     /**
153      * Private constructor used only by JAXB.
154      * 
155      */
156     private EntityBioDemographics() {
157         this.entityId = null;
158         this.deceasedDate = null;
159         this.birthDate = null;
160         this.genderCode = null;
161         this.genderChangeCode = null;
162         this.maritalStatusCode = null;
163         this.primaryLanguageCode = null;
164         this.secondaryLanguageCode = null;
165         this.birthCountry = null;
166         this.birthStateProvinceCode = null;
167         this.birthCity = null;
168         this.geographicOrigin = null;
169 
170         this.birthDateUnmasked = null;
171         this.genderCodeUnmasked = null;
172         this.genderChangeCodeUnmasked = null;
173         this.maritalStatusCodeUnmasked = null;
174         this.primaryLanguageCodeUnmasked = null;
175         this.secondaryLanguageCodeUnmasked = null;
176         this.birthCountryUnmasked = null;
177         this.birthStateProvinceCodeUnmasked = null;
178         this.birthCityUnmasked = null;
179         this.geographicOriginUnmasked = null;
180 
181         this.noteMessage = null;
182         this.militaryRecords = null;
183         this.disabilities = null;
184         this.suppressPersonal = false;
185         this.versionNumber = null;
186         this.objectId = null;
187     }
188 
189     private EntityBioDemographics(Builder builder) {
190         this.entityId = builder.getEntityId();
191         this.deceasedDate = builder.getDeceasedDate();
192         this.birthDate = builder.getBirthDate();
193         this.genderCode = builder.getGenderCode();
194         this.genderChangeCode = builder.getGenderChangeCode();
195         this.maritalStatusCode = builder.getMaritalStatusCode();
196         this.primaryLanguageCode = builder.getPrimaryLanguageCode();
197         this.secondaryLanguageCode = builder.getSecondaryLanguageCode();
198         this.birthCountry = builder.getBirthCountry();
199         this.birthStateProvinceCode = builder.getBirthStateProvinceCode();
200         this.birthCity = builder.getBirthCity();
201         this.geographicOrigin = builder.getGeographicOrigin();
202 
203         this.birthDateUnmasked = builder.getBirthDateUnmasked();
204         this.genderCodeUnmasked = builder.getGenderCodeUnmasked();
205         this.genderChangeCodeUnmasked = builder.getGenderChangeCodeUnmasked();
206         this.maritalStatusCodeUnmasked = builder.getMaritalStatusCodeUnmasked();
207         this.primaryLanguageCodeUnmasked = builder.getPrimaryLanguageCodeUnmasked();
208         this.secondaryLanguageCodeUnmasked = builder.getSecondaryLanguageCodeUnmasked();
209         this.birthCountryUnmasked = builder.getBirthCountryUnmasked();
210         this.birthStateProvinceCodeUnmasked = builder.getBirthStateProvinceCodeUnmasked();
211         this.birthCityUnmasked = builder.getBirthCityUnmasked();
212         this.geographicOriginUnmasked = builder.getGeographicOriginUnmasked();
213 
214         this.noteMessage = builder.getNoteMessage();
215         this.disabilities = new ArrayList<EntityDisability>();
216         if (CollectionUtils.isNotEmpty(builder.getDisabilities())) {
217             for (EntityDisability.Builder disability : builder.getDisabilities()) {
218                 this.disabilities.add(disability.build());
219             }
220         }
221 
222         this.militaryRecords = new ArrayList<EntityMilitary>();
223         if (CollectionUtils.isNotEmpty(builder.getMilitaryRecords())) {
224             for (EntityMilitary.Builder military : builder.getMilitaryRecords()) {
225                 this.militaryRecords.add(military.build());
226             }
227         }
228 
229         this.suppressPersonal = builder.isSuppressPersonal();
230         this.versionNumber = builder.getVersionNumber();
231         this.objectId = builder.getObjectId();
232     }
233 
234     @Override
235     public String getEntityId() {
236         return this.entityId;
237     }
238 
239     @Override
240     public String getDeceasedDate() {
241         return this.deceasedDate;
242     }
243 
244     @Override
245     public String getBirthDate() {
246         return this.birthDate;
247     }
248 
249     @Override
250     @XmlElement(name = Elements.VETERAN, required = false)
251     public boolean isVeteran() {
252         return CollectionUtils.isNotEmpty(this.militaryRecords);
253     }
254 
255     @Override
256     @XmlElement(name = Elements.DISABLED, required = false)
257     public boolean isDisabled() {
258         return CollectionUtils.isNotEmpty(this.disabilities);
259     }
260 
261     @Override
262     @XmlElement(name = Elements.AGE, required = true)
263     public Integer getAge() {
264         return calculateAge(this.birthDate, this.deceasedDate, isSuppressPersonal());
265     }
266 
267     @Override
268     public String getGenderCode() {
269         return this.genderCode;
270     }
271 
272     @Override
273     public String getGenderChangeCode() {
274         return this.genderChangeCode;
275     }
276 
277     @Override
278     public String getMaritalStatusCode() {
279         return this.maritalStatusCode;
280     }
281 
282     @Override
283     public String getPrimaryLanguageCode() {
284         return this.primaryLanguageCode;
285     }
286 
287     @Override
288     public String getSecondaryLanguageCode() {
289         return this.secondaryLanguageCode;
290     }
291 
292     @Override
293     public String getBirthCountry() {
294         return this.birthCountry;
295     }
296 
297     @Override
298     public String getBirthStateProvinceCode() {
299         return this.birthStateProvinceCode;
300     }
301 
302     @Override
303     public String getBirthCity() {
304         return this.birthCity;
305     }
306 
307     @Override
308     public String getGeographicOrigin() {
309         return this.geographicOrigin;
310     }
311 
312     @Override
313     public String getBirthDateUnmasked() {
314         return this.birthDateUnmasked;
315     }
316 
317     @Override
318     public String getGenderCodeUnmasked() {
319         return this.genderCodeUnmasked;
320     }
321 
322     @Override
323     public String getGenderChangeCodeUnmasked() {
324         return this.genderChangeCodeUnmasked;
325     }
326     
327     @Override
328     public String getMaritalStatusCodeUnmasked() {
329         return this.maritalStatusCodeUnmasked;
330     }
331 
332     @Override
333     public String getPrimaryLanguageCodeUnmasked() {
334         return this.primaryLanguageCodeUnmasked;
335     }
336 
337     @Override
338     public String getSecondaryLanguageCodeUnmasked() {
339         return this.secondaryLanguageCodeUnmasked;
340     }
341 
342     @Override
343     public String getBirthCountryUnmasked() {
344         return this.birthCountryUnmasked;
345     }
346 
347     @Override
348     public String getBirthStateProvinceCodeUnmasked() {
349         return this.birthStateProvinceCodeUnmasked;
350     }
351 
352     @Override
353     public String getBirthCityUnmasked() {
354         return this.birthCityUnmasked;
355     }
356 
357     @Override
358     public String getGeographicOriginUnmasked() {
359         return this.geographicOriginUnmasked;
360     }
361 
362     @Override
363     public String getNoteMessage() {
364         return this.noteMessage;
365     }
366 
367     @Override
368     public boolean isSuppressPersonal() {
369         return this.suppressPersonal;
370     }
371 
372     @Override
373     public Long getVersionNumber() {
374         return this.versionNumber;
375     }
376 
377     @Override
378     public String getObjectId() {
379         return this.objectId;
380     }
381 
382     @Override
383     public List<EntityDisability> getDisabilities() {
384         return Collections.unmodifiableList(this.disabilities);
385     }
386 
387     @Override
388     public List<EntityMilitary> getMilitaryRecords() {
389         return Collections.unmodifiableList(this.militaryRecords);
390     }
391 
392     /**
393      * Helper to parse the birth date for age calculation
394      * @param birthDate the birth date in EntityBioDemographicsContract BIRTH_DATE_FORMAT format
395      * @param deceasedDate the deceased date in EntityBioDemographicsContract DECEASED_DATE_FORMAT format
396      * @param suppressPersonal whether personal information is being suppressed
397      * @return the age in years or null if unavailable, suppressed, or an error occurs during calculation
398      */
399     private static Integer calculateAge(String birthDate, String deceasedDate, boolean suppressPersonal) {
400         if (birthDate != null && ! suppressPersonal) {
401             Date parsedBirthDate;
402             try {
403                 parsedBirthDate = new SimpleDateFormat(BIRTH_DATE_FORMAT).parse(birthDate);
404             } catch (ParseException pe) {
405                 LOG.error("Error parsing EntityBioDemographics birth date: '" + birthDate + "'", pe);
406                 return null;
407             }
408             DateTime endDate;
409             if (deceasedDate != null) {
410                 try {
411                    endDate = new DateTime(new SimpleDateFormat(BIRTH_DATE_FORMAT).parse(deceasedDate));
412                 } catch (ParseException pe) {
413                     LOG.error("Error parsing EntityBioDemographics deceased date: '" + deceasedDate+ "'", pe);
414                     return null;
415                 }
416             } else {
417                 endDate = new DateTime();
418             }
419             return Years.yearsBetween(new DateTime(parsedBirthDate), endDate).getYears();
420         }
421         return null;
422     }
423 
424     /**
425      * A builder which can be used to construct {@link EntityBioDemographics} instances.  Enforces the constraints of the {@link EntityBioDemographicsContract}.
426      * 
427      */
428     public final static class Builder
429         implements Serializable, ModelBuilder, EntityBioDemographicsContract
430     {
431 
432         private String entityId;
433         private String deceasedDate;
434         private String birthDate;
435         private String genderCode;
436         private String maritalStatusCode;
437         private String primaryLanguageCode;
438         private String secondaryLanguageCode;
439         private String birthCountry;
440         private String birthStateProvinceCode;
441         private String birthCity;
442         private String geographicOrigin;
443         private String genderChangeCode;
444         private String noteMessage;
445         private boolean suppressPersonal;
446         private List<EntityDisability.Builder> disabilities;
447         private List<EntityMilitary.Builder> militaryRecords;
448         private Long versionNumber;
449         private String objectId;
450 
451         private Builder(String entityId, String genderCode) {
452             setEntityId(entityId);
453             setGenderCode(genderCode);
454         }
455 
456         public static Builder create(String entityId, String genderCode) {
457             // TODO modify as needed to pass any required values and add them to the signature of the 'create' method
458             return new Builder(entityId, genderCode);
459         }
460 
461         public static Builder create(EntityBioDemographicsContract contract) {
462             if (contract == null) {
463                 throw new IllegalArgumentException("contract was null");
464             }
465             Builder builder = create(contract.getEntityId(), contract.getGenderCode());
466             builder.setDeceasedDate(contract.getDeceasedDate());
467             builder.setBirthDate(contract.getBirthDate());
468             builder.setMaritalStatusCode(contract.getMaritalStatusCode());
469             builder.setPrimaryLanguageCode(contract.getPrimaryLanguageCode());
470             builder.setSecondaryLanguageCode(contract.getSecondaryLanguageCode());
471             builder.setBirthCountry(contract.getBirthCountry());
472             builder.setBirthStateProvinceCode(contract.getBirthStateProvinceCode());
473             builder.setBirthCity(contract.getBirthCity());
474             builder.setGeographicOrigin(contract.getGeographicOrigin());
475             builder.setGenderChangeCode(contract.getGenderChangeCode());
476             builder.setNoteMessage(contract.getNoteMessage());
477             builder.setSuppressPersonal(contract.isSuppressPersonal());
478             if (contract.getDisabilities() != null) {
479                 List<EntityDisability.Builder> disabilities = new ArrayList<EntityDisability.Builder>();
480                 for (EntityDisabilityContract disability : contract.getDisabilities()) {
481                     disabilities.add(EntityDisability.Builder.create(disability));
482                 }
483                 builder.setDisabilities(disabilities);
484             }
485             if (contract.getMilitaryRecords() != null) {
486                 List<EntityMilitary.Builder> militaryRecs = new ArrayList<EntityMilitary.Builder>();
487                 for (EntityMilitaryContract military : contract.getMilitaryRecords()) {
488                     militaryRecs.add(EntityMilitary.Builder.create(military));
489                 }
490                 builder.setMilitaryRecords(militaryRecs);
491             }
492 
493             builder.setVersionNumber(contract.getVersionNumber());
494             builder.setObjectId(contract.getObjectId());
495             return builder;
496         }
497 
498         public EntityBioDemographics build() {
499             return new EntityBioDemographics(this);
500         }
501 
502         @Override
503         public String getEntityId() {
504             return this.entityId;
505         }
506 
507         @Override
508         public String getDeceasedDate() {
509             return this.deceasedDate;
510         }
511 
512         @Override
513         public String getBirthDate() {
514             if (isSuppressPersonal()) {
515                 return KimConstants.RESTRICTED_DATA_MASK;
516             }
517             return this.birthDate;
518         }
519 
520         @Override
521         public Integer getAge() {
522             return calculateAge(this.birthDate, this.deceasedDate, isSuppressPersonal());
523         }
524 
525         @Override
526         public String getGenderCode() {
527             if (isSuppressPersonal()) {
528                 return KimConstants.RESTRICTED_DATA_MASK;
529             }
530             return this.genderCode;
531         }
532 
533         @Override
534         public String getGenderChangeCode() {
535             if (isSuppressPersonal()) {
536                 return KimConstants.RESTRICTED_DATA_MASK;
537             }
538             return this.genderChangeCode;
539         }
540 
541         @Override
542         public String getMaritalStatusCode() {
543             if (isSuppressPersonal()) {
544                 return KimConstants.RESTRICTED_DATA_MASK;
545             }
546             return this.maritalStatusCode;
547         }
548 
549         @Override
550         public String getPrimaryLanguageCode() {
551             if (isSuppressPersonal()) {
552                 return KimConstants.RESTRICTED_DATA_MASK;
553             }
554             return this.primaryLanguageCode;
555         }
556 
557         @Override
558         public String getSecondaryLanguageCode() {
559             if (isSuppressPersonal()) {
560                 return KimConstants.RESTRICTED_DATA_MASK;
561             }
562             return this.secondaryLanguageCode;
563         }
564 
565         @Override
566         public String getBirthCountry() {
567             if (isSuppressPersonal()) {
568                 return KimConstants.RESTRICTED_DATA_MASK;
569             }
570             return this.birthCountry;
571         }
572 
573         @Override
574         public String getBirthStateProvinceCode() {
575             if (isSuppressPersonal()) {
576                 return KimConstants.RESTRICTED_DATA_MASK;
577             }
578             return this.birthStateProvinceCode;
579         }
580 
581         @Override
582         public String getBirthCity() {
583             if (isSuppressPersonal()) {
584                 return KimConstants.RESTRICTED_DATA_MASK;
585             }
586             return this.birthCity;
587         }
588 
589         @Override
590         public String getGeographicOrigin() {
591             if (isSuppressPersonal()) {
592                 return KimConstants.RESTRICTED_DATA_MASK;
593             }
594             return this.geographicOrigin;
595         }
596 
597         @Override
598         public String getBirthDateUnmasked() {
599             return this.birthDate;
600         }
601 
602         @Override
603         public String getGenderCodeUnmasked() {
604             return this.genderCode;
605         }
606 
607         @Override
608         public String getGenderChangeCodeUnmasked() {
609             return this.genderChangeCode;
610         }
611 
612         @Override
613         public String getMaritalStatusCodeUnmasked() {
614             return this.maritalStatusCode;
615         }
616 
617         @Override
618         public String getPrimaryLanguageCodeUnmasked() {
619             return this.primaryLanguageCode;
620         }
621 
622         @Override
623         public String getSecondaryLanguageCodeUnmasked() {
624             return this.secondaryLanguageCode;
625         }
626 
627         @Override
628         public String getBirthCountryUnmasked() {
629             return this.birthCountry;
630         }
631 
632         @Override
633         public String getBirthStateProvinceCodeUnmasked() {
634             return this.birthStateProvinceCode;
635         }
636 
637         @Override
638         public String getBirthCityUnmasked() {
639             return this.birthCity;
640         }
641 
642         @Override
643         public String getGeographicOriginUnmasked() {
644             return this.geographicOrigin;
645         }
646 
647         @Override
648         public String getNoteMessage() {
649             return this.noteMessage;
650         }
651 
652         @Override
653         public boolean isSuppressPersonal() {
654             return this.suppressPersonal;
655         }
656 
657         @Override
658         public Long getVersionNumber() {
659             return this.versionNumber;
660         }
661 
662         @Override
663         public String getObjectId() {
664             return this.objectId;
665         }
666 
667         @Override
668         public boolean isVeteran() {
669             return CollectionUtils.isNotEmpty(this.militaryRecords);
670         }
671 
672         @Override
673         public boolean isDisabled() {
674             return CollectionUtils.isNotEmpty(this.disabilities);
675         }
676 
677         @Override
678         public List<EntityDisability.Builder> getDisabilities() {
679             return this.disabilities;
680         }
681 
682         @Override
683         public List<EntityMilitary.Builder> getMilitaryRecords() {
684             return this.militaryRecords;
685         }
686 
687         public void setEntityId(String entityId) {
688             if (StringUtils.isEmpty(entityId)) {
689                 throw new IllegalArgumentException("id is empty");
690             }
691             this.entityId = entityId;
692         }
693 
694         public void setDeceasedDate(String deceasedDate) {
695             if (deceasedDate != null) {
696                 SimpleDateFormat format = new SimpleDateFormat(DECEASED_DATE_FORMAT);
697                 try{
698                     format.parse(deceasedDate);
699                     this.deceasedDate = deceasedDate;
700                 }
701                 catch(ParseException e) {
702                     throw new IllegalArgumentException("deceasedDate is not of the format 'yyyy-MM-DD'");
703                 }
704             }
705         }
706 
707         public void setBirthDate(String birthDate) {
708             if (birthDate != null) {
709                 SimpleDateFormat format = new SimpleDateFormat(BIRTH_DATE_FORMAT);
710                 try{
711                     format.parse(birthDate);
712                     this.birthDate = birthDate;
713                 }
714                 catch(ParseException e) {
715                     throw new IllegalArgumentException("birthDate is not of the format 'yyyy-MM-DD'");
716                 }
717             }
718         }
719 
720         public void setDeceasedDate(Date deceasedDate) {
721             this.deceasedDate = new SimpleDateFormat(DECEASED_DATE_FORMAT).format(deceasedDate);
722         }
723 
724         public void setBirthDate(Date birthDate) {
725             this.birthDate = new SimpleDateFormat(BIRTH_DATE_FORMAT).format(birthDate);
726         }
727 
728         public void setGenderCode(String genderCode) {
729             if (StringUtils.isEmpty(genderCode)) {
730                 throw new IllegalArgumentException("genderCode is empty");
731             }
732             this.genderCode = genderCode;
733         }
734 
735         public void setGenderChangeCode(String genderChangeCode) {
736             this.genderChangeCode = genderChangeCode;
737         }
738 
739         public void setMaritalStatusCode(String maritalStatusCode) {
740             this.maritalStatusCode = maritalStatusCode;
741         }
742 
743         public void setPrimaryLanguageCode(String primaryLanguageCode) {
744             this.primaryLanguageCode = primaryLanguageCode;
745         }
746 
747         public void setSecondaryLanguageCode(String secondaryLanguageCode) {
748             this.secondaryLanguageCode = secondaryLanguageCode;
749         }
750 
751         public void setBirthCountry(String birthCountry) {
752             this.birthCountry = birthCountry;
753         }
754 
755         public void setBirthStateProvinceCode(String birthStateProvinceCode) {
756             this.birthStateProvinceCode = birthStateProvinceCode;
757         }
758 
759         public void setBirthCity(String birthCity) {
760             this.birthCity = birthCity;
761         }
762 
763         public void setGeographicOrigin(String geographicOrigin) {
764             this.geographicOrigin = geographicOrigin;
765         }
766 
767         private void setNoteMessage(String noteMessage) {
768             this.noteMessage = noteMessage;
769         }
770 
771         private void setSuppressPersonal(boolean suppressPersonal) {
772             this.suppressPersonal = suppressPersonal;
773         }
774 
775         public void setVersionNumber(Long versionNumber) {
776             this.versionNumber = versionNumber;
777         }
778 
779         public void setObjectId(String objectId) {
780             this.objectId = objectId;
781         }
782 
783         public void setDisabilities(List<EntityDisability.Builder> disabilities) {
784             this.disabilities = disabilities;
785         }
786 
787         public void setMilitaryRecords(List<EntityMilitary.Builder> militaryRecords) {
788             this.militaryRecords = militaryRecords;
789         }
790 
791     }
792 
793 
794     /**
795      * Defines some internal constants used on this class.
796      * 
797      */
798     static class Constants {
799 
800         final static String ROOT_ELEMENT_NAME = "entityBioDemographics";
801         final static String TYPE_NAME = "EntityBioDemographicsType";
802     }
803 
804 
805     /**
806      * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
807      * 
808      */
809     static class Elements {
810 
811         final static String ENTITY_ID = "entityId";
812         final static String DECEASED_DATE = "deceasedDate";
813         final static String BIRTH_DATE = "birthDate";
814         final static String AGE = "age";
815         final static String GENDER_CODE = "genderCode";
816         final static String MARITAL_STATUS_CODE = "maritalStatusCode";
817         final static String PRIMARY_LANGUAGE_CODE = "primaryLanguageCode";
818         final static String SECONDARY_LANGUAGE_CODE = "secondaryLanguageCode";
819         final static String BIRTH_COUNTRY = "birthCountry";
820         final static String BIRTH_STATE_PROVINCE_CODE = "birthStateProvinceCode";
821         final static String BIRTH_CITY = "birthCity";
822         final static String GEOGRAPHIC_ORIGIN = "geographicOrigin";
823         final static String BIRTH_DATE_UNMASKED = "birthDateUnmasked";
824         final static String GENDER_CODE_UNMASKED = "genderCodeUnmasked";
825         final static String MARITAL_STATUS_CODE_UNMASKED = "maritalStatusCodeUnmasked";
826         final static String PRIMARY_LANGUAGE_CODE_UNMASKED = "primaryLanguageCodeUnmasked";
827         final static String SECONDARY_LANGUAGE_CODE_UNMASKED = "secondaryLanguageCodeUnmasked";
828         final static String BIRTH_COUNTRY_UNMASKED = "birthCountryUnmasked";
829         final static String BIRTH_STATE_PROVINCE_CODE_UNMASKED = "birthStateProvinceCodeUnmasked";
830         final static String BIRTH_CITY_UNMASKED = "birthCityUnmasked";
831         final static String GEOGRAPHIC_ORIGIN_UNMASKED = "geographicOriginUnmasked";
832         final static String GENDER_CHANGE_CODE = "genderChangeCode";
833         final static String GENDER_CHANGE_CODE_UNMASKED = "genderChangeCodeUnmasked";
834         final static String NOTE_MESSAGE = "noteMessage";
835 
836         final static String DISABLED = "disabled";
837         final static String DISABILITIES = "disabilities";
838         final static String DISABILITY = "disability";
839         final static String VETERAN = "veteran";
840         final static String MILITARY_RECORDS = "militaryRecords";
841         final static String MILITARY_RECORD = "militaryRecord";
842 
843         final static String SUPPRESS_PERSONAL = "suppressPersonal";
844 
845     }
846 
847 }