1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kim.impl.identity.address;
17
18 import java.sql.Timestamp;
19
20 import javax.persistence.Column;
21 import javax.persistence.MappedSuperclass;
22 import javax.persistence.Transient;
23
24 import org.joda.time.DateTime;
25 import org.kuali.rice.kim.api.KimApiConstants;
26 import org.kuali.rice.kim.api.identity.address.EntityAddressContract;
27 import org.kuali.rice.kim.api.identity.privacy.EntityPrivacyPreferences;
28 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
29 import org.kuali.rice.krad.bo.DataObjectBase;
30 import org.kuali.rice.krad.data.jpa.converters.BooleanYNConverter;
31
32 @MappedSuperclass
33 public abstract class EntityAddressBase extends DataObjectBase implements EntityAddressContract {
34 private static final long serialVersionUID = -7550286656495828391L;
35
36 @Column(name = "ENTITY_ID")
37 private String entityId;
38 @Column(name = "ADDR_TYP_CD")
39 private String addressTypeCode;
40 @Column(name = "ENT_TYP_CD")
41 private String entityTypeCode;
42 @Column(name = "CITY")
43 private String city;
44 @Column(name = "STATE_PVC_CD")
45 private String stateProvinceCode;
46 @Column(name = "POSTAL_CD")
47 private String postalCode;
48 @Column(name = "POSTAL_CNTRY_CD")
49 private String countryCode;
50 @Column(name = "ATTN_LINE")
51 private String attentionLine;
52 @Column(name = "ADDR_LINE_1")
53 private String line1;
54 @Column(name = "ADDR_LINE_2")
55 private String line2;
56 @Column(name = "ADDR_LINE_3")
57 private String line3;
58 @javax.persistence.Convert(converter=BooleanYNConverter.class)
59 @Column(name = "DFLT_IND")
60 private boolean defaultValue;
61 @javax.persistence.Convert(converter=BooleanYNConverter.class)
62 @Column(name = "ACTV_IND")
63 private boolean active;
64 @Column(name = "ADDR_FMT")
65 private String addressFormat;
66 @Column(name = "MOD_DT")
67 private Timestamp modifiedDate;
68 @Column(name = "VALID_DT")
69 private Timestamp validatedDate;
70 @javax.persistence.Convert(converter=BooleanYNConverter.class)
71 @Column(name = "VALID_IND")
72 private boolean validated;
73 @Column(name = "NOTE_MSG")
74 private String noteMessage;
75 @Transient private boolean suppressAddress;
76
77
78 @Override
79 public boolean isSuppressAddress() {
80 try {
81 EntityPrivacyPreferences privacy =
82 KimApiServiceLocator.getIdentityService().getEntityPrivacyPreferences(getEntityId());
83 if (privacy != null) {
84 this.suppressAddress = privacy.isSuppressAddress();
85 } else {
86 this.suppressAddress = false;
87 }
88 } catch (NullPointerException e) {
89 return false;
90 } catch (ClassCastException c) {
91 return false;
92 }
93
94
95 return suppressAddress;
96 }
97
98 @Override
99 public String getAttentionLine() {
100 if (isSuppressAddress()) {
101 return KimApiConstants.RestrictedMasks.RESTRICTED_DATA_MASK;
102 }
103
104 return this.attentionLine;
105 }
106
107 @Override
108 public String getLine1() {
109 if (isSuppressAddress()) {
110 return KimApiConstants.RestrictedMasks.RESTRICTED_DATA_MASK;
111 }
112
113 return this.line1;
114 }
115
116 @Override
117 public String getLine2() {
118 if (isSuppressAddress()) {
119 return KimApiConstants.RestrictedMasks.RESTRICTED_DATA_MASK;
120 }
121
122 return this.line2;
123 }
124
125 @Override
126 public String getLine3() {
127 if (isSuppressAddress()) {
128 return KimApiConstants.RestrictedMasks.RESTRICTED_DATA_MASK;
129 }
130
131 return this.line3;
132 }
133
134 @Override
135 public String getCity() {
136 if (isSuppressAddress()) {
137 return KimApiConstants.RestrictedMasks.RESTRICTED_DATA_MASK;
138 }
139
140 return this.city;
141 }
142
143 @Override
144 public String getStateProvinceCode() {
145 if (isSuppressAddress()) {
146 return KimApiConstants.RestrictedMasks.RESTRICTED_DATA_MASK_CODE;
147 }
148
149 return this.stateProvinceCode;
150 }
151
152 @Override
153 public String getPostalCode() {
154 if (isSuppressAddress()) {
155 return KimApiConstants.RestrictedMasks.RESTRICTED_DATA_MASK_ZIP;
156 }
157
158 return this.postalCode;
159 }
160
161 @Override
162 public String getCountryCode() {
163 if (isSuppressAddress()) {
164 return KimApiConstants.RestrictedMasks.RESTRICTED_DATA_MASK_CODE;
165 }
166
167 return this.countryCode;
168 }
169
170 @Override
171 public String getAttentionLineUnmasked() {
172 return attentionLine;
173 }
174
175 @Override
176 public String getLine1Unmasked() {
177 return line1;
178 }
179
180 @Override
181 public String getLine2Unmasked() {
182 return line2;
183 }
184
185 @Override
186 public String getLine3Unmasked() {
187 return line3;
188 }
189
190 @Override
191 public String getCityUnmasked() {
192 return city;
193 }
194
195 @Override
196 public String getStateProvinceCodeUnmasked() {
197 return stateProvinceCode;
198 }
199
200 @Override
201 public String getPostalCodeUnmasked() {
202 return postalCode;
203 }
204
205 @Override
206 public String getCountryCodeUnmasked() {
207 return countryCode;
208 }
209
210 @Override
211 public DateTime getModifiedDate() {
212 return modifiedDate != null ? new DateTime(modifiedDate.getTime()) : null;
213 }
214
215 public Timestamp getModifiedTimestamp() {
216 return modifiedDate;
217 }
218
219 @Override
220 public DateTime getValidatedDate() {
221 return validatedDate != null ? new DateTime(validatedDate.getTime()) : null;
222 }
223
224 public Timestamp getValidatedTimestamp() {
225 return validatedDate;
226 }
227
228 @Override
229 public String getEntityId() {
230 return entityId;
231 }
232
233 public void setEntityId(String entityId) {
234 this.entityId = entityId;
235 }
236
237 public String getAddressTypeCode() {
238 return addressTypeCode;
239 }
240
241 public void setAddressTypeCode(String addressTypeCode) {
242 this.addressTypeCode = addressTypeCode;
243 }
244
245 @Override
246 public String getEntityTypeCode() {
247 return entityTypeCode;
248 }
249
250 public void setEntityTypeCode(String entityTypeCode) {
251 this.entityTypeCode = entityTypeCode;
252 }
253
254 public void setCity(String city) {
255 this.city = city;
256 }
257
258 public void setStateProvinceCode(String stateProvinceCode) {
259 this.stateProvinceCode = stateProvinceCode;
260 }
261
262 public void setPostalCode(String postalCode) {
263 this.postalCode = postalCode;
264 }
265
266 public void setCountryCode(String countryCode) {
267 this.countryCode = countryCode;
268 }
269
270 public void setAttentionLine(String attentionLine) {
271 this.attentionLine = attentionLine;
272 }
273
274 public void setLine1(String line1) {
275 this.line1 = line1;
276 }
277
278 public void setLine2(String line2) {
279 this.line2 = line2;
280 }
281
282 public void setLine3(String line3) {
283 this.line3 = line3;
284 }
285
286 public boolean getDefaultValue() {
287 return defaultValue;
288 }
289
290 @Override
291 public boolean isDefaultValue() {
292 return defaultValue;
293 }
294
295 public void setDefaultValue(boolean defaultValue) {
296 this.defaultValue = defaultValue;
297 }
298
299 public boolean getActive() {
300 return active;
301 }
302
303 @Override
304 public boolean isActive() {
305 return active;
306 }
307
308 public void setActive(boolean active) {
309 this.active = active;
310 }
311
312 @Override
313 public String getAddressFormat() {
314 return addressFormat;
315 }
316
317 public void setAddressFormat(String addressFormat) {
318 this.addressFormat = addressFormat;
319 }
320
321 public void setModifiedDate(DateTime modifiedDate) {
322 if ( modifiedDate != null ) {
323 this.modifiedDate = new Timestamp(modifiedDate.getMillis());
324 } else {
325 this.modifiedDate = null;
326 }
327 }
328
329 public void setModifiedTimestamp( Timestamp modifiedDate ) {
330 this.modifiedDate = modifiedDate;
331 }
332
333 public void setValidatedDate(DateTime validatedDate) {
334 if ( validatedDate != null ) {
335 this.validatedDate = new Timestamp(validatedDate.getMillis());
336 } else {
337 this.validatedDate = null;
338 }
339 }
340
341 public void setValidatedTimestamp( Timestamp validatedDate ) {
342 this.validatedDate = validatedDate;
343 }
344
345 public boolean getValidated() {
346 return validated;
347 }
348
349 @Override
350 public boolean isValidated() {
351 return validated;
352 }
353
354 public void setValidated(boolean validated) {
355 this.validated = validated;
356 }
357
358 @Override
359 public String getNoteMessage() {
360 return noteMessage;
361 }
362
363 public void setNoteMessage(String noteMessage) {
364 this.noteMessage = noteMessage;
365 }
366
367 public boolean getSuppressAddress() {
368 return suppressAddress;
369 }
370
371 public void setSuppressAddress(boolean suppressAddress) {
372 this.suppressAddress = suppressAddress;
373 }
374 }