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