1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kim.api.identity.personal;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.core.api.CoreConstants;
20 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
21 import org.kuali.rice.core.api.mo.ModelBuilder;
22 import org.kuali.rice.kim.api.KimApiConstants;
23 import org.kuali.rice.kim.api.identity.CodedAttribute;
24 import org.w3c.dom.Element;
25
26 import javax.xml.bind.annotation.XmlAccessType;
27 import javax.xml.bind.annotation.XmlAccessorType;
28 import javax.xml.bind.annotation.XmlAnyElement;
29 import javax.xml.bind.annotation.XmlElement;
30 import javax.xml.bind.annotation.XmlRootElement;
31 import javax.xml.bind.annotation.XmlType;
32 import java.io.Serializable;
33 import java.util.Collection;
34
35 @XmlRootElement(name = EntityEthnicity.Constants.ROOT_ELEMENT_NAME)
36 @XmlAccessorType(XmlAccessType.NONE)
37 @XmlType(name = EntityEthnicity.Constants.TYPE_NAME, propOrder = {
38 EntityEthnicity.Elements.ID,
39 EntityEthnicity.Elements.ENTITY_ID,
40 EntityEthnicity.Elements.ETHNICITY_CODE,
41 EntityEthnicity.Elements.ETHNICITY_CODE_UNMASKED,
42 EntityEthnicity.Elements.SUB_ETHNICITY_CODE,
43 EntityEthnicity.Elements.SUB_ETHNICITY_CODE_UNMASKED,
44 EntityEthnicity.Elements.SUPPRESS_PERSONAL,
45 EntityEthnicity.Elements.HISPANIC_OR_LATINO,
46 EntityEthnicity.Elements.RACE_ETHNICITY_CODE,
47 EntityEthnicity.Elements.RACE_ETHNICITY_CODE_UNMASKED,
48 EntityEthnicity.Elements.LOCAL_RACE_ETHNICITY_CODE,
49 EntityEthnicity.Elements.LOCAL_RACE_ETHNICITY_CODE_UNMASKED,
50 CoreConstants.CommonElements.VERSION_NUMBER,
51 CoreConstants.CommonElements.OBJECT_ID,
52 EntityEthnicity.Elements.PERCENTAGE,
53 EntityEthnicity.Elements.PERCENTAGE_UNMASKED,
54 CoreConstants.CommonElements.FUTURE_ELEMENTS
55 })
56 public final class EntityEthnicity extends AbstractDataTransferObject
57 implements EntityEthnicityContract
58 {
59
60 @XmlElement(name = Elements.ENTITY_ID, required = false)
61 private final String entityId;
62 @XmlElement(name = Elements.ETHNICITY_CODE, required = false)
63 private final String ethnicityCode;
64 @XmlElement(name = Elements.ETHNICITY_CODE_UNMASKED, required = false)
65 private final String ethnicityCodeUnmasked;
66 @XmlElement(name = Elements.SUB_ETHNICITY_CODE, required = false)
67 private final String subEthnicityCode;
68 @XmlElement(name = Elements.SUB_ETHNICITY_CODE_UNMASKED, required = false)
69 private final String subEthnicityCodeUnmasked;
70 @XmlElement(name = Elements.SUPPRESS_PERSONAL, required = false)
71 private final boolean suppressPersonal;
72 @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
73 private final Long versionNumber;
74 @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
75 private final String objectId;
76 @XmlElement(name = Elements.ID, required = false)
77 private final String id;
78 @XmlElement(name = Elements.HISPANIC_OR_LATINO, required = false)
79 private final boolean hispanicOrLatino;
80 @XmlElement(name = Elements.RACE_ETHNICITY_CODE, required = false)
81 private final CodedAttribute raceEthnicityCode;
82 @XmlElement(name = Elements.RACE_ETHNICITY_CODE_UNMASKED, required = false)
83 private final CodedAttribute raceEthnicityCodeUnmasked;
84 @XmlElement(name = Elements.LOCAL_RACE_ETHNICITY_CODE, required = false)
85 private final String localRaceEthnicityCode;
86 @XmlElement(name = Elements.LOCAL_RACE_ETHNICITY_CODE_UNMASKED, required = false)
87 private final String localRaceEthnicityCodeUnmasked;
88 @XmlElement(name = Elements.PERCENTAGE, required = false)
89 private final Double percentage;
90 @XmlElement(name = Elements.PERCENTAGE_UNMASKED, required = false)
91 private final Double percentageUnmasked;
92 @SuppressWarnings("unused")
93 @XmlAnyElement
94 private final Collection<Element> _futureElements = null;
95
96
97
98
99
100 private EntityEthnicity() {
101 this.entityId = null;
102 this.ethnicityCode = null;
103 this.ethnicityCodeUnmasked = null;
104 this.subEthnicityCode = null;
105 this.subEthnicityCodeUnmasked = null;
106 this.suppressPersonal = false;
107 this.versionNumber = null;
108 this.objectId = null;
109 this.id = null;
110 this.hispanicOrLatino = false;
111 this.raceEthnicityCode = null;
112 this.raceEthnicityCodeUnmasked = null;
113 this.localRaceEthnicityCode = null;
114 this.localRaceEthnicityCodeUnmasked = null;
115 this.percentage = null;
116 this.percentageUnmasked = null;
117 }
118
119 private EntityEthnicity(Builder builder) {
120 this.entityId = builder.getEntityId();
121 this.ethnicityCode = builder.getEthnicityCode();
122 this.ethnicityCodeUnmasked = builder.getEthnicityCodeUnmasked();
123 this.subEthnicityCode = builder.getSubEthnicityCode();
124 this.subEthnicityCodeUnmasked = builder.getSubEthnicityCodeUnmasked();
125 this.suppressPersonal = builder.isSuppressPersonal();
126 this.versionNumber = builder.getVersionNumber();
127 this.objectId = builder.getObjectId();
128 this.id = builder.getId();
129 this.hispanicOrLatino = builder.isHispanicOrLatino();
130 this.raceEthnicityCode = builder.getRaceEthnicityCode() != null ? builder.getRaceEthnicityCode().build() : null;
131 this.raceEthnicityCodeUnmasked = builder.getRaceEthnicityCodeUnmasked() != null ? builder.getRaceEthnicityCodeUnmasked().build() : null;
132 this.localRaceEthnicityCode = builder.getLocalRaceEthnicityCode();
133 this.localRaceEthnicityCodeUnmasked = builder.getLocalRaceEthnicityCodeUnmasked();
134 this.percentage = builder.getPercentage();
135 this.percentageUnmasked = builder.getPercentageUnmasked();
136 }
137
138 @Override
139 public String getEntityId() {
140 return this.entityId;
141 }
142
143 @Override
144 public String getEthnicityCode() {
145 return this.ethnicityCode;
146 }
147
148 @Override
149 public String getEthnicityCodeUnmasked() {
150 return this.ethnicityCodeUnmasked;
151 }
152
153 @Override
154 public String getSubEthnicityCode() {
155 return this.subEthnicityCode;
156 }
157
158 @Override
159 public String getSubEthnicityCodeUnmasked() {
160 return this.subEthnicityCodeUnmasked;
161 }
162
163 @Override
164 public boolean isSuppressPersonal() {
165 return this.suppressPersonal;
166 }
167
168 @Override
169 public Long getVersionNumber() {
170 return this.versionNumber;
171 }
172
173 @Override
174 public String getObjectId() {
175 return this.objectId;
176 }
177
178 @Override
179 public String getId() {
180 return this.id;
181 }
182
183 @Override
184 public boolean isHispanicOrLatino() {
185 return this.hispanicOrLatino;
186 }
187
188 @Override
189 public CodedAttribute getRaceEthnicityCode() {
190 return this.raceEthnicityCode;
191 }
192
193 @Override
194 public CodedAttribute getRaceEthnicityCodeUnmasked() {
195 return this.raceEthnicityCodeUnmasked;
196 }
197
198 @Override
199 public String getLocalRaceEthnicityCode() {
200 return this.localRaceEthnicityCode;
201 }
202
203 @Override
204 public String getLocalRaceEthnicityCodeUnmasked() {
205 return this.localRaceEthnicityCodeUnmasked;
206 }
207
208 @Override
209 public Double getPercentage() {
210 return this.percentage;
211 }
212
213 @Override
214 public Double getPercentageUnmasked() {
215 return this.percentageUnmasked;
216 }
217
218
219
220
221
222
223 public final static class Builder
224 implements Serializable, ModelBuilder, EntityEthnicityContract
225 {
226
227 private String entityId;
228 private String ethnicityCode;
229 private String subEthnicityCode;
230 private boolean suppressPersonal;
231 private Long versionNumber;
232 private String objectId;
233 private String id;
234 private boolean hispanicOrLatino;
235 private CodedAttribute.Builder raceEthnicityCode;
236 private String localRaceEthnicityCode;
237 private Double percentage;
238
239 private Builder() { }
240
241 public static Builder create() {
242 return new Builder();
243 }
244
245 public static Builder create(EntityEthnicityContract contract) {
246 if (contract == null) {
247 throw new IllegalArgumentException("contract was null");
248 }
249 Builder builder = create();
250 builder.setEntityId(contract.getEntityId());
251 builder.setEthnicityCode(contract.getEthnicityCodeUnmasked());
252 builder.setSubEthnicityCode(contract.getSubEthnicityCodeUnmasked());
253 builder.setSuppressPersonal(contract.isSuppressPersonal());
254 builder.setVersionNumber(contract.getVersionNumber());
255 builder.setObjectId(contract.getObjectId());
256 builder.setId(contract.getId());
257 builder.setHispanicOrLatino(contract.isHispanicOrLatino());
258 if (contract.getRaceEthnicityCodeUnmasked() != null) {
259 builder.setRaceEthnicityCodes(CodedAttribute.Builder.create(contract.getRaceEthnicityCodeUnmasked()));
260 }
261 builder.setLocalRaceEthnicityCode(contract.getLocalRaceEthnicityCodeUnmasked());
262 builder.setPercentage(contract.getPercentageUnmasked());
263 return builder;
264 }
265
266 @Override
267 public EntityEthnicity build() {
268 return new EntityEthnicity(this);
269 }
270
271 @Override
272 public String getEntityId() {
273 return this.entityId;
274 }
275
276 @Override
277 public String getEthnicityCode() {
278 if (isSuppressPersonal()) {
279 return KimApiConstants.RestrictedMasks.RESTRICTED_DATA_MASK;
280 }
281 return this.ethnicityCode;
282 }
283
284 @Override
285 public String getEthnicityCodeUnmasked() {
286 return this.ethnicityCode;
287 }
288
289 @Override
290 public String getSubEthnicityCode() {
291 if (isSuppressPersonal()) {
292 return KimApiConstants.RestrictedMasks.RESTRICTED_DATA_MASK;
293 }
294 return this.subEthnicityCode;
295 }
296
297 @Override
298 public String getSubEthnicityCodeUnmasked() {
299 return this.subEthnicityCode;
300 }
301
302 @Override
303 public boolean isSuppressPersonal() {
304 return this.suppressPersonal;
305 }
306
307 @Override
308 public Long getVersionNumber() {
309 return this.versionNumber;
310 }
311
312 @Override
313 public String getObjectId() {
314 return this.objectId;
315 }
316
317 @Override
318 public String getId() {
319 return this.id;
320 }
321
322 @Override
323 public boolean isHispanicOrLatino() {
324 return this.hispanicOrLatino;
325 }
326
327 @Override
328 public CodedAttribute.Builder getRaceEthnicityCode() {
329 if (isSuppressPersonal()) {
330 return null;
331 }
332 return this.raceEthnicityCode;
333 }
334
335 @Override
336 public CodedAttribute.Builder getRaceEthnicityCodeUnmasked() {
337 return this.raceEthnicityCode;
338 }
339
340 @Override
341 public String getLocalRaceEthnicityCode() {
342 if (isSuppressPersonal()) {
343 return KimApiConstants.RestrictedMasks.RESTRICTED_DATA_MASK;
344 }
345 return this.localRaceEthnicityCode;
346 }
347
348 @Override
349 public String getLocalRaceEthnicityCodeUnmasked() {
350 return this.localRaceEthnicityCode;
351 }
352
353 @Override
354 public Double getPercentage() {
355 if (isSuppressPersonal()) {
356 return null;
357 }
358 return this.percentage;
359 }
360
361 @Override
362 public Double getPercentageUnmasked() {
363 return this.percentage;
364 }
365
366
367 public void setHispanicOrLatino(boolean hispanicOrLatino) {
368 this.hispanicOrLatino = hispanicOrLatino;
369 }
370
371 public void setRaceEthnicityCodes(CodedAttribute.Builder raceEthnicityCode) {
372 this.raceEthnicityCode = raceEthnicityCode;
373 }
374
375 public void setLocalRaceEthnicityCode(String localRaceEthnicityCode) {
376 this.localRaceEthnicityCode = localRaceEthnicityCode;
377 }
378
379 public void setEntityId(String entityId) {
380 this.entityId = entityId;
381 }
382
383 public void setEthnicityCode(String ethnicityCode) {
384 this.ethnicityCode = ethnicityCode;
385 }
386
387 public void setSubEthnicityCode(String subEthnicityCode) {
388 this.subEthnicityCode = subEthnicityCode;
389 }
390
391 private void setSuppressPersonal(boolean suppressPersonal) {
392 this.suppressPersonal = suppressPersonal;
393 }
394
395 public void setVersionNumber(Long versionNumber) {
396 this.versionNumber = versionNumber;
397 }
398
399 public void setObjectId(String objectId) {
400 this.objectId = objectId;
401 }
402
403 public void setPercentage(Double percentage) {
404 this.percentage = percentage;
405 }
406
407 public void setId(String id) {
408 if (StringUtils.isWhitespace(id)) {
409 throw new IllegalArgumentException("id is blank");
410 }
411 this.id = id;
412 }
413
414 }
415
416
417
418
419
420
421 static class Constants {
422
423 final static String ROOT_ELEMENT_NAME = "entityEthnicity";
424 final static String TYPE_NAME = "EntityEthnicityType";
425 }
426
427
428
429
430
431
432 static class Elements {
433
434 final static String ENTITY_ID = "entityId";
435 final static String ETHNICITY_CODE = "ethnicityCode";
436 final static String ETHNICITY_CODE_UNMASKED = "ethnicityCodeUnmasked";
437 final static String SUB_ETHNICITY_CODE = "subEthnicityCode";
438 final static String SUB_ETHNICITY_CODE_UNMASKED = "subEthnicityCodeUnmasked";
439 final static String SUPPRESS_PERSONAL = "suppressPersonal";
440 final static String ID = "id";
441 final static String HISPANIC_OR_LATINO = "hispanicOrLatino";
442 final static String RACE_ETHNICITY_CODE_UNMASKED = "raceEthnicityCodeUnmasked";
443 final static String RACE_ETHNICITY_CODE = "raceEthnicityCode";
444 final static String LOCAL_RACE_ETHNICITY_CODE = "localRaceEthnicityCode";
445 final static String LOCAL_RACE_ETHNICITY_CODE_UNMASKED = "localRaceEthnicityCodeUnmasked";
446 final static String PERCENTAGE = "percentage";
447 final static String PERCENTAGE_UNMASKED = "percentageUnmasked";
448 }
449
450 }