1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kim.api.identity.phone; |
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 | 0 | @XmlRootElement(name = EntityPhone.Constants.ROOT_ELEMENT_NAME) |
36 | |
@XmlAccessorType(XmlAccessType.NONE) |
37 | |
@XmlType(name = EntityPhone.Constants.TYPE_NAME, propOrder = { |
38 | |
EntityPhone.Elements.ID, |
39 | |
EntityPhone.Elements.ENTITY_TYPE_CODE, |
40 | |
EntityPhone.Elements.ENTITY_ID, |
41 | |
EntityPhone.Elements.PHONE_TYPE, |
42 | |
EntityPhone.Elements.COUNTRY_CODE, |
43 | |
EntityPhone.Elements.PHONE_NUMBER, |
44 | |
EntityPhone.Elements.EXTENSION_NUMBER, |
45 | |
EntityPhone.Elements.FORMATTED_PHONE_NUMBER, |
46 | |
EntityPhone.Elements.COUNTRY_CODE_UNMASKED, |
47 | |
EntityPhone.Elements.PHONE_NUMBER_UNMASKED, |
48 | |
EntityPhone.Elements.EXTENSION_NUMBER_UNMASKED, |
49 | |
EntityPhone.Elements.FORMATTED_PHONE_NUMBER_UNMASKED, |
50 | |
EntityPhone.Elements.SUPPRESS_PHONE, |
51 | |
EntityPhone.Elements.DEFAULT_VALUE, |
52 | |
EntityPhone.Elements.ACTIVE, |
53 | |
CoreConstants.CommonElements.VERSION_NUMBER, |
54 | |
CoreConstants.CommonElements.OBJECT_ID, |
55 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
56 | |
}) |
57 | 0 | public final class EntityPhone extends AbstractDataTransferObject |
58 | |
implements EntityPhoneContract |
59 | |
{ |
60 | |
|
61 | |
@XmlElement(name = Elements.ID, required = false) |
62 | |
private final String id; |
63 | |
@XmlElement(name = Elements.ENTITY_TYPE_CODE, required = false) |
64 | |
private final String entityTypeCode; |
65 | |
@XmlElement(name = Elements.ENTITY_ID, required = false) |
66 | |
private final String entityId; |
67 | |
@XmlElement(name = Elements.PHONE_TYPE, required = false) |
68 | |
private final CodedAttribute phoneType; |
69 | |
@XmlElement(name = Elements.PHONE_NUMBER, required = false) |
70 | |
private final String phoneNumber; |
71 | |
@XmlElement(name = Elements.EXTENSION_NUMBER, required = false) |
72 | |
private final String extensionNumber; |
73 | |
@XmlElement(name = Elements.COUNTRY_CODE, required = false) |
74 | |
private final String countryCode; |
75 | |
@XmlElement(name = Elements.PHONE_NUMBER_UNMASKED, required = false) |
76 | |
private final String phoneNumberUnmasked; |
77 | |
@XmlElement(name = Elements.EXTENSION_NUMBER_UNMASKED, required = false) |
78 | |
private final String extensionNumberUnmasked; |
79 | |
@XmlElement(name = Elements.COUNTRY_CODE_UNMASKED, required = false) |
80 | |
private final String countryCodeUnmasked; |
81 | |
@XmlElement(name = Elements.FORMATTED_PHONE_NUMBER, required = false) |
82 | |
private final String formattedPhoneNumber; |
83 | |
@XmlElement(name = Elements.FORMATTED_PHONE_NUMBER_UNMASKED, required = false) |
84 | |
private final String formattedPhoneNumberUnmasked; |
85 | |
@XmlElement(name = Elements.SUPPRESS_PHONE, required = false) |
86 | |
private final boolean suppressPhone; |
87 | |
@XmlElement(name = Elements.DEFAULT_VALUE, required = false) |
88 | |
private final boolean defaultValue; |
89 | |
@XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false) |
90 | |
private final Long versionNumber; |
91 | |
@XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false) |
92 | |
private final String objectId; |
93 | |
@XmlElement(name = Elements.ACTIVE, required = false) |
94 | |
private final boolean active; |
95 | 0 | @SuppressWarnings("unused") |
96 | |
@XmlAnyElement |
97 | |
private final Collection<Element> _futureElements = null; |
98 | |
|
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | 0 | private EntityPhone() { |
104 | 0 | this.id = null; |
105 | 0 | this.entityId = null; |
106 | 0 | this.entityTypeCode = null; |
107 | 0 | this.phoneType = null; |
108 | 0 | this.phoneNumber = null; |
109 | 0 | this.extensionNumber = null; |
110 | 0 | this.countryCode = null; |
111 | 0 | this.phoneNumberUnmasked = null; |
112 | 0 | this.extensionNumberUnmasked = null; |
113 | 0 | this.countryCodeUnmasked = null; |
114 | 0 | this.formattedPhoneNumber = null; |
115 | 0 | this.formattedPhoneNumberUnmasked = null; |
116 | 0 | this.suppressPhone = false; |
117 | 0 | this.defaultValue = false; |
118 | 0 | this.versionNumber = null; |
119 | 0 | this.objectId = null; |
120 | 0 | this.active = false; |
121 | 0 | } |
122 | |
|
123 | 0 | private EntityPhone(Builder builder) { |
124 | 0 | this.id = builder.getId(); |
125 | 0 | this.entityId = builder.getEntityId(); |
126 | 0 | this.entityTypeCode = builder.getEntityTypeCode(); |
127 | 0 | this.phoneType = (builder.getPhoneType() != null) ? builder.getPhoneType().build() : null; |
128 | 0 | this.phoneNumber = builder.getPhoneNumber(); |
129 | 0 | this.extensionNumber = builder.getExtensionNumber(); |
130 | 0 | this.countryCode = builder.getCountryCode(); |
131 | 0 | this.phoneNumberUnmasked = builder.getPhoneNumberUnmasked(); |
132 | 0 | this.extensionNumberUnmasked = builder.getExtensionNumberUnmasked(); |
133 | 0 | this.countryCodeUnmasked = builder.getCountryCodeUnmasked(); |
134 | 0 | this.formattedPhoneNumber = builder.getFormattedPhoneNumber(); |
135 | 0 | this.formattedPhoneNumberUnmasked = builder.getFormattedPhoneNumberUnmasked(); |
136 | 0 | this.suppressPhone = builder.isSuppressPhone(); |
137 | 0 | this.defaultValue = builder.isDefaultValue(); |
138 | 0 | this.versionNumber = builder.getVersionNumber(); |
139 | 0 | this.objectId = builder.getObjectId(); |
140 | 0 | this.active = builder.isActive(); |
141 | 0 | } |
142 | |
|
143 | |
@Override |
144 | |
public String getId() { |
145 | 0 | return this.id; |
146 | |
} |
147 | |
|
148 | |
@Override |
149 | |
public String getEntityId() { |
150 | 0 | return this.entityId; |
151 | |
} |
152 | |
|
153 | |
@Override |
154 | |
public String getEntityTypeCode() { |
155 | 0 | return this.entityTypeCode; |
156 | |
} |
157 | |
|
158 | |
@Override |
159 | |
public CodedAttribute getPhoneType() { |
160 | 0 | return this.phoneType; |
161 | |
} |
162 | |
|
163 | |
@Override |
164 | |
public String getPhoneNumber() { |
165 | 0 | return this.phoneNumber; |
166 | |
} |
167 | |
|
168 | |
@Override |
169 | |
public String getExtensionNumber() { |
170 | 0 | return this.extensionNumber; |
171 | |
} |
172 | |
|
173 | |
@Override |
174 | |
public String getCountryCode() { |
175 | 0 | return this.countryCode; |
176 | |
} |
177 | |
|
178 | |
@Override |
179 | |
public String getPhoneNumberUnmasked() { |
180 | 0 | return this.phoneNumberUnmasked; |
181 | |
} |
182 | |
|
183 | |
@Override |
184 | |
public String getExtensionNumberUnmasked() { |
185 | 0 | return this.extensionNumberUnmasked; |
186 | |
} |
187 | |
|
188 | |
@Override |
189 | |
public String getCountryCodeUnmasked() { |
190 | 0 | return this.countryCodeUnmasked; |
191 | |
} |
192 | |
|
193 | |
@Override |
194 | |
public String getFormattedPhoneNumber() { |
195 | 0 | return this.formattedPhoneNumber; |
196 | |
} |
197 | |
|
198 | |
@Override |
199 | |
public String getFormattedPhoneNumberUnmasked() { |
200 | 0 | return this.formattedPhoneNumberUnmasked; |
201 | |
} |
202 | |
|
203 | |
@Override |
204 | |
public boolean isSuppressPhone() { |
205 | 0 | return this.suppressPhone; |
206 | |
} |
207 | |
|
208 | |
@Override |
209 | |
public boolean isDefaultValue() { |
210 | 0 | return this.defaultValue; |
211 | |
} |
212 | |
|
213 | |
@Override |
214 | |
public Long getVersionNumber() { |
215 | 0 | return this.versionNumber; |
216 | |
} |
217 | |
|
218 | |
@Override |
219 | |
public String getObjectId() { |
220 | 0 | return this.objectId; |
221 | |
} |
222 | |
|
223 | |
@Override |
224 | |
public boolean isActive() { |
225 | 0 | return this.active; |
226 | |
} |
227 | |
|
228 | |
|
229 | |
|
230 | |
|
231 | |
|
232 | 0 | public final static class Builder |
233 | |
implements Serializable, ModelBuilder, EntityPhoneContract |
234 | |
{ |
235 | |
|
236 | |
private String id; |
237 | |
private String entityId; |
238 | |
private String entityTypeCode; |
239 | |
private CodedAttribute.Builder phoneType; |
240 | |
|
241 | |
|
242 | |
|
243 | |
private String phoneNumberUnmasked; |
244 | |
private String extensionNumberUnmasked; |
245 | |
private String countryCodeUnmasked; |
246 | |
|
247 | |
|
248 | |
private boolean suppressPhone; |
249 | |
private boolean defaultValue; |
250 | |
private Long versionNumber; |
251 | |
private String objectId; |
252 | |
private boolean active; |
253 | |
|
254 | 0 | private Builder() { |
255 | |
|
256 | 0 | } |
257 | |
|
258 | |
public static Builder create() { |
259 | 0 | return new Builder(); |
260 | |
} |
261 | |
|
262 | |
public static Builder create(EntityPhoneContract contract) { |
263 | 0 | if (contract == null) { |
264 | 0 | throw new IllegalArgumentException("contract was null"); |
265 | |
} |
266 | 0 | Builder builder = create(); |
267 | 0 | builder.setId(contract.getId()); |
268 | 0 | builder.setEntityId(contract.getEntityId()); |
269 | 0 | builder.setEntityTypeCode(contract.getEntityTypeCode()); |
270 | 0 | builder.setSuppressPhone(contract.isSuppressPhone()); |
271 | 0 | if (contract.getPhoneType() != null) { |
272 | 0 | builder.setPhoneType(CodedAttribute.Builder.create(contract.getPhoneType())); |
273 | |
} |
274 | 0 | builder.setPhoneNumber(contract.getPhoneNumberUnmasked()); |
275 | 0 | builder.setExtensionNumber(contract.getExtensionNumberUnmasked()); |
276 | 0 | builder.setCountryCode(contract.getCountryCodeUnmasked()); |
277 | 0 | builder.setDefaultValue(contract.isDefaultValue()); |
278 | 0 | builder.setVersionNumber(contract.getVersionNumber()); |
279 | 0 | builder.setObjectId(contract.getObjectId()); |
280 | 0 | builder.setActive(contract.isActive()); |
281 | 0 | return builder; |
282 | |
} |
283 | |
|
284 | |
public EntityPhone build() { |
285 | 0 | return new EntityPhone(this); |
286 | |
} |
287 | |
|
288 | |
@Override |
289 | |
public String getId() { |
290 | 0 | return this.id; |
291 | |
} |
292 | |
|
293 | |
@Override |
294 | |
public String getEntityTypeCode() { |
295 | 0 | return this.entityTypeCode; |
296 | |
} |
297 | |
|
298 | |
@Override |
299 | |
public String getEntityId() { |
300 | 0 | return this.entityId; |
301 | |
} |
302 | |
|
303 | |
@Override |
304 | |
public CodedAttribute.Builder getPhoneType() { |
305 | 0 | return this.phoneType; |
306 | |
} |
307 | |
|
308 | |
@Override |
309 | |
public String getPhoneNumber() { |
310 | 0 | if (isSuppressPhone()) { |
311 | 0 | return KimApiConstants.RestrictedMasks.RESTRICTED_DATA_MASK_PHONE; |
312 | |
} |
313 | 0 | return this.phoneNumberUnmasked; |
314 | |
} |
315 | |
|
316 | |
@Override |
317 | |
public String getExtensionNumber() { |
318 | 0 | if (isSuppressPhone()) { |
319 | 0 | return KimApiConstants.RestrictedMasks.RESTRICTED_DATA_MASK; |
320 | |
} |
321 | 0 | return this.extensionNumberUnmasked; |
322 | |
} |
323 | |
|
324 | |
@Override |
325 | |
public String getCountryCode() { |
326 | 0 | if (isSuppressPhone()) { |
327 | 0 | return KimApiConstants.RestrictedMasks.RESTRICTED_DATA_MASK_CODE; |
328 | |
} |
329 | 0 | return this.countryCodeUnmasked; |
330 | |
} |
331 | |
|
332 | |
@Override |
333 | |
public String getPhoneNumberUnmasked() { |
334 | 0 | return this.phoneNumberUnmasked; |
335 | |
} |
336 | |
|
337 | |
@Override |
338 | |
public String getExtensionNumberUnmasked() { |
339 | 0 | return this.extensionNumberUnmasked; |
340 | |
} |
341 | |
|
342 | |
@Override |
343 | |
public String getCountryCodeUnmasked() { |
344 | 0 | return this.countryCodeUnmasked; |
345 | |
} |
346 | |
|
347 | |
@Override |
348 | |
public String getFormattedPhoneNumber() { |
349 | 0 | if (isSuppressPhone()) { |
350 | 0 | return KimApiConstants.RestrictedMasks.RESTRICTED_DATA_MASK; |
351 | |
} |
352 | 0 | return this.getFormattedPhoneNumberUnmasked(); |
353 | |
} |
354 | |
|
355 | |
@Override |
356 | |
public String getFormattedPhoneNumberUnmasked() { |
357 | 0 | StringBuffer sb = new StringBuffer( 30 ); |
358 | |
|
359 | |
|
360 | |
|
361 | 0 | sb.append( this.phoneNumberUnmasked ); |
362 | 0 | if ( StringUtils.isNotBlank( this.extensionNumberUnmasked) ) { |
363 | 0 | sb.append( " x" ); |
364 | 0 | sb.append( this.extensionNumberUnmasked ); |
365 | |
} |
366 | |
|
367 | 0 | return sb.toString(); |
368 | |
} |
369 | |
|
370 | |
@Override |
371 | |
public boolean isSuppressPhone() { |
372 | 0 | return this.suppressPhone; |
373 | |
} |
374 | |
|
375 | |
@Override |
376 | |
public boolean isDefaultValue() { |
377 | 0 | return this.defaultValue; |
378 | |
} |
379 | |
|
380 | |
@Override |
381 | |
public Long getVersionNumber() { |
382 | 0 | return this.versionNumber; |
383 | |
} |
384 | |
|
385 | |
@Override |
386 | |
public String getObjectId() { |
387 | 0 | return this.objectId; |
388 | |
} |
389 | |
|
390 | |
@Override |
391 | |
public boolean isActive() { |
392 | 0 | return this.active; |
393 | |
} |
394 | |
|
395 | |
public void setId(String id) { |
396 | 0 | if (StringUtils.isWhitespace(id)) { |
397 | 0 | throw new IllegalArgumentException("id is blank"); |
398 | |
} |
399 | 0 | this.id = id; |
400 | 0 | } |
401 | |
|
402 | |
public void setEntityTypeCode(String entityTypeCode) { |
403 | 0 | this.entityTypeCode = entityTypeCode; |
404 | 0 | } |
405 | |
|
406 | |
public void setEntityId(String entityId) { |
407 | 0 | this.entityId = entityId; |
408 | 0 | } |
409 | |
|
410 | |
public void setPhoneType(CodedAttribute.Builder phoneType) { |
411 | 0 | this.phoneType = phoneType; |
412 | 0 | } |
413 | |
|
414 | |
public void setPhoneNumber(String phoneNumber) { |
415 | 0 | this.phoneNumberUnmasked = phoneNumber; |
416 | 0 | } |
417 | |
|
418 | |
public void setExtensionNumber(String extensionNumber) { |
419 | 0 | this.extensionNumberUnmasked = extensionNumber; |
420 | 0 | } |
421 | |
|
422 | |
public void setCountryCode(String countryCode) { |
423 | 0 | this.countryCodeUnmasked = countryCode; |
424 | 0 | } |
425 | |
|
426 | |
private void setSuppressPhone(boolean suppressPhone) { |
427 | 0 | this.suppressPhone = suppressPhone; |
428 | 0 | } |
429 | |
|
430 | |
public void setDefaultValue(boolean defaultValue) { |
431 | 0 | this.defaultValue = defaultValue; |
432 | 0 | } |
433 | |
|
434 | |
public void setVersionNumber(Long versionNumber) { |
435 | 0 | this.versionNumber = versionNumber; |
436 | 0 | } |
437 | |
|
438 | |
public void setObjectId(String objectId) { |
439 | 0 | this.objectId = objectId; |
440 | 0 | } |
441 | |
|
442 | |
public void setActive(boolean active) { |
443 | 0 | this.active = active; |
444 | 0 | } |
445 | |
|
446 | |
} |
447 | |
|
448 | |
|
449 | |
|
450 | |
|
451 | |
|
452 | |
|
453 | 0 | static class Constants { |
454 | |
|
455 | |
final static String ROOT_ELEMENT_NAME = "entityPhone"; |
456 | |
final static String TYPE_NAME = "EntityPhoneType"; |
457 | |
} |
458 | |
|
459 | |
|
460 | |
|
461 | |
|
462 | |
|
463 | |
|
464 | 0 | static class Elements { |
465 | |
|
466 | |
final static String ID = "id"; |
467 | |
final static String ENTITY_TYPE_CODE = "entityTypeCode"; |
468 | |
final static String ENTITY_ID = "entityId"; |
469 | |
final static String PHONE_TYPE = "phoneType"; |
470 | |
final static String PHONE_NUMBER = "phoneNumber"; |
471 | |
final static String EXTENSION_NUMBER = "extensionNumber"; |
472 | |
final static String COUNTRY_CODE = "countryCode"; |
473 | |
final static String PHONE_NUMBER_UNMASKED = "phoneNumberUnmasked"; |
474 | |
final static String EXTENSION_NUMBER_UNMASKED = "extensionNumberUnmasked"; |
475 | |
final static String COUNTRY_CODE_UNMASKED = "countryCodeUnmasked"; |
476 | |
final static String FORMATTED_PHONE_NUMBER = "formattedPhoneNumber"; |
477 | |
final static String FORMATTED_PHONE_NUMBER_UNMASKED = "formattedPhoneNumberUnmasked"; |
478 | |
final static String SUPPRESS_PHONE = "suppressPhone"; |
479 | |
final static String DEFAULT_VALUE = "defaultValue"; |
480 | |
final static String ACTIVE = "active"; |
481 | |
|
482 | |
} |
483 | |
|
484 | |
} |