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