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.apache.commons.lang.StringUtils; |
30 | |
import org.kuali.rice.kim.bo.entity.KimEntityPhone; |
31 | |
import org.kuali.rice.kim.bo.entity.KimEntityPrivacyPreferences; |
32 | |
import org.kuali.rice.kim.bo.reference.PhoneType; |
33 | |
import org.kuali.rice.kim.bo.reference.impl.PhoneTypeImpl; |
34 | |
import org.kuali.rice.kim.service.KIMServiceLocator; |
35 | |
import org.kuali.rice.kim.util.KimConstants; |
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
@Entity |
41 | |
@Table(name = "KRIM_ENTITY_PHONE_T") |
42 | 0 | public class KimEntityPhoneImpl extends KimDefaultableEntityDataBase implements KimEntityPhone { |
43 | |
|
44 | |
private static final long serialVersionUID = 1L; |
45 | |
|
46 | |
@Id |
47 | |
@Column(name = "ENTITY_PHONE_ID") |
48 | |
protected String entityPhoneId; |
49 | |
|
50 | |
@Column(name = "ENTITY_ID") |
51 | |
protected String entityId; |
52 | |
|
53 | |
@Column(name = "ENT_TYP_CD") |
54 | |
protected String entityTypeCode; |
55 | |
|
56 | |
@Column(name = "PHONE_TYP_CD") |
57 | |
protected String phoneTypeCode; |
58 | |
|
59 | |
@Column(name = "PHONE_NBR") |
60 | |
protected String phoneNumber; |
61 | |
|
62 | |
@Column(name = "PHONE_EXTN_NBR") |
63 | |
protected String extensionNumber; |
64 | |
|
65 | |
@Column(name = "POSTAL_CNTRY_CD") |
66 | |
protected String countryCode; |
67 | |
|
68 | |
@ManyToOne(targetEntity=PhoneTypeImpl.class, fetch = FetchType.EAGER, cascade = {}) |
69 | |
@JoinColumn(name = "PHONE_TYP_CD", insertable = false, updatable = false) |
70 | |
protected PhoneType phoneType; |
71 | |
|
72 | |
@Transient |
73 | |
protected Boolean suppressPhone; |
74 | |
|
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
public String getCountryCode() { |
82 | 0 | if (isSuppressPhone()) { |
83 | 0 | return "XX"; |
84 | |
} |
85 | 0 | return countryCode; |
86 | |
} |
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | |
public String getEntityPhoneId() { |
92 | 0 | return entityPhoneId; |
93 | |
} |
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | |
public String getExtensionNumber() { |
99 | 0 | if (isSuppressPhone()) { |
100 | 0 | return KimConstants.RESTRICTED_DATA_MASK; |
101 | |
} |
102 | 0 | return extensionNumber; |
103 | |
} |
104 | |
|
105 | |
|
106 | |
|
107 | |
|
108 | |
public String getPhoneNumber() { |
109 | 0 | if (isSuppressPhone()) { |
110 | 0 | return "000-000-0000"; |
111 | |
} |
112 | 0 | return phoneNumber; |
113 | |
} |
114 | |
|
115 | |
|
116 | |
|
117 | |
|
118 | |
public String getPhoneTypeCode() { |
119 | 0 | return phoneTypeCode; |
120 | |
} |
121 | |
|
122 | |
|
123 | |
|
124 | |
|
125 | |
public void setCountryCode(String countryCode) { |
126 | 0 | this.countryCode = countryCode; |
127 | 0 | } |
128 | |
|
129 | |
|
130 | |
|
131 | |
|
132 | |
public void setExtensionNumber(String extensionNumber) { |
133 | 0 | this.extensionNumber = extensionNumber; |
134 | 0 | } |
135 | |
|
136 | |
|
137 | |
|
138 | |
|
139 | |
public void setPhoneNumber(String phoneNumber) { |
140 | 0 | this.phoneNumber = phoneNumber; |
141 | 0 | } |
142 | |
|
143 | |
|
144 | |
|
145 | |
|
146 | |
public void setPhoneTypeCode(String phoneTypeCode) { |
147 | 0 | this.phoneTypeCode = phoneTypeCode; |
148 | 0 | } |
149 | |
|
150 | |
|
151 | |
|
152 | |
|
153 | |
public String getEntityTypeCode() { |
154 | 0 | return entityTypeCode; |
155 | |
} |
156 | |
|
157 | |
|
158 | |
|
159 | |
|
160 | |
public void setEntityTypeCode(String entityTypeCode) { |
161 | 0 | this.entityTypeCode = entityTypeCode; |
162 | 0 | } |
163 | |
|
164 | |
|
165 | |
|
166 | |
|
167 | |
@SuppressWarnings("unchecked") |
168 | |
@Override |
169 | |
protected LinkedHashMap toStringMapper() { |
170 | 0 | LinkedHashMap m = new LinkedHashMap(); |
171 | 0 | m.put( "entityPhoneId", entityPhoneId ); |
172 | 0 | m.put( "phoneNumber", getPhoneNumber() ); |
173 | 0 | m.put( "extensionNumber", getExtensionNumber() ); |
174 | 0 | m.put( "countryCode", getCountryCode() ); |
175 | 0 | return m; |
176 | |
} |
177 | |
|
178 | |
public String getEntityId() { |
179 | 0 | return this.entityId; |
180 | |
} |
181 | |
|
182 | |
public void setEntityId(String entityId) { |
183 | 0 | this.entityId = entityId; |
184 | 0 | } |
185 | |
|
186 | |
public PhoneType getPhoneType() { |
187 | 0 | return this.phoneType; |
188 | |
} |
189 | |
|
190 | |
public void setPhoneType(PhoneType phoneType) { |
191 | 0 | this.phoneType = phoneType; |
192 | 0 | } |
193 | |
|
194 | |
public void setEntityPhoneId(String entityPhoneId) { |
195 | 0 | this.entityPhoneId = entityPhoneId; |
196 | 0 | } |
197 | |
|
198 | |
public String getFormattedPhoneNumber() { |
199 | 0 | if (isSuppressPhone()) { |
200 | 0 | return KimConstants.RESTRICTED_DATA_MASK; |
201 | |
} |
202 | 0 | StringBuffer sb = new StringBuffer( 30 ); |
203 | |
|
204 | |
|
205 | |
|
206 | 0 | sb.append( getPhoneNumber() ); |
207 | 0 | if ( StringUtils.isNotBlank( getExtensionNumber() ) ) { |
208 | 0 | sb.append( " x" ); |
209 | 0 | sb.append( getExtensionNumber() ); |
210 | |
} |
211 | |
|
212 | 0 | return sb.toString(); |
213 | |
} |
214 | |
|
215 | |
public boolean isSuppressPhone() { |
216 | 0 | if (suppressPhone != null) { |
217 | 0 | return suppressPhone.booleanValue(); |
218 | |
} |
219 | 0 | KimEntityPrivacyPreferences privacy = KIMServiceLocator.getIdentityService().getEntityPrivacyPreferences(getEntityId()); |
220 | |
|
221 | 0 | suppressPhone = false; |
222 | 0 | if (privacy != null) { |
223 | 0 | suppressPhone = privacy.isSuppressPhone(); |
224 | |
} |
225 | 0 | return suppressPhone.booleanValue(); |
226 | |
} |
227 | |
|
228 | |
|
229 | |
|
230 | |
|
231 | |
public String getCountryCodeUnmasked() { |
232 | 0 | return this.countryCode; |
233 | |
} |
234 | |
|
235 | |
|
236 | |
|
237 | |
|
238 | |
public String getExtensionNumberUnmasked() { |
239 | 0 | return this.extensionNumber; |
240 | |
} |
241 | |
|
242 | |
|
243 | |
|
244 | |
|
245 | |
public String getFormattedPhoneNumberUnmasked() { |
246 | 0 | StringBuffer sb = new StringBuffer( 30 ); |
247 | |
|
248 | |
|
249 | |
|
250 | 0 | sb.append( this.phoneNumber ); |
251 | 0 | if ( StringUtils.isNotBlank( this.extensionNumber ) ) { |
252 | 0 | sb.append( " x" ); |
253 | 0 | sb.append( this.extensionNumber ); |
254 | |
} |
255 | |
|
256 | 0 | return sb.toString(); |
257 | |
} |
258 | |
|
259 | |
|
260 | |
|
261 | |
|
262 | |
public String getPhoneNumberUnmasked() { |
263 | 0 | return this.phoneNumber; |
264 | |
} |
265 | |
} |