1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kim.bo.entity.impl; |
17 | |
|
18 | |
import java.util.LinkedHashMap; |
19 | |
|
20 | |
import javax.persistence.Column; |
21 | |
import javax.persistence.Entity; |
22 | |
import javax.persistence.FetchType; |
23 | |
import javax.persistence.Id; |
24 | |
import javax.persistence.JoinColumn; |
25 | |
import javax.persistence.ManyToOne; |
26 | |
import javax.persistence.Table; |
27 | |
import javax.persistence.Transient; |
28 | |
|
29 | |
import org.kuali.rice.kim.bo.entity.KimEntityAddress; |
30 | |
import org.kuali.rice.kim.bo.entity.KimEntityPrivacyPreferences; |
31 | |
import org.kuali.rice.kim.bo.reference.AddressType; |
32 | |
import org.kuali.rice.kim.bo.reference.impl.AddressTypeImpl; |
33 | |
import org.kuali.rice.kim.service.KIMServiceLocator; |
34 | |
import org.kuali.rice.kim.util.KimConstants; |
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
@Entity |
40 | |
@Table(name = "KRIM_ENTITY_ADDR_T") |
41 | 0 | public class KimEntityAddressImpl extends KimDefaultableEntityDataBase implements KimEntityAddress { |
42 | |
|
43 | |
private static final long serialVersionUID = 1L; |
44 | |
|
45 | |
@Id |
46 | |
@Column(name = "ENTITY_ADDR_ID") |
47 | |
protected String entityAddressId; |
48 | |
|
49 | |
@Column(name = "ENTITY_ID") |
50 | |
protected String entityId; |
51 | |
|
52 | |
@Column(name = "ADDR_TYP_CD") |
53 | |
protected String addressTypeCode; |
54 | |
|
55 | |
@Column(name = "ENT_TYP_CD") |
56 | |
protected String entityTypeCode; |
57 | |
|
58 | |
@Column(name = "CITY_NM") |
59 | |
protected String cityName; |
60 | |
|
61 | |
@Column(name = "POSTAL_STATE_CD") |
62 | |
protected String stateCode; |
63 | |
|
64 | |
@Column(name = "POSTAL_CD") |
65 | |
protected String postalCode; |
66 | |
|
67 | |
@Column(name = "POSTAL_CNTRY_CD") |
68 | |
protected String countryCode; |
69 | |
|
70 | |
@Column(name = "ADDR_LINE_1") |
71 | |
protected String line1; |
72 | |
|
73 | |
@Column(name = "ADDR_LINE_2") |
74 | |
protected String line2; |
75 | |
|
76 | |
@Column(name = "ADDR_LINE_3") |
77 | |
protected String line3; |
78 | |
|
79 | |
@ManyToOne(targetEntity=AddressTypeImpl.class, fetch = FetchType.EAGER, cascade = {}) |
80 | |
@JoinColumn(name = "ADDR_TYP_CD", insertable = false, updatable = false) |
81 | |
protected AddressType addressType; |
82 | |
|
83 | |
@Transient |
84 | |
protected Boolean suppressAddress; |
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | |
|
92 | |
|
93 | |
|
94 | |
public String getAddressTypeCode() { |
95 | 0 | return addressTypeCode; |
96 | |
} |
97 | |
|
98 | |
|
99 | |
|
100 | |
|
101 | |
public String getCityName() { |
102 | 0 | if (isSuppressAddress()) { |
103 | 0 | return KimConstants.RESTRICTED_DATA_MASK; |
104 | |
} |
105 | 0 | return cityName; |
106 | |
} |
107 | |
|
108 | |
|
109 | |
|
110 | |
|
111 | |
|
112 | |
public String getCountryCode() { |
113 | 0 | if (isSuppressAddress()) { |
114 | 0 | return "XX"; |
115 | |
} |
116 | 0 | return countryCode; |
117 | |
} |
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
|
123 | |
|
124 | |
public String getEntityAddressId() { |
125 | 0 | return entityAddressId; |
126 | |
} |
127 | |
|
128 | |
|
129 | |
|
130 | |
|
131 | |
public String getLine1() { |
132 | 0 | if (isSuppressAddress()) { |
133 | 0 | return KimConstants.RESTRICTED_DATA_MASK; |
134 | |
} |
135 | 0 | return line1; |
136 | |
} |
137 | |
|
138 | |
|
139 | |
|
140 | |
|
141 | |
public String getLine2() { |
142 | 0 | if (isSuppressAddress()) { |
143 | 0 | return KimConstants.RESTRICTED_DATA_MASK; |
144 | |
} |
145 | 0 | return line2; |
146 | |
} |
147 | |
|
148 | |
|
149 | |
|
150 | |
|
151 | |
public String getLine3() { |
152 | 0 | if (isSuppressAddress()) { |
153 | 0 | return KimConstants.RESTRICTED_DATA_MASK; |
154 | |
} |
155 | 0 | return line3; |
156 | |
} |
157 | |
|
158 | |
|
159 | |
|
160 | |
|
161 | |
public String getPostalCode() { |
162 | 0 | if (isSuppressAddress()) { |
163 | 0 | return "00000"; |
164 | |
} |
165 | 0 | return postalCode; |
166 | |
} |
167 | |
|
168 | |
|
169 | |
|
170 | |
|
171 | |
public String getStateCode() { |
172 | 0 | if (isSuppressAddress()) { |
173 | 0 | return "XX"; |
174 | |
} |
175 | 0 | return stateCode; |
176 | |
} |
177 | |
|
178 | |
|
179 | |
|
180 | |
|
181 | |
public void setAddressTypeCode(String addressTypeCode) { |
182 | 0 | this.addressTypeCode = addressTypeCode; |
183 | 0 | } |
184 | |
|
185 | |
|
186 | |
|
187 | |
|
188 | |
public void setCityName(String cityName) { |
189 | 0 | this.cityName = cityName; |
190 | 0 | } |
191 | |
|
192 | |
|
193 | |
|
194 | |
|
195 | |
public void setCountryCode(String countryCode) { |
196 | 0 | this.countryCode = countryCode; |
197 | 0 | } |
198 | |
|
199 | |
|
200 | |
|
201 | |
|
202 | |
public void setLine1(String line1) { |
203 | 0 | this.line1 = line1; |
204 | 0 | } |
205 | |
|
206 | |
|
207 | |
|
208 | |
|
209 | |
public void setLine2(String line2) { |
210 | 0 | this.line2 = line2; |
211 | 0 | } |
212 | |
|
213 | |
|
214 | |
|
215 | |
|
216 | |
public void setLine3(String line3) { |
217 | 0 | this.line3 = line3; |
218 | 0 | } |
219 | |
|
220 | |
|
221 | |
|
222 | |
|
223 | |
public void setPostalCode(String postalCode) { |
224 | 0 | this.postalCode = postalCode; |
225 | 0 | } |
226 | |
|
227 | |
|
228 | |
|
229 | |
|
230 | |
public void setStateCode(String stateCode) { |
231 | 0 | this.stateCode = stateCode; |
232 | 0 | } |
233 | |
|
234 | |
|
235 | |
|
236 | |
|
237 | |
public String getEntityTypeCode() { |
238 | 0 | return entityTypeCode; |
239 | |
} |
240 | |
|
241 | |
|
242 | |
|
243 | |
|
244 | |
public void setEntityTypeCode(String entityTypeCode) { |
245 | 0 | this.entityTypeCode = entityTypeCode; |
246 | 0 | } |
247 | |
|
248 | |
public String getEntityId() { |
249 | 0 | return this.entityId; |
250 | |
} |
251 | |
|
252 | |
public void setEntityId(String entityId) { |
253 | 0 | this.entityId = entityId; |
254 | 0 | } |
255 | |
|
256 | |
public void setEntityAddressId(String entityAddressId) { |
257 | 0 | this.entityAddressId = entityAddressId; |
258 | 0 | } |
259 | |
|
260 | |
public AddressType getAddressType() { |
261 | 0 | return this.addressType; |
262 | |
} |
263 | |
|
264 | |
public void setAddressType(AddressType addressType) { |
265 | 0 | this.addressType = addressType; |
266 | 0 | } |
267 | |
|
268 | |
|
269 | |
|
270 | |
|
271 | |
@SuppressWarnings("unchecked") |
272 | |
@Override |
273 | |
protected LinkedHashMap toStringMapper() { |
274 | 0 | LinkedHashMap m = new LinkedHashMap(); |
275 | 0 | m.put("entityAddressId", entityAddressId); |
276 | 0 | m.put("entityTypeCode", entityTypeCode); |
277 | 0 | m.put("entityId", entityId); |
278 | 0 | return m; |
279 | |
} |
280 | |
|
281 | |
|
282 | |
|
283 | |
|
284 | |
public boolean isSuppressAddress() { |
285 | 0 | if (suppressAddress != null) { |
286 | 0 | return suppressAddress.booleanValue(); |
287 | |
} |
288 | 0 | KimEntityPrivacyPreferences privacy = KIMServiceLocator.getIdentityService().getEntityPrivacyPreferences(getEntityId()); |
289 | |
|
290 | 0 | suppressAddress = false; |
291 | 0 | if (privacy != null) { |
292 | 0 | suppressAddress = privacy.isSuppressAddress(); |
293 | |
} |
294 | 0 | return suppressAddress.booleanValue(); |
295 | |
} |
296 | |
|
297 | |
|
298 | |
|
299 | |
|
300 | |
public String getCityNameUnmasked() { |
301 | 0 | return this.cityName; |
302 | |
} |
303 | |
|
304 | |
|
305 | |
|
306 | |
|
307 | |
public String getCountryCodeUnmasked() { |
308 | 0 | return this.countryCode; |
309 | |
} |
310 | |
|
311 | |
|
312 | |
|
313 | |
|
314 | |
public String getLine1Unmasked() { |
315 | 0 | return this.line1; |
316 | |
} |
317 | |
|
318 | |
|
319 | |
|
320 | |
|
321 | |
public String getLine2Unmasked() { |
322 | 0 | return this.line2; |
323 | |
} |
324 | |
|
325 | |
|
326 | |
|
327 | |
|
328 | |
public String getLine3Unmasked() { |
329 | 0 | return this.line3; |
330 | |
} |
331 | |
|
332 | |
|
333 | |
|
334 | |
|
335 | |
public String getPostalCodeUnmasked() { |
336 | 0 | return this.postalCode; |
337 | |
} |
338 | |
|
339 | |
|
340 | |
|
341 | |
|
342 | |
public String getStateCodeUnmasked() { |
343 | 0 | return this.stateCode; |
344 | |
} |
345 | |
} |