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 org.kuali.rice.kim.api.entity.address.EntityAddress; |
19 | |
import org.kuali.rice.kim.api.entity.email.EntityEmail; |
20 | |
import org.kuali.rice.kim.api.entity.phone.EntityPhone; |
21 | |
import org.kuali.rice.kim.api.entity.principal.Principal; |
22 | |
import org.kuali.rice.kim.api.entity.type.EntityTypeDataDefault; |
23 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityAffiliationInfo; |
24 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityDefaultInfo; |
25 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityEmploymentInformationInfo; |
26 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityExternalIdentifierInfo; |
27 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityNameInfo; |
28 | |
import org.kuali.rice.kns.bo.PersistableBusinessObjectBase; |
29 | |
|
30 | |
import javax.persistence.Column; |
31 | |
import javax.persistence.Entity; |
32 | |
import javax.persistence.Id; |
33 | |
import javax.persistence.Table; |
34 | |
import javax.persistence.Transient; |
35 | |
import java.sql.Timestamp; |
36 | |
import java.util.ArrayList; |
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
@Entity |
45 | |
@Table(name="KRIM_ENTITY_CACHE_T") |
46 | |
public class KimEntityDefaultInfoCacheImpl extends PersistableBusinessObjectBase { |
47 | |
|
48 | |
private static final long serialVersionUID = 1L; |
49 | |
|
50 | |
@Transient |
51 | |
protected Long versionNumber; |
52 | |
|
53 | |
|
54 | |
@Id |
55 | |
@Column(name="PRNCPL_ID") |
56 | |
protected String principalId; |
57 | |
@Column(name="PRNCPL_NM") |
58 | |
protected String principalName; |
59 | |
@Column(name="ENTITY_ID") |
60 | |
protected String entityId; |
61 | |
@Column(name="ENTITY_TYP_CD") |
62 | |
protected String entityTypeCode; |
63 | |
|
64 | |
|
65 | 0 | @Column(name="FIRST_NM") |
66 | |
protected String firstName = ""; |
67 | 0 | @Column(name="MIDDLE_NM") |
68 | |
protected String middleName = ""; |
69 | 0 | @Column(name="LAST_NM") |
70 | |
protected String lastName = ""; |
71 | 0 | @Column(name="PRSN_NM") |
72 | |
protected String name = ""; |
73 | |
|
74 | 0 | @Column(name="CAMPUS_CD") |
75 | |
protected String campusCode = ""; |
76 | |
|
77 | |
|
78 | 0 | @Column(name="PRMRY_DEPT_CD") |
79 | |
protected String primaryDepartmentCode = ""; |
80 | 0 | @Column(name="EMP_ID") |
81 | |
protected String employeeId = ""; |
82 | |
|
83 | |
@Column(name="LAST_UPDT_TS") |
84 | |
protected Timestamp lastUpdateTimestamp; |
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | 0 | public KimEntityDefaultInfoCacheImpl() { |
90 | 0 | } |
91 | |
|
92 | 0 | public KimEntityDefaultInfoCacheImpl( KimEntityDefaultInfo entity ) { |
93 | 0 | if ( entity != null ) { |
94 | 0 | entityId = entity.getEntityId(); |
95 | 0 | if ( entity.getPrincipals() != null && !entity.getPrincipals().isEmpty() ) { |
96 | 0 | principalId = entity.getPrincipals().get(0).getPrincipalId(); |
97 | 0 | principalName = entity.getPrincipals().get(0).getPrincipalName(); |
98 | |
} |
99 | 0 | if ( entity.getEntityTypes() != null && !entity.getEntityTypes().isEmpty() ) { |
100 | 0 | entityTypeCode = entity.getEntityTypes().get(0).getEntityTypeCode(); |
101 | |
} |
102 | 0 | if ( entity.getDefaultName() != null ) { |
103 | 0 | firstName = entity.getDefaultName().getFirstNameUnmasked(); |
104 | 0 | middleName = entity.getDefaultName().getMiddleNameUnmasked(); |
105 | 0 | lastName = entity.getDefaultName().getLastNameUnmasked(); |
106 | 0 | name = entity.getDefaultName().getFormattedNameUnmasked(); |
107 | |
} |
108 | 0 | if ( entity.getDefaultAffiliation() != null ) { |
109 | 0 | campusCode = entity.getDefaultAffiliation().getCampusCode(); |
110 | |
} |
111 | 0 | if ( entity.getPrimaryEmployment() != null ) { |
112 | 0 | primaryDepartmentCode = entity.getPrimaryEmployment().getPrimaryDepartmentCode(); |
113 | 0 | employeeId = entity.getPrimaryEmployment().getEmployeeId(); |
114 | |
} |
115 | |
} |
116 | 0 | } |
117 | |
|
118 | |
@SuppressWarnings("unchecked") |
119 | |
public KimEntityDefaultInfo convertCacheToEntityDefaultInfo() { |
120 | 0 | KimEntityDefaultInfo info = new KimEntityDefaultInfo(); |
121 | |
|
122 | |
|
123 | 0 | info.setEntityId( this.getEntityId() ); |
124 | 0 | info.setActive( this.isActive() ); |
125 | |
|
126 | |
|
127 | 0 | Principal.Builder principalInfo = Principal.Builder.create(this.getPrincipalName()); |
128 | 0 | principalInfo.setEntityId(this.getEntityId()); |
129 | 0 | principalInfo.setPrincipalId(this.getPrincipalId()); |
130 | 0 | principalInfo.setActive(this.isActive()); |
131 | 0 | info.setPrincipals( new ArrayList<Principal>( 1 ) ); |
132 | 0 | ((ArrayList<Principal>)info.getPrincipals()).add(principalInfo.build()); |
133 | |
|
134 | |
|
135 | 0 | KimEntityNameInfo nameInfo = new KimEntityNameInfo(); |
136 | 0 | nameInfo.setFirstName( this.getFirstName() ); |
137 | 0 | nameInfo.setLastName( this.getLastName() ); |
138 | 0 | nameInfo.setMiddleName( this.getMiddleName() ); |
139 | 0 | info.setDefaultName(nameInfo); |
140 | |
|
141 | |
|
142 | 0 | ArrayList<EntityTypeDataDefault> entityTypesInfo = new ArrayList<EntityTypeDataDefault>( 1 ); |
143 | 0 | info.setEntityTypes( entityTypesInfo ); |
144 | 0 | EntityTypeDataDefault entityTypeInfo = new EntityTypeDataDefault(this.getEntityTypeCode(), |
145 | |
EntityAddress.Builder.create().build(), |
146 | |
EntityEmail.Builder.create().build(), |
147 | |
EntityPhone.Builder.create().build()); |
148 | 0 | entityTypesInfo.add(entityTypeInfo); |
149 | 0 | info.setEntityTypes(entityTypesInfo); |
150 | |
|
151 | |
|
152 | 0 | ArrayList<KimEntityAffiliationInfo> affInfo = new ArrayList<KimEntityAffiliationInfo>( 1 ); |
153 | 0 | info.setAffiliations( affInfo ); |
154 | 0 | KimEntityAffiliationInfo aff = new KimEntityAffiliationInfo(); |
155 | 0 | aff.setCampusCode(this.getCampusCode()); |
156 | 0 | aff.setDefaultValue(true); |
157 | 0 | info.setDefaultAffiliation(aff); |
158 | 0 | info.setAffiliations(affInfo); |
159 | |
|
160 | |
|
161 | 0 | KimEntityEmploymentInformationInfo empInfo = new KimEntityEmploymentInformationInfo(); |
162 | 0 | empInfo.setEmployeeId( this.getEmployeeId() ); |
163 | 0 | empInfo.setPrimary(true); |
164 | 0 | empInfo.setPrimaryDepartmentCode(this.getPrimaryDepartmentCode()); |
165 | 0 | info.setPrimaryEmployment( empInfo ); |
166 | |
|
167 | |
|
168 | 0 | info.setExternalIdentifiers( new ArrayList<KimEntityExternalIdentifierInfo>(0) ); |
169 | 0 | return info; |
170 | |
|
171 | |
} |
172 | |
|
173 | |
public String getPrincipalId() { |
174 | 0 | return this.principalId; |
175 | |
} |
176 | |
|
177 | |
|
178 | |
public void setPrincipalId(String principalId) { |
179 | 0 | this.principalId = principalId; |
180 | 0 | } |
181 | |
|
182 | |
|
183 | |
public String getPrincipalName() { |
184 | 0 | return this.principalName; |
185 | |
} |
186 | |
|
187 | |
|
188 | |
public void setPrincipalName(String principalName) { |
189 | 0 | this.principalName = principalName; |
190 | 0 | } |
191 | |
|
192 | |
|
193 | |
public String getEntityId() { |
194 | 0 | return this.entityId; |
195 | |
} |
196 | |
|
197 | |
|
198 | |
public void setEntityId(String entityId) { |
199 | 0 | this.entityId = entityId; |
200 | 0 | } |
201 | |
|
202 | |
|
203 | |
public String getEntityTypeCode() { |
204 | 0 | return this.entityTypeCode; |
205 | |
} |
206 | |
|
207 | |
|
208 | |
public void setEntityTypeCode(String entityTypeCode) { |
209 | 0 | this.entityTypeCode = entityTypeCode; |
210 | 0 | } |
211 | |
|
212 | |
|
213 | |
public String getFirstName() { |
214 | 0 | return this.firstName; |
215 | |
} |
216 | |
|
217 | |
|
218 | |
public void setFirstName(String firstName) { |
219 | 0 | this.firstName = firstName; |
220 | 0 | } |
221 | |
|
222 | |
|
223 | |
public String getMiddleName() { |
224 | 0 | return this.middleName; |
225 | |
} |
226 | |
|
227 | |
|
228 | |
public void setMiddleName(String middleName) { |
229 | 0 | this.middleName = middleName; |
230 | 0 | } |
231 | |
|
232 | |
|
233 | |
public String getLastName() { |
234 | 0 | return this.lastName; |
235 | |
} |
236 | |
|
237 | |
|
238 | |
public void setLastName(String lastName) { |
239 | 0 | this.lastName = lastName; |
240 | 0 | } |
241 | |
|
242 | |
|
243 | |
public String getName() { |
244 | 0 | return this.name; |
245 | |
} |
246 | |
|
247 | |
|
248 | |
public void setName(String name) { |
249 | 0 | this.name = name; |
250 | 0 | } |
251 | |
|
252 | |
|
253 | |
public String getCampusCode() { |
254 | 0 | return this.campusCode; |
255 | |
} |
256 | |
|
257 | |
|
258 | |
public void setCampusCode(String campusCode) { |
259 | 0 | this.campusCode = campusCode; |
260 | 0 | } |
261 | |
|
262 | |
|
263 | |
public String getPrimaryDepartmentCode() { |
264 | 0 | return this.primaryDepartmentCode; |
265 | |
} |
266 | |
|
267 | |
|
268 | |
public void setPrimaryDepartmentCode(String primaryDepartmentCode) { |
269 | 0 | this.primaryDepartmentCode = primaryDepartmentCode; |
270 | 0 | } |
271 | |
|
272 | |
|
273 | |
public String getEmployeeId() { |
274 | 0 | return this.employeeId; |
275 | |
} |
276 | |
|
277 | |
|
278 | |
public void setEmployeeId(String employeeId) { |
279 | 0 | this.employeeId = employeeId; |
280 | 0 | } |
281 | |
|
282 | |
|
283 | |
public boolean isActive() { |
284 | 0 | return false; |
285 | |
} |
286 | |
|
287 | |
public Timestamp getLastUpdateTimestamp() { |
288 | 0 | return this.lastUpdateTimestamp; |
289 | |
} |
290 | |
|
291 | |
|
292 | |
|
293 | |
@Override |
294 | |
protected void prePersist() { |
295 | 0 | super.prePersist(); |
296 | 0 | lastUpdateTimestamp = new Timestamp(System.currentTimeMillis()); |
297 | 0 | } |
298 | |
|
299 | |
@Override |
300 | |
protected void preUpdate() { |
301 | 0 | super.preUpdate(); |
302 | 0 | lastUpdateTimestamp = new Timestamp(System.currentTimeMillis()); |
303 | 0 | } |
304 | |
|
305 | |
} |