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.KimEntityName; |
30 | |
import org.kuali.rice.kim.bo.entity.KimEntityPrivacyPreferences; |
31 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityDefaultInfo; |
32 | |
import org.kuali.rice.kim.bo.reference.EntityNameType; |
33 | |
import org.kuali.rice.kim.bo.reference.impl.EntityNameTypeImpl; |
34 | |
import org.kuali.rice.kim.service.KIMServiceLocator; |
35 | |
import org.kuali.rice.kim.util.KimCommonUtils; |
36 | |
import org.kuali.rice.kim.util.KimConstants; |
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
@Entity |
42 | |
@Table(name = "KRIM_ENTITY_NM_T") |
43 | 0 | public class KimEntityNameImpl extends KimDefaultableEntityDataBase implements KimEntityName { |
44 | |
|
45 | |
private static final long serialVersionUID = 1L; |
46 | |
|
47 | |
@Id |
48 | |
@Column(name = "ENTITY_NM_ID") |
49 | |
protected String entityNameId; |
50 | |
|
51 | |
@Column(name = "ENTITY_ID") |
52 | |
protected String entityId; |
53 | |
|
54 | |
@Column(name = "NM_TYP_CD") |
55 | |
protected String nameTypeCode ; |
56 | |
|
57 | |
@Column(name = "FIRST_NM") |
58 | |
protected String firstName; |
59 | |
|
60 | |
@Column(name = "MIDDLE_NM") |
61 | |
protected String middleName; |
62 | |
|
63 | |
@Column(name = "LAST_NM") |
64 | |
protected String lastName; |
65 | |
|
66 | |
@Column(name = "TITLE_NM") |
67 | |
protected String title; |
68 | |
|
69 | |
@Column(name = "SUFFIX_NM") |
70 | |
protected String suffix; |
71 | |
|
72 | |
@ManyToOne(targetEntity=EntityNameTypeImpl.class, fetch = FetchType.EAGER, cascade = {}) |
73 | |
@JoinColumn(name = "NM_TYP_CD", insertable = false, updatable = false) |
74 | |
protected EntityNameType entityNameType; |
75 | |
|
76 | |
@Transient |
77 | |
protected Boolean suppressName; |
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | |
public String getEntityNameId() { |
84 | 0 | return entityNameId; |
85 | |
} |
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
public String getFirstName() { |
91 | 0 | if (isSuppressName()) { |
92 | 0 | return KimConstants.RESTRICTED_DATA_MASK; |
93 | |
} |
94 | 0 | return firstName; |
95 | |
} |
96 | |
|
97 | |
|
98 | |
|
99 | |
|
100 | |
public String getLastName() { |
101 | 0 | if (isSuppressName()) { |
102 | 0 | return KimConstants.RESTRICTED_DATA_MASK; |
103 | |
} |
104 | 0 | return lastName; |
105 | |
} |
106 | |
|
107 | |
|
108 | |
|
109 | |
|
110 | |
public String getMiddleName() { |
111 | 0 | if (isSuppressName()) { |
112 | 0 | return KimConstants.RESTRICTED_DATA_MASK; |
113 | |
} |
114 | 0 | return middleName; |
115 | |
} |
116 | |
|
117 | |
|
118 | |
|
119 | |
|
120 | |
public String getNameTypeCode() { |
121 | 0 | return nameTypeCode; |
122 | |
} |
123 | |
|
124 | |
|
125 | |
|
126 | |
|
127 | |
public String getSuffix() { |
128 | 0 | if (isSuppressName()) { |
129 | 0 | return KimConstants.RESTRICTED_DATA_MASK; |
130 | |
} |
131 | 0 | return suffix; |
132 | |
} |
133 | |
|
134 | |
|
135 | |
|
136 | |
|
137 | |
public String getTitle() { |
138 | 0 | if (isSuppressName()) { |
139 | 0 | return KimConstants.RESTRICTED_DATA_MASK; |
140 | |
} |
141 | 0 | return title; |
142 | |
} |
143 | |
|
144 | |
public void setFirstName(String firstName) { |
145 | 0 | this.firstName = firstName; |
146 | 0 | } |
147 | |
|
148 | |
public void setLastName(String lastName) { |
149 | 0 | this.lastName = lastName; |
150 | 0 | } |
151 | |
|
152 | |
public void setMiddleName(String middleName) { |
153 | 0 | this.middleName = middleName; |
154 | 0 | } |
155 | |
|
156 | |
public void setNameTypeCode(String nameTypeCode) { |
157 | 0 | this.nameTypeCode = nameTypeCode; |
158 | 0 | } |
159 | |
|
160 | |
public void setSuffix(String suffix) { |
161 | 0 | this.suffix = suffix; |
162 | 0 | } |
163 | |
|
164 | |
public void setTitle(String title) { |
165 | 0 | this.title = title; |
166 | 0 | } |
167 | |
|
168 | |
|
169 | |
|
170 | |
|
171 | |
|
172 | |
|
173 | |
public String getFormattedName() { |
174 | 0 | if (isSuppressName()) { |
175 | 0 | return KimConstants.RESTRICTED_DATA_MASK; |
176 | |
} |
177 | 0 | return getLastName() + ", " + getFirstName() + (getMiddleName()==null?"":" " + getMiddleName()); |
178 | |
} |
179 | |
|
180 | |
|
181 | |
|
182 | |
|
183 | |
@SuppressWarnings("unchecked") |
184 | |
@Override |
185 | |
protected LinkedHashMap toStringMapper() { |
186 | 0 | LinkedHashMap m = new LinkedHashMap(); |
187 | 0 | m.put( "entityNameId", entityNameId ); |
188 | 0 | m.put( "firstName", getFirstName() ); |
189 | 0 | m.put( "lastName", getLastName() ); |
190 | 0 | return m; |
191 | |
} |
192 | |
|
193 | |
public String getEntityId() { |
194 | 0 | return this.entityId; |
195 | |
} |
196 | |
|
197 | |
public void setEntityId(String entityId) { |
198 | 0 | this.entityId = entityId; |
199 | 0 | } |
200 | |
|
201 | |
public EntityNameType getEntityNameType() { |
202 | 0 | return this.entityNameType; |
203 | |
} |
204 | |
|
205 | |
public void setEntityNameType(EntityNameType entityNameType) { |
206 | 0 | this.entityNameType = entityNameType; |
207 | 0 | } |
208 | |
|
209 | |
public void setEntityNameId(String entityNameId) { |
210 | 0 | this.entityNameId = entityNameId; |
211 | 0 | } |
212 | |
|
213 | |
|
214 | |
|
215 | |
|
216 | |
public String getFirstNameUnmasked() { |
217 | 0 | return this.firstName; |
218 | |
} |
219 | |
|
220 | |
|
221 | |
|
222 | |
|
223 | |
public String getFormattedNameUnmasked() { |
224 | 0 | return this.lastName + ", " + this.firstName + (this.middleName==null?"":" " + this.middleName); |
225 | |
} |
226 | |
|
227 | |
|
228 | |
|
229 | |
|
230 | |
public String getLastNameUnmasked() { |
231 | 0 | return this.lastName; |
232 | |
} |
233 | |
|
234 | |
|
235 | |
|
236 | |
|
237 | |
public String getMiddleNameUnmasked() { |
238 | 0 | return this.middleName; |
239 | |
} |
240 | |
|
241 | |
|
242 | |
|
243 | |
|
244 | |
public String getSuffixUnmasked() { |
245 | 0 | return this.suffix; |
246 | |
} |
247 | |
|
248 | |
|
249 | |
|
250 | |
|
251 | |
public String getTitleUnmasked() { |
252 | 0 | return this.title; |
253 | |
} |
254 | |
|
255 | |
public boolean isSuppressName() { |
256 | 0 | if (suppressName != null) { |
257 | 0 | return suppressName.booleanValue(); |
258 | |
} |
259 | 0 | KimEntityPrivacyPreferences privacy = KIMServiceLocator.getIdentityService().getEntityPrivacyPreferences(getEntityId()); |
260 | |
|
261 | 0 | suppressName = false; |
262 | 0 | if (privacy != null) { |
263 | 0 | suppressName = privacy.isSuppressName(); |
264 | |
} |
265 | 0 | return suppressName.booleanValue(); |
266 | |
} |
267 | |
} |