1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kim.document; |
17 | |
|
18 | |
import java.util.ArrayList; |
19 | |
import java.util.HashMap; |
20 | |
import java.util.List; |
21 | |
import java.util.Map; |
22 | |
|
23 | |
import javax.persistence.AssociationOverride; |
24 | |
import javax.persistence.AssociationOverrides; |
25 | |
import javax.persistence.AttributeOverride; |
26 | |
import javax.persistence.AttributeOverrides; |
27 | |
import javax.persistence.CascadeType; |
28 | |
import javax.persistence.Column; |
29 | |
import javax.persistence.Entity; |
30 | |
import javax.persistence.FetchType; |
31 | |
import javax.persistence.GeneratedValue; |
32 | |
import javax.persistence.JoinColumn; |
33 | |
import javax.persistence.OneToMany; |
34 | |
import javax.persistence.OneToOne; |
35 | |
import javax.persistence.Table; |
36 | |
import javax.persistence.Transient; |
37 | |
|
38 | |
import org.apache.commons.collections.CollectionUtils; |
39 | |
import org.apache.commons.lang.StringUtils; |
40 | |
import org.hibernate.annotations.Fetch; |
41 | |
import org.hibernate.annotations.FetchMode; |
42 | |
import org.hibernate.annotations.GenericGenerator; |
43 | |
import org.hibernate.annotations.Parameter; |
44 | |
import org.hibernate.annotations.Type; |
45 | |
import org.kuali.rice.kew.dto.DocumentRouteStatusChangeDTO; |
46 | |
import org.kuali.rice.kim.api.identity.employment.EntityEmployment; |
47 | |
import org.kuali.rice.kim.api.role.Role; |
48 | |
import org.kuali.rice.kim.api.services.KimApiServiceLocator; |
49 | |
import org.kuali.rice.kim.api.type.KimType; |
50 | |
import org.kuali.rice.kim.bo.ui.KimDocumentRoleMember; |
51 | |
import org.kuali.rice.kim.bo.ui.KimDocumentRoleQualifier; |
52 | |
import org.kuali.rice.kim.bo.ui.PersonDocumentAddress; |
53 | |
import org.kuali.rice.kim.bo.ui.PersonDocumentAffiliation; |
54 | |
import org.kuali.rice.kim.bo.ui.PersonDocumentCitizenship; |
55 | |
import org.kuali.rice.kim.bo.ui.PersonDocumentEmail; |
56 | |
import org.kuali.rice.kim.bo.ui.PersonDocumentEmploymentInfo; |
57 | |
import org.kuali.rice.kim.bo.ui.PersonDocumentGroup; |
58 | |
import org.kuali.rice.kim.bo.ui.PersonDocumentName; |
59 | |
import org.kuali.rice.kim.bo.ui.PersonDocumentPhone; |
60 | |
import org.kuali.rice.kim.bo.ui.PersonDocumentPrivacy; |
61 | |
import org.kuali.rice.kim.bo.ui.PersonDocumentRole; |
62 | |
import org.kuali.rice.kim.bo.ui.RoleDocumentDelegationMember; |
63 | |
import org.kuali.rice.kim.bo.ui.RoleDocumentDelegationMemberQualifier; |
64 | |
import org.kuali.rice.kim.impl.type.KimTypeAttributesHelper; |
65 | |
import org.kuali.rice.kim.service.KIMServiceLocatorInternal; |
66 | |
import org.kuali.rice.kim.service.UiDocumentService; |
67 | |
import org.kuali.rice.kim.util.KimConstants; |
68 | |
import org.kuali.rice.krad.service.DocumentHelperService; |
69 | |
import org.kuali.rice.krad.service.KRADServiceLocatorWeb; |
70 | |
import org.kuali.rice.krad.service.SequenceAccessorService; |
71 | |
import org.kuali.rice.krad.util.GlobalVariables; |
72 | |
|
73 | |
|
74 | |
|
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
@Entity |
81 | |
@AttributeOverrides({ |
82 | |
@AttributeOverride(name="documentNumber",column=@Column(name="FDOC_NBR")) |
83 | |
}) |
84 | |
@AssociationOverrides({ |
85 | |
@AssociationOverride(name="documentHeader",joinColumns=@JoinColumn(name="FDOC_NBR",referencedColumnName="DOC_HDR_ID",insertable=false,updatable=false)) |
86 | |
}) |
87 | |
@Table(name="KRIM_PERSON_DOCUMENT_T") |
88 | |
public class IdentityManagementPersonDocument extends IdentityManagementKimDocument { |
89 | |
|
90 | |
protected static final long serialVersionUID = -534993712085516925L; |
91 | |
|
92 | |
|
93 | |
@GeneratedValue(generator="KRIM_PRNCPL_ID_S") |
94 | |
@GenericGenerator(name="KRIM_PRNCPL_ID_S",strategy="org.kuali.rice.core.jpa.spring.RiceNumericStringSequenceStyleGenerator",parameters={ |
95 | |
@Parameter(name="sequence_name",value="KRIM_PRNCPL_ID_S"), |
96 | |
@Parameter(name="value_column",value="id") |
97 | |
}) |
98 | |
@Column(name="PRNCPL_ID") |
99 | |
protected String principalId; |
100 | |
@Column(name="PRNCPL_NM") |
101 | |
protected String principalName; |
102 | |
@GeneratedValue(generator="KRIM_ENTITY_ID_S") |
103 | |
@GenericGenerator(name="KRIM_ENTITY_ID_S",strategy="org.kuali.rice.core.jpa.spring.RiceNumericStringSequenceStyleGenerator",parameters={ |
104 | |
@Parameter(name="sequence_name",value="KRIM_ENTITY_ID_S"), |
105 | |
@Parameter(name="value_column",value="id") |
106 | |
}) |
107 | |
@Column(name="ENTITY_ID") |
108 | |
protected String entityId; |
109 | |
@Type(type="org.kuali.rice.krad.util.HibernateKualiHashType") |
110 | |
@Column(name="PRNCPL_PSWD") |
111 | |
protected String password; |
112 | |
|
113 | 0 | protected String univId = ""; |
114 | |
|
115 | |
@OneToMany(targetEntity=PersonDocumentAffiliation.class, fetch=FetchType.EAGER, cascade={CascadeType.ALL}) |
116 | |
@Fetch(value = FetchMode.SELECT) |
117 | |
@JoinColumn(name="FDOC_NBR",insertable=false,updatable=false) |
118 | |
protected List<PersonDocumentAffiliation> affiliations; |
119 | |
|
120 | 0 | @Transient |
121 | |
protected String campusCode = ""; |
122 | |
|
123 | 0 | @Transient |
124 | |
protected Map<String, String> externalIdentifiers = null; |
125 | |
|
126 | |
@Column(name="ACTV_IND") |
127 | |
@Type(type="yes_no") |
128 | |
protected boolean active; |
129 | |
|
130 | |
|
131 | |
@Transient |
132 | |
protected List<PersonDocumentCitizenship> citizenships; |
133 | |
|
134 | |
@OneToMany(targetEntity=PersonDocumentName.class, fetch=FetchType.EAGER, cascade={CascadeType.ALL}) |
135 | |
@Fetch(value = FetchMode.SELECT) |
136 | |
@JoinColumn(name="FDOC_NBR",insertable=false,updatable=false) |
137 | |
protected List<PersonDocumentName> names; |
138 | |
@OneToMany(targetEntity=PersonDocumentAddress.class, fetch=FetchType.EAGER, cascade={CascadeType.ALL}) |
139 | |
@Fetch(value = FetchMode.SELECT) |
140 | |
@JoinColumn(name="FDOC_NBR",insertable=false,updatable=false) |
141 | |
protected List<PersonDocumentAddress> addrs; |
142 | |
@OneToMany(targetEntity=PersonDocumentPhone.class, fetch=FetchType.EAGER, cascade={CascadeType.ALL}) |
143 | |
@Fetch(value = FetchMode.SELECT) |
144 | |
@JoinColumn(name="FDOC_NBR") |
145 | |
protected List<PersonDocumentPhone> phones; |
146 | |
@OneToMany(targetEntity=PersonDocumentEmail.class, fetch=FetchType.EAGER, cascade={CascadeType.ALL}) |
147 | |
@Fetch(value = FetchMode.SELECT) |
148 | |
@JoinColumn(name="FDOC_NBR",insertable=false,updatable=false) |
149 | |
protected List<PersonDocumentEmail> emails; |
150 | |
@OneToMany(targetEntity=PersonDocumentGroup.class, fetch=FetchType.EAGER, cascade={CascadeType.ALL}) |
151 | |
@Fetch(value = FetchMode.SELECT) |
152 | |
@JoinColumn(name="FDOC_NBR",insertable=false,updatable=false) |
153 | |
protected List<PersonDocumentGroup> groups; |
154 | |
@OneToMany(targetEntity=PersonDocumentRole.class, fetch=FetchType.EAGER, cascade={CascadeType.ALL}) |
155 | |
@Fetch(value = FetchMode.SELECT) |
156 | |
@JoinColumn(name="FDOC_NBR",insertable=false,updatable=false) |
157 | |
protected List<PersonDocumentRole> roles; |
158 | |
|
159 | |
@OneToOne(targetEntity=PersonDocumentPrivacy.class, fetch=FetchType.EAGER, cascade={CascadeType.ALL}) |
160 | |
@JoinColumn(name="FDOC_NBR",insertable=false,updatable=false) |
161 | |
protected PersonDocumentPrivacy privacy; |
162 | |
|
163 | 0 | public IdentityManagementPersonDocument() { |
164 | 0 | affiliations = new ArrayList<PersonDocumentAffiliation>(); |
165 | 0 | citizenships = new ArrayList<PersonDocumentCitizenship>(); |
166 | |
|
167 | 0 | names = new ArrayList<PersonDocumentName>(); |
168 | 0 | addrs = new ArrayList<PersonDocumentAddress>(); |
169 | 0 | phones = new ArrayList<PersonDocumentPhone>(); |
170 | 0 | emails = new ArrayList<PersonDocumentEmail>(); |
171 | 0 | groups = new ArrayList<PersonDocumentGroup>(); |
172 | 0 | roles = new ArrayList<PersonDocumentRole>(); |
173 | 0 | privacy = new PersonDocumentPrivacy(); |
174 | 0 | this.active = true; |
175 | |
|
176 | 0 | } |
177 | |
|
178 | |
public String getPrincipalId() { |
179 | 0 | return this.principalId; |
180 | |
} |
181 | |
|
182 | |
public void setPrincipalId(String principalId) { |
183 | 0 | this.principalId = principalId; |
184 | 0 | } |
185 | |
|
186 | |
public String getPrincipalName() { |
187 | 0 | return this.principalName; |
188 | |
} |
189 | |
|
190 | |
|
191 | |
|
192 | |
|
193 | |
|
194 | |
public void setPrincipalName(String principalName) { |
195 | 0 | this.principalName = principalName; |
196 | 0 | } |
197 | |
|
198 | |
public String getEntityId() { |
199 | 0 | return this.entityId; |
200 | |
} |
201 | |
|
202 | |
public void setEntityId(String entityId) { |
203 | 0 | this.entityId = entityId; |
204 | 0 | } |
205 | |
|
206 | |
public List<PersonDocumentAffiliation> getAffiliations() { |
207 | 0 | return this.affiliations; |
208 | |
} |
209 | |
|
210 | |
public void setAffiliations(List<PersonDocumentAffiliation> affiliations) { |
211 | 0 | this.affiliations = affiliations; |
212 | 0 | } |
213 | |
|
214 | |
public String getCampusCode() { |
215 | 0 | return this.campusCode; |
216 | |
} |
217 | |
|
218 | |
public void setCampusCode(String campusCode) { |
219 | 0 | this.campusCode = campusCode; |
220 | 0 | } |
221 | |
|
222 | |
public Map<String, String> getExternalIdentifiers() { |
223 | 0 | return this.externalIdentifiers; |
224 | |
} |
225 | |
|
226 | |
public void setExternalIdentifiers(Map<String, String> externalIdentifiers) { |
227 | 0 | this.externalIdentifiers = externalIdentifiers; |
228 | 0 | } |
229 | |
|
230 | |
public String getPassword() { |
231 | 0 | return this.password; |
232 | |
} |
233 | |
|
234 | |
public void setPassword(String password) { |
235 | 0 | this.password = password; |
236 | 0 | } |
237 | |
|
238 | |
public boolean isActive() { |
239 | 0 | return this.active; |
240 | |
} |
241 | |
|
242 | |
public void setActive(boolean active) { |
243 | 0 | this.active = active; |
244 | 0 | } |
245 | |
|
246 | |
public List<PersonDocumentCitizenship> getCitizenships() { |
247 | 0 | return this.citizenships; |
248 | |
} |
249 | |
|
250 | |
public void setCitizenships(List<PersonDocumentCitizenship> citizenships) { |
251 | 0 | this.citizenships = citizenships; |
252 | 0 | } |
253 | |
|
254 | |
public List<PersonDocumentName> getNames() { |
255 | 0 | return this.names; |
256 | |
} |
257 | |
|
258 | |
public void setNames(List<PersonDocumentName> names) { |
259 | 0 | this.names = names; |
260 | 0 | } |
261 | |
|
262 | |
public List<PersonDocumentAddress> getAddrs() { |
263 | 0 | return this.addrs; |
264 | |
} |
265 | |
|
266 | |
public void setAddrs(List<PersonDocumentAddress> addrs) { |
267 | 0 | this.addrs = addrs; |
268 | 0 | } |
269 | |
|
270 | |
public List<PersonDocumentPhone> getPhones() { |
271 | 0 | return this.phones; |
272 | |
} |
273 | |
|
274 | |
public void setPhones(List<PersonDocumentPhone> phones) { |
275 | 0 | this.phones = phones; |
276 | 0 | } |
277 | |
|
278 | |
public List<PersonDocumentEmail> getEmails() { |
279 | 0 | return this.emails; |
280 | |
} |
281 | |
|
282 | |
public void setEmails(List<PersonDocumentEmail> emails) { |
283 | 0 | this.emails = emails; |
284 | 0 | } |
285 | |
|
286 | |
public void setGroups(List<PersonDocumentGroup> groups) { |
287 | 0 | this.groups = groups; |
288 | 0 | } |
289 | |
|
290 | |
public List<PersonDocumentRole> getRoles() { |
291 | 0 | return this.roles; |
292 | |
} |
293 | |
|
294 | |
public void setRoles(List<PersonDocumentRole> roles) { |
295 | 0 | this.roles = roles; |
296 | 0 | } |
297 | |
|
298 | |
public List<PersonDocumentGroup> getGroups() { |
299 | 0 | return this.groups; |
300 | |
} |
301 | |
|
302 | |
public String getUnivId() { |
303 | 0 | return this.univId; |
304 | |
} |
305 | |
|
306 | |
public void setUnivId(String univId) { |
307 | 0 | this.univId = univId; |
308 | 0 | } |
309 | |
|
310 | |
public PersonDocumentPrivacy getPrivacy() { |
311 | 0 | return this.privacy; |
312 | |
} |
313 | |
|
314 | |
public void setPrivacy(PersonDocumentPrivacy privacy) { |
315 | 0 | this.privacy = privacy; |
316 | 0 | } |
317 | |
|
318 | |
public void initializeDocumentForNewPerson() { |
319 | 0 | if(StringUtils.isBlank(this.principalId)){ |
320 | 0 | this.principalId = getSequenceAccessorService().getNextAvailableSequenceNumber(KimConstants.SequenceNames.KRIM_PRNCPL_ID_S).toString(); |
321 | |
} |
322 | 0 | if(StringUtils.isBlank(this.entityId)){ |
323 | 0 | this.entityId = getSequenceAccessorService().getNextAvailableSequenceNumber(KimConstants.SequenceNames.KRIM_ENTITY_ID_S).toString(); |
324 | |
} |
325 | 0 | } |
326 | |
|
327 | |
@SuppressWarnings("unchecked") |
328 | |
@Override |
329 | |
public List buildListOfDeletionAwareLists() { |
330 | 0 | List managedLists = super.buildListOfDeletionAwareLists(); |
331 | 0 | List<PersonDocumentEmploymentInfo> empInfos = new ArrayList<PersonDocumentEmploymentInfo>(); |
332 | 0 | for (PersonDocumentAffiliation affiliation : getAffiliations()) { |
333 | 0 | empInfos.addAll(affiliation.getEmpInfos()); |
334 | |
} |
335 | |
|
336 | 0 | managedLists.add(empInfos); |
337 | 0 | managedLists.add(getAffiliations()); |
338 | 0 | managedLists.add(getCitizenships()); |
339 | 0 | managedLists.add(getPhones()); |
340 | 0 | managedLists.add(getAddrs()); |
341 | 0 | managedLists.add(getEmails()); |
342 | 0 | managedLists.add(getNames()); |
343 | 0 | managedLists.add(getGroups()); |
344 | 0 | managedLists.add(getRoles()); |
345 | 0 | return managedLists; |
346 | |
} |
347 | |
|
348 | |
|
349 | |
|
350 | |
|
351 | |
@Override |
352 | |
public void doRouteStatusChange(DocumentRouteStatusChangeDTO statusChangeEvent) { |
353 | 0 | super.doRouteStatusChange(statusChangeEvent); |
354 | 0 | if (getDocumentHeader().getWorkflowDocument().isProcessed()) { |
355 | 0 | setIfRolesEditable(); |
356 | 0 | KIMServiceLocatorInternal.getUiDocumentService().saveEntityPerson(this); |
357 | |
} |
358 | 0 | } |
359 | |
|
360 | |
|
361 | |
@Override |
362 | |
public void prepareForSave(){ |
363 | 0 | if (StringUtils.isBlank(getPrivacy().getDocumentNumber())) { |
364 | 0 | getPrivacy().setDocumentNumber( |
365 | |
getDocumentNumber()); |
366 | |
} |
367 | 0 | setEmployeeRecordIds(); |
368 | 0 | for (PersonDocumentRole role : getRoles()) { |
369 | 0 | role.setDocumentNumber(getDocumentNumber()); |
370 | |
|
371 | |
|
372 | |
|
373 | |
|
374 | |
|
375 | |
|
376 | |
|
377 | 0 | for (KimDocumentRoleMember rolePrncpl : role.getRolePrncpls()) { |
378 | 0 | rolePrncpl.setDocumentNumber(getDocumentNumber()); |
379 | 0 | rolePrncpl.setRoleId(role.getRoleId()); |
380 | 0 | if (StringUtils.isEmpty(rolePrncpl.getRoleMemberId())) { |
381 | 0 | SequenceAccessorService sas = getSequenceAccessorService(); |
382 | 0 | Long nextSeq = sas.getNextAvailableSequenceNumber( |
383 | |
"KRIM_ROLE_MBR_ID_S", this.getClass()); |
384 | 0 | String roleMemberId = nextSeq.toString(); |
385 | 0 | rolePrncpl.setRoleMemberId(roleMemberId); |
386 | |
} |
387 | 0 | for (KimDocumentRoleQualifier qualifier : rolePrncpl.getQualifiers()) { |
388 | 0 | qualifier.setDocumentNumber(getDocumentNumber()); |
389 | 0 | qualifier.setKimTypId(role.getKimTypeId()); |
390 | |
} |
391 | |
} |
392 | |
} |
393 | 0 | if(getDelegationMembers()!=null){ |
394 | 0 | for(RoleDocumentDelegationMember delegationMember: getDelegationMembers()){ |
395 | 0 | delegationMember.setDocumentNumber(getDocumentNumber()); |
396 | 0 | for (RoleDocumentDelegationMemberQualifier qualifier: delegationMember.getQualifiers()) { |
397 | 0 | qualifier.setDocumentNumber(getDocumentNumber()); |
398 | 0 | qualifier.setKimTypId(delegationMember.getRoleBo().getKimTypeId()); |
399 | |
} |
400 | 0 | addDelegationMemberToDelegation(delegationMember); |
401 | |
} |
402 | |
} |
403 | 0 | if (getAddrs() != null) { |
404 | |
String entityAddressId; |
405 | 0 | for(PersonDocumentAddress address : getAddrs()) { |
406 | 0 | address.setDocumentNumber(getDocumentNumber()); |
407 | 0 | if (StringUtils.isEmpty(address.getEntityAddressId())) { |
408 | 0 | SequenceAccessorService sas = getSequenceAccessorService(); |
409 | 0 | Long nextSeq = sas.getNextAvailableSequenceNumber( |
410 | |
"KRIM_ENTITY_ADDR_ID_S", this.getClass()); |
411 | 0 | entityAddressId = nextSeq.toString(); |
412 | 0 | address.setEntityAddressId(entityAddressId); |
413 | 0 | } |
414 | |
} |
415 | |
} |
416 | 0 | if (getAffiliations() != null) { |
417 | |
String affiliationId; |
418 | 0 | for(PersonDocumentAffiliation affiliation : getAffiliations()) { |
419 | 0 | affiliation.setDocumentNumber(getDocumentNumber()); |
420 | 0 | if (StringUtils.isEmpty(affiliation.getEntityAffiliationId())) { |
421 | 0 | SequenceAccessorService sas = getSequenceAccessorService(); |
422 | 0 | Long nextSeq = sas.getNextAvailableSequenceNumber( |
423 | |
"KRIM_ENTITY_AFLTN_ID_S", this.getClass()); |
424 | 0 | affiliationId = nextSeq.toString(); |
425 | 0 | affiliation.setEntityAffiliationId(affiliationId); |
426 | 0 | } |
427 | |
} |
428 | |
} |
429 | 0 | if (getEmails() != null) { |
430 | |
String entityEmailId; |
431 | 0 | for(PersonDocumentEmail email : getEmails()) { |
432 | 0 | email.setDocumentNumber(getDocumentNumber()); |
433 | 0 | if (StringUtils.isEmpty(email.getEntityEmailId())) { |
434 | 0 | SequenceAccessorService sas = getSequenceAccessorService(); |
435 | 0 | Long nextSeq = sas.getNextAvailableSequenceNumber( |
436 | |
"KRIM_ENTITY_EMAIL_ID_S", this.getClass()); |
437 | 0 | entityEmailId = nextSeq.toString(); |
438 | 0 | email.setEntityEmailId(entityEmailId); |
439 | 0 | } |
440 | |
} |
441 | |
} |
442 | 0 | if (getGroups() != null) { |
443 | |
String groupMemberId; |
444 | 0 | for(PersonDocumentGroup group : getGroups()) { |
445 | 0 | group.setDocumentNumber(getDocumentNumber()); |
446 | 0 | if (StringUtils.isEmpty(group.getGroupMemberId())) { |
447 | 0 | SequenceAccessorService sas = getSequenceAccessorService(); |
448 | 0 | Long nextSeq = sas.getNextAvailableSequenceNumber( |
449 | |
"KRIM_GRP_MBR_ID_S", this.getClass()); |
450 | 0 | groupMemberId = nextSeq.toString(); |
451 | 0 | group.setGroupMemberId(groupMemberId); |
452 | 0 | } |
453 | |
} |
454 | |
} |
455 | 0 | if (getNames() != null) { |
456 | |
String entityNameId; |
457 | 0 | for(PersonDocumentName name : getNames()) { |
458 | 0 | name.setDocumentNumber(getDocumentNumber()); |
459 | 0 | if (StringUtils.isEmpty(name.getEntityNameId())) { |
460 | 0 | SequenceAccessorService sas = getSequenceAccessorService(); |
461 | 0 | Long nextSeq = sas.getNextAvailableSequenceNumber( |
462 | |
"KRIM_ENTITY_NM_ID_S", this.getClass()); |
463 | 0 | entityNameId = nextSeq.toString(); |
464 | 0 | name.setEntityNameId(entityNameId); |
465 | 0 | } |
466 | |
} |
467 | |
} |
468 | 0 | if (getPhones() != null) { |
469 | |
String entityPhoneId; |
470 | 0 | for(PersonDocumentPhone phone : getPhones()) { |
471 | 0 | phone.setDocumentNumber(getDocumentNumber()); |
472 | 0 | if (StringUtils.isEmpty(phone.getEntityPhoneId())) { |
473 | 0 | SequenceAccessorService sas = getSequenceAccessorService(); |
474 | 0 | Long nextSeq = sas.getNextAvailableSequenceNumber( |
475 | |
"KRIM_ENTITY_PHONE_ID_S", this.getClass()); |
476 | 0 | entityPhoneId = nextSeq.toString(); |
477 | 0 | phone.setEntityPhoneId(entityPhoneId); |
478 | 0 | } |
479 | |
} |
480 | |
} |
481 | |
|
482 | 0 | } |
483 | |
|
484 | |
protected void setEmployeeRecordIds(){ |
485 | 0 | List<EntityEmployment> empInfos = getUiDocumentService().getEntityEmploymentInformationInfo(getEntityId()); |
486 | 0 | for(PersonDocumentAffiliation affiliation: getAffiliations()) { |
487 | 0 | int employeeRecordCounter = CollectionUtils.isEmpty(empInfos) ? 0 : empInfos.size(); |
488 | 0 | for(PersonDocumentEmploymentInfo empInfo: affiliation.getEmpInfos()){ |
489 | 0 | if(CollectionUtils.isNotEmpty(empInfos)){ |
490 | 0 | for(EntityEmployment origEmpInfo: empInfos){ |
491 | 0 | if (origEmpInfo.getEmployeeId().equals(empInfo.getEntityEmploymentId())) { |
492 | 0 | empInfo.setEmploymentRecordId(origEmpInfo.getEmploymentRecordId()); |
493 | |
} |
494 | |
} |
495 | |
} |
496 | 0 | if(StringUtils.isEmpty(empInfo.getEmploymentRecordId())){ |
497 | 0 | employeeRecordCounter++; |
498 | 0 | empInfo.setEmploymentRecordId(employeeRecordCounter+""); |
499 | |
} |
500 | |
} |
501 | 0 | } |
502 | 0 | } |
503 | |
|
504 | |
public KimTypeAttributesHelper getKimTypeAttributesHelper(String roleId) { |
505 | 0 | Role role = KimApiServiceLocator.getRoleService().getRole(roleId); |
506 | 0 | KimType kimTypeInfo = KimApiServiceLocator.getKimTypeInfoService().getKimType(role.getKimTypeId()); |
507 | 0 | return new KimTypeAttributesHelper(kimTypeInfo); |
508 | |
|
509 | |
} |
510 | |
|
511 | |
public void setIfRolesEditable(){ |
512 | 0 | if(CollectionUtils.isNotEmpty(getRoles())){ |
513 | 0 | for(PersonDocumentRole role: getRoles()){ |
514 | 0 | role.setEditable(validAssignRole(role)); |
515 | |
} |
516 | |
} |
517 | 0 | } |
518 | |
|
519 | |
public boolean validAssignRole(PersonDocumentRole role){ |
520 | 0 | boolean rulePassed = true; |
521 | 0 | if(StringUtils.isNotEmpty(role.getNamespaceCode())){ |
522 | 0 | Map<String,String> additionalPermissionDetails = new HashMap<String,String>(); |
523 | 0 | additionalPermissionDetails.put(KimConstants.AttributeConstants.NAMESPACE_CODE, role.getNamespaceCode()); |
524 | 0 | additionalPermissionDetails.put(KimConstants.AttributeConstants.ROLE_NAME, role.getRoleName()); |
525 | 0 | if (!getDocumentHelperService().getDocumentAuthorizer(this).isAuthorizedByTemplate( |
526 | |
this, |
527 | |
KimConstants.NAMESPACE_CODE, |
528 | |
KimConstants.PermissionTemplateNames.ASSIGN_ROLE, |
529 | |
GlobalVariables.getUserSession().getPrincipalId(), |
530 | |
additionalPermissionDetails, null)){ |
531 | 0 | rulePassed = false; |
532 | |
} |
533 | |
} |
534 | 0 | return rulePassed; |
535 | |
} |
536 | |
|
537 | |
@Transient |
538 | |
protected transient DocumentHelperService documentHelperService; |
539 | |
@Transient |
540 | |
protected transient UiDocumentService uiDocumentService; |
541 | |
|
542 | |
protected DocumentHelperService getDocumentHelperService() { |
543 | 0 | if ( documentHelperService == null ) { |
544 | 0 | documentHelperService = KRADServiceLocatorWeb.getDocumentHelperService(); |
545 | |
} |
546 | 0 | return this.documentHelperService; |
547 | |
} |
548 | |
|
549 | |
protected UiDocumentService getUiDocumentService() { |
550 | 0 | if (uiDocumentService == null ) { |
551 | 0 | uiDocumentService = KIMServiceLocatorInternal.getUiDocumentService(); |
552 | |
} |
553 | 0 | return this.uiDocumentService; |
554 | |
} |
555 | |
|
556 | |
} |