1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.krad.bo; |
17 | |
|
18 | |
import org.apache.commons.lang.StringUtils; |
19 | |
import org.kuali.rice.kim.api.identity.Person; |
20 | |
import org.kuali.rice.kim.api.services.KimApiServiceLocator; |
21 | |
|
22 | |
import javax.persistence.Entity; |
23 | |
import javax.persistence.IdClass; |
24 | |
import javax.persistence.Table; |
25 | |
import javax.persistence.Transient; |
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
@IdClass(AdHocRoutePersonId.class) |
33 | |
@Entity |
34 | |
@Table(name = "KRNS_ADHOC_RTE_ACTN_RECIP_T") |
35 | |
public class AdHocRoutePerson extends AdHocRouteRecipient { |
36 | |
private static final long serialVersionUID = 1L; |
37 | |
|
38 | |
@Transient |
39 | |
private transient Person person; |
40 | |
|
41 | 0 | public AdHocRoutePerson() { |
42 | 0 | setType(PERSON_TYPE); |
43 | |
|
44 | |
|
45 | |
try { |
46 | 0 | person = (Person) Class.forName("org.kuali.rice.kim.impl.identity.PersonImpl").newInstance(); |
47 | 0 | } catch (Exception e) { |
48 | 0 | throw new RuntimeException(e); |
49 | 0 | } |
50 | 0 | } |
51 | |
|
52 | |
@Override |
53 | |
public void setType(Integer type) { |
54 | 0 | if (!PERSON_TYPE.equals(type)) { |
55 | 0 | throw new IllegalArgumentException("cannot change type to " + type); |
56 | |
} |
57 | 0 | super.setType(type); |
58 | 0 | } |
59 | |
|
60 | |
@Override |
61 | |
public void setId(String id) { |
62 | 0 | super.setId(id); |
63 | |
|
64 | 0 | if (StringUtils.isNotBlank(id)) { |
65 | 0 | person = KimApiServiceLocator.getPersonService().getPerson(id); |
66 | 0 | setPerson(person); |
67 | |
} |
68 | 0 | } |
69 | |
|
70 | |
@Override |
71 | |
public void setName(String name) { |
72 | 0 | super.setName(name); |
73 | |
|
74 | 0 | if (StringUtils.isNotBlank(name) && |
75 | |
((person != null) && !StringUtils.equals(person.getName(), name))) { |
76 | 0 | person = KimApiServiceLocator.getPersonService().getPerson(getId()); |
77 | 0 | setPerson(person); |
78 | |
} |
79 | 0 | } |
80 | |
|
81 | |
public Person getPerson() { |
82 | 0 | if ((person == null) || !StringUtils.equals(person.getPrincipalId(), getId())) { |
83 | 0 | person = KimApiServiceLocator.getPersonService().getPerson(getId()); |
84 | |
|
85 | 0 | if (person == null) { |
86 | |
try { |
87 | 0 | person = (Person) Class.forName("org.kuali.rice.kim.impl.identity.PersonImpl").newInstance(); |
88 | 0 | } catch (Exception e) { |
89 | 0 | throw new RuntimeException(e); |
90 | 0 | } |
91 | |
} |
92 | |
} |
93 | |
|
94 | 0 | return person; |
95 | |
} |
96 | |
|
97 | |
public void setPerson(Person person) { |
98 | 0 | this.person = person; |
99 | 0 | this.id = person.getPrincipalId(); |
100 | 0 | this.name = person.getPrincipalName(); |
101 | 0 | } |
102 | |
} |
103 | |
|