1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kim.bo.ui; |
17 | |
|
18 | |
import org.apache.log4j.Logger; |
19 | |
import org.hibernate.annotations.Fetch; |
20 | |
import org.hibernate.annotations.FetchMode; |
21 | |
import org.kuali.rice.kim.api.services.KimApiServiceLocator; |
22 | |
import org.kuali.rice.kim.api.type.KimAttributeField; |
23 | |
import org.kuali.rice.kim.bo.impl.KimAttributes; |
24 | |
import org.kuali.rice.kim.framework.services.KimFrameworkServiceLocator; |
25 | |
import org.kuali.rice.kim.framework.type.KimTypeService; |
26 | |
import org.kuali.rice.kim.impl.role.RoleBo; |
27 | |
import org.kuali.rice.kim.impl.role.RoleResponsibilityBo; |
28 | |
import org.kuali.rice.kim.impl.type.KimTypeBo; |
29 | |
import org.kuali.rice.kim.service.KIMServiceLocatorInternal; |
30 | |
import org.springframework.util.AutoPopulatingList; |
31 | |
|
32 | |
import javax.persistence.CascadeType; |
33 | |
import javax.persistence.Column; |
34 | |
import javax.persistence.Entity; |
35 | |
import javax.persistence.FetchType; |
36 | |
import javax.persistence.Id; |
37 | |
import javax.persistence.IdClass; |
38 | |
import javax.persistence.JoinColumn; |
39 | |
import javax.persistence.JoinColumns; |
40 | |
import javax.persistence.ManyToMany; |
41 | |
import javax.persistence.OneToMany; |
42 | |
import javax.persistence.Table; |
43 | |
import javax.persistence.Transient; |
44 | |
import javax.persistence.UniqueConstraint; |
45 | |
import java.util.ArrayList; |
46 | |
import java.util.Collections; |
47 | |
import java.util.HashMap; |
48 | |
import java.util.List; |
49 | |
import java.util.Map; |
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
@Entity |
59 | |
@IdClass(org.kuali.rice.kim.bo.ui.PersonDocumentRoleId.class) |
60 | |
@Table(name="KRIM_PND_ROLE_MT",uniqueConstraints=@UniqueConstraint(columnNames={"FDOC_NBR", "ROLE_ID"})) |
61 | |
public class PersonDocumentRole extends KimDocumentBoActivatableEditableBase { |
62 | 0 | private static final Logger LOG = Logger.getLogger(PersonDocumentRole.class); |
63 | |
private static final long serialVersionUID = 4908044213007222739L; |
64 | |
@Id |
65 | |
@Column(name="ROLE_ID") |
66 | |
protected String roleId; |
67 | |
@Column(name="KIM_TYP_ID") |
68 | |
protected String kimTypeId; |
69 | |
@Column(name="ROLE_NM") |
70 | |
protected String roleName; |
71 | |
@Transient |
72 | |
protected RoleBo roleBo; |
73 | |
@Column(name="NMSPC_CD") |
74 | |
protected String namespaceCode; |
75 | |
@Transient |
76 | |
protected KimTypeBo kimRoleType; |
77 | |
@Transient |
78 | |
protected List<? extends KimAttributes> attributes; |
79 | |
@Transient |
80 | |
protected transient List<KimAttributeField> definitions; |
81 | |
@Transient |
82 | |
protected transient Map<String,Object> attributeEntry; |
83 | |
@OneToMany(fetch=FetchType.EAGER, cascade={CascadeType.ALL}) |
84 | |
@Fetch(value = FetchMode.SELECT) |
85 | |
@JoinColumns({ |
86 | |
@JoinColumn(name="ROLE_ID",insertable=false,updatable=false), |
87 | |
@JoinColumn(name="FDOC_NBR", insertable=false, updatable=false) |
88 | |
}) |
89 | |
protected List<KimDocumentRoleMember> rolePrncpls; |
90 | |
@Transient |
91 | |
protected KimDocumentRoleMember newRolePrncpl; |
92 | |
|
93 | |
|
94 | |
|
95 | 0 | @ManyToMany(fetch=FetchType.EAGER, cascade={CascadeType.ALL}) |
96 | |
@Fetch(value = FetchMode.SELECT) |
97 | |
@JoinColumn(name="ROLE_ID",insertable=false,updatable=false) |
98 | |
|
99 | |
|
100 | |
|
101 | |
|
102 | |
protected List<RoleResponsibilityBo> assignedResponsibilities = new AutoPopulatingList(RoleResponsibilityBo.class); |
103 | |
|
104 | 0 | @Transient |
105 | |
protected boolean isEditable = true; |
106 | |
|
107 | 0 | public PersonDocumentRole() { |
108 | 0 | attributes = new ArrayList<KimAttributes>(); |
109 | 0 | rolePrncpls = new ArrayList<KimDocumentRoleMember>(); |
110 | 0 | attributeEntry = new HashMap<String,Object>(); |
111 | 0 | } |
112 | |
|
113 | |
public String getRoleId() { |
114 | 0 | return this.roleId; |
115 | |
} |
116 | |
|
117 | |
public void setRoleId(String roleId) { |
118 | 0 | this.roleId = roleId; |
119 | 0 | } |
120 | |
|
121 | |
public String getKimTypeId() { |
122 | 0 | return this.kimTypeId; |
123 | |
} |
124 | |
|
125 | |
public void setKimTypeId(String kimTypeId) { |
126 | 0 | this.kimTypeId = kimTypeId; |
127 | 0 | } |
128 | |
|
129 | |
public String getRoleName() { |
130 | 0 | return this.roleName; |
131 | |
} |
132 | |
|
133 | |
public void setRoleName(String roleName) { |
134 | 0 | this.roleName = roleName; |
135 | 0 | } |
136 | |
|
137 | |
public List<? extends KimAttributes> getAttributes() { |
138 | 0 | return this.attributes; |
139 | |
} |
140 | |
|
141 | |
public void setAttributes(List<? extends KimAttributes> attributes) { |
142 | 0 | this.attributes = attributes; |
143 | 0 | } |
144 | |
|
145 | |
public KimTypeBo getKimRoleType() { |
146 | 0 | if ( kimRoleType == null ) { |
147 | 0 | kimRoleType = KimTypeBo.from(KimApiServiceLocator.getKimTypeInfoService().getKimType(kimTypeId)); |
148 | |
} |
149 | 0 | return kimRoleType; |
150 | |
} |
151 | |
|
152 | |
public List<KimAttributeField> getDefinitions() { |
153 | 0 | if (definitions == null || definitions.isEmpty()) { |
154 | 0 | KimTypeService kimTypeService = KimFrameworkServiceLocator.getKimTypeService(KimTypeBo.to( |
155 | |
this.getKimRoleType())); |
156 | |
|
157 | |
|
158 | |
try { |
159 | 0 | if ( kimTypeService != null ) { |
160 | 0 | definitions = kimTypeService.getAttributeDefinitions(getKimTypeId()); |
161 | |
} else { |
162 | 0 | definitions = Collections.emptyList(); |
163 | |
} |
164 | 0 | } catch (Exception ex) { |
165 | 0 | LOG.warn("Not able to retrieve KimTypeService from remote system for KIM Role Type: " + this.getKimRoleType(), ex); |
166 | 0 | } |
167 | |
} |
168 | |
|
169 | 0 | return definitions; |
170 | |
} |
171 | |
|
172 | |
public void setDefinitions(List<KimAttributeField> definitions) { |
173 | 0 | this.definitions = definitions; |
174 | 0 | } |
175 | |
|
176 | |
public Map<String,Object> getAttributeEntry() { |
177 | 0 | if (attributeEntry == null || attributeEntry.isEmpty()) { |
178 | 0 | attributeEntry = KIMServiceLocatorInternal.getUiDocumentService().getAttributeEntries(getDefinitions()); |
179 | |
} |
180 | |
|
181 | 0 | return this.attributeEntry; |
182 | |
} |
183 | |
|
184 | |
public void setAttributeEntry(Map<String,Object> attributeEntry) { |
185 | 0 | this.attributeEntry = attributeEntry; |
186 | 0 | } |
187 | |
|
188 | |
public List<KimDocumentRoleMember> getRolePrncpls() { |
189 | 0 | return this.rolePrncpls; |
190 | |
} |
191 | |
|
192 | |
public void setRolePrncpls(List<KimDocumentRoleMember> rolePrncpls) { |
193 | 0 | this.rolePrncpls = rolePrncpls; |
194 | 0 | } |
195 | |
|
196 | |
public KimDocumentRoleMember getNewRolePrncpl() { |
197 | 0 | return this.newRolePrncpl; |
198 | |
} |
199 | |
|
200 | |
public void setNewRolePrncpl(KimDocumentRoleMember newRolePrncpl) { |
201 | 0 | this.newRolePrncpl = newRolePrncpl; |
202 | 0 | } |
203 | |
|
204 | |
public String getNamespaceCode() { |
205 | 0 | return this.namespaceCode; |
206 | |
} |
207 | |
|
208 | |
public void setNamespaceCode(String namespaceCode) { |
209 | 0 | this.namespaceCode = namespaceCode; |
210 | 0 | } |
211 | |
|
212 | |
public List<RoleResponsibilityBo> getAssignedResponsibilities() { |
213 | 0 | return this.assignedResponsibilities; |
214 | |
} |
215 | |
|
216 | |
public void setAssignedResponsibilities( |
217 | |
List<RoleResponsibilityBo> assignedResponsibilities) { |
218 | 0 | this.assignedResponsibilities = assignedResponsibilities; |
219 | 0 | } |
220 | |
|
221 | |
|
222 | |
|
223 | |
|
224 | |
public RoleBo getRoleBo() { |
225 | 0 | return this.roleBo; |
226 | |
} |
227 | |
|
228 | |
|
229 | |
|
230 | |
|
231 | |
public void setRoleBo(RoleBo roleBo) { |
232 | 0 | this.roleBo = roleBo; |
233 | 0 | } |
234 | |
|
235 | |
|
236 | |
|
237 | |
|
238 | |
public boolean isEditable() { |
239 | 0 | return this.isEditable; |
240 | |
} |
241 | |
|
242 | |
|
243 | |
|
244 | |
|
245 | |
public void setEditable(boolean isEditable) { |
246 | 0 | this.isEditable = isEditable; |
247 | 0 | } |
248 | |
|
249 | |
} |