1 | |
package org.kuali.rice.kim.impl.identity.personal |
2 | |
|
3 | |
import java.text.SimpleDateFormat |
4 | |
import javax.persistence.Column |
5 | |
import javax.persistence.Entity |
6 | |
import javax.persistence.Id |
7 | |
import javax.persistence.Table |
8 | |
import javax.persistence.Transient |
9 | |
import org.kuali.rice.kim.api.KimConstants |
10 | |
import org.kuali.rice.kim.api.identity.personal.EntityBioDemographics |
11 | |
import org.kuali.rice.kim.api.identity.personal.EntityBioDemographicsContract |
12 | |
import org.kuali.rice.kim.api.identity.privacy.EntityPrivacyPreferences |
13 | |
import org.kuali.rice.kim.api.services.KimApiServiceLocator |
14 | |
import org.kuali.rice.krad.bo.PersistableBusinessObjectBase |
15 | |
|
16 | |
@Entity |
17 | |
@Table(name = "KRIM_ENTITY_BIO_T") |
18 | |
class EntityBioDemographicsBo extends PersistableBusinessObjectBase implements EntityBioDemographicsContract { |
19 | |
private static final long serialVersionUID = 6317317790920881093L; |
20 | |
|
21 | |
@Id |
22 | |
@Column(name = "ENTITY_ID") |
23 | |
String entityId; |
24 | |
|
25 | |
@Column(name = "BIRTH_DT") |
26 | |
Date birthDateValue; |
27 | |
|
28 | |
@Column(name = "GNDR_CD") |
29 | |
String genderCode; |
30 | |
|
31 | |
@Column(name = "DECEASED_DT") |
32 | |
Date deceasedDateValue; |
33 | |
|
34 | |
@Column(name = "MARITAL_STATUS") |
35 | |
String maritalStatusCode; |
36 | |
|
37 | |
@Column(name = "PRIM_LANG_CD") |
38 | |
String primaryLanguageCode; |
39 | |
|
40 | |
@Column(name = "SEC_LANG_CD") |
41 | |
String secondaryLanguageCode; |
42 | |
|
43 | |
@Column(name = "BIRTH_CNTRY_CD") |
44 | |
String countryOfBirthCode; |
45 | |
|
46 | |
@Column(name = "BIRTH_STATE_CD") |
47 | |
String birthStateCode; |
48 | |
|
49 | |
@Column(name = "BIRTH_CITY") |
50 | |
String cityOfBirth; |
51 | |
|
52 | |
@Column(name = "GEO_ORIGIN") |
53 | |
String geographicOrigin; |
54 | |
|
55 | |
@Transient |
56 | |
boolean suppressPersonal; |
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
static EntityBioDemographics to(EntityBioDemographicsBo bo) { |
64 | 1 | if (bo == null) { return null } |
65 | 1 | return EntityBioDemographics.Builder.create(bo).build() |
66 | |
} |
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
static EntityBioDemographicsBo from(EntityBioDemographics immutable) { |
74 | 1 | if (immutable == null) {return null} |
75 | |
|
76 | 1 | EntityBioDemographicsBo bo = new EntityBioDemographicsBo() |
77 | 1 | bo.entityId = immutable.entityId |
78 | 1 | if (immutable.birthDateUnmasked != null) { |
79 | 0 | bo.birthDateValue = new SimpleDateFormat("yyyy-MM-dd").parse(immutable.birthDateUnmasked) |
80 | |
} |
81 | 1 | bo.birthStateCode = immutable.birthStateCodeUnmasked |
82 | 1 | bo.cityOfBirth = immutable.cityOfBirthUnmasked |
83 | 1 | bo.countryOfBirthCode = immutable.countryOfBirthCodeUnmasked |
84 | 1 | if (immutable.deceasedDate != null) { |
85 | 0 | bo.deceasedDateValue = new SimpleDateFormat("yyyy-MM-dd").parse(immutable.deceasedDate) |
86 | |
} |
87 | 1 | bo.genderCode = immutable.genderCodeUnmasked |
88 | 1 | bo.geographicOrigin = immutable.geographicOriginUnmasked |
89 | 1 | bo.maritalStatusCode = immutable.maritalStatusCodeUnmasked |
90 | 1 | bo.primaryLanguageCode = immutable.primaryLanguageCodeUnmasked |
91 | 1 | bo.secondaryLanguageCode = immutable.secondaryLanguageCodeUnmasked |
92 | 1 | bo.versionNumber = immutable.versionNumber |
93 | 1 | bo.objectId = immutable.objectId |
94 | |
|
95 | 1 | return bo; |
96 | |
} |
97 | |
|
98 | |
@Override |
99 | |
String getBirthDate() { |
100 | 1 | if (this.birthDateValue != null) { |
101 | 0 | if (isSuppressPersonal()) { |
102 | 0 | return KimConstants.RestrictedMasks.RESTRICTED_DATA_MASK |
103 | |
} |
104 | 0 | return new SimpleDateFormat("yyyy-MM-dd").format(this.birthDateValue) |
105 | |
} |
106 | 1 | return null; |
107 | |
} |
108 | |
|
109 | |
@Override |
110 | |
String getDeceasedDate() { |
111 | 1 | if (this.deceasedDateValue != null) { |
112 | 0 | return new SimpleDateFormat("yyyy-MM-dd").format(this.deceasedDateValue) |
113 | |
} |
114 | 1 | return null |
115 | |
} |
116 | |
|
117 | |
@Override |
118 | |
String getBirthDateUnmasked() { |
119 | 0 | if (this.birthDateValue != null) { |
120 | 0 | return new SimpleDateFormat("yyyy-MM-dd").format(this.birthDateValue) |
121 | |
} |
122 | 0 | return null; |
123 | |
} |
124 | |
|
125 | |
@Override |
126 | |
boolean isSuppressPersonal() { |
127 | 9 | if (this.suppressPersonal == null) { |
128 | 0 | EntityPrivacyPreferences privacy = KimApiServiceLocator.getIdentityService().getEntityPrivacyPreferences(getEntityId()) |
129 | 0 | if (privacy != null) { |
130 | 0 | this.suppressPersonal = privacy.isSuppressPersonal() |
131 | |
} else { |
132 | 0 | this.suppressPersonal = false |
133 | |
} |
134 | |
} |
135 | |
|
136 | 9 | return suppressPersonal; |
137 | |
} |
138 | |
|
139 | |
String getGenderCode() { |
140 | 1 | if (isSuppressPersonal()) { |
141 | 0 | return KimConstants.RestrictedMasks.RESTRICTED_DATA_MASK_CODE |
142 | |
} |
143 | 1 | return this.genderCode |
144 | |
} |
145 | |
|
146 | |
String getMaritalStatusCode() { |
147 | 1 | if (isSuppressPersonal()) { |
148 | 0 | return KimConstants.RestrictedMasks.RESTRICTED_DATA_MASK_CODE |
149 | |
} |
150 | 1 | return this.maritalStatusCode |
151 | |
} |
152 | |
String getPrimaryLanguageCode() { |
153 | 1 | if (isSuppressPersonal()) { |
154 | 0 | return KimConstants.RestrictedMasks.RESTRICTED_DATA_MASK_CODE |
155 | |
} |
156 | 1 | return this.primaryLanguageCode |
157 | |
} |
158 | |
String getSecondaryLanguageCode() { |
159 | 1 | if (isSuppressPersonal()) { |
160 | 0 | return KimConstants.RestrictedMasks.RESTRICTED_DATA_MASK_CODE |
161 | |
} |
162 | 1 | return this.secondaryLanguageCode |
163 | |
} |
164 | |
String getCountryOfBirthCode() { |
165 | 1 | if (isSuppressPersonal()) { |
166 | 0 | return KimConstants.RestrictedMasks.RESTRICTED_DATA_MASK_CODE |
167 | |
} |
168 | 1 | return this.countryOfBirthCode |
169 | |
} |
170 | |
String getBirthStateCode() { |
171 | 1 | if (isSuppressPersonal()) { |
172 | 0 | return KimConstants.RestrictedMasks.RESTRICTED_DATA_MASK_CODE |
173 | |
} |
174 | 1 | return this.birthStateCode |
175 | |
} |
176 | |
String getCityOfBirth() { |
177 | 1 | if (isSuppressPersonal()) { |
178 | 0 | return KimConstants.RestrictedMasks.RESTRICTED_DATA_MASK_CODE |
179 | |
} |
180 | 1 | return this.cityOfBirth |
181 | |
} |
182 | |
String getGeographicOrigin() { |
183 | 1 | if (isSuppressPersonal()) { |
184 | 0 | return KimConstants.RestrictedMasks.RESTRICTED_DATA_MASK_CODE |
185 | |
} |
186 | 1 | return this.geographicOrigin |
187 | |
} |
188 | |
|
189 | |
|
190 | |
String getGenderCodeUnmasked() { |
191 | 0 | return this.genderCode |
192 | |
} |
193 | |
String getMaritalStatusCodeUnmasked() { |
194 | 0 | return this.maritalStatusCode |
195 | |
} |
196 | |
String getPrimaryLanguageCodeUnmasked() { |
197 | 0 | return this.primaryLanguageCode |
198 | |
} |
199 | |
String getSecondaryLanguageCodeUnmasked() { |
200 | 0 | return this.secondaryLanguageCode |
201 | |
} |
202 | |
String getCountryOfBirthCodeUnmasked() { |
203 | 0 | return this.countryOfBirthCode |
204 | |
} |
205 | |
String getBirthStateCodeUnmasked() { |
206 | 0 | return this.birthStateCode |
207 | |
} |
208 | |
String getCityOfBirthUnmasked() { |
209 | 0 | return this.cityOfBirth |
210 | |
} |
211 | |
String getGeographicOriginUnmasked() { |
212 | 0 | return this.geographicOrigin |
213 | |
} |
214 | |
} |