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.hibernate.annotations.Fetch; |
19 | |
import org.hibernate.annotations.FetchMode; |
20 | |
import org.hibernate.annotations.GenericGenerator; |
21 | |
import org.hibernate.annotations.Parameter; |
22 | |
import org.kuali.rice.kew.util.KEWConstants; |
23 | |
import org.kuali.rice.kim.api.group.Group; |
24 | |
import org.kuali.rice.kim.api.services.KimApiServiceLocator; |
25 | |
import org.kuali.rice.kim.bo.impl.RoleImpl; |
26 | |
import org.kuali.rice.kim.bo.role.dto.KimRoleInfo; |
27 | |
import org.kuali.rice.kim.document.KimTypeAttributesHelper; |
28 | |
import org.kuali.rice.kim.impl.type.KimTypeBo; |
29 | |
import org.kuali.rice.kim.util.KimConstants; |
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.GeneratedValue; |
37 | |
import javax.persistence.Id; |
38 | |
import javax.persistence.IdClass; |
39 | |
import javax.persistence.JoinColumn; |
40 | |
import javax.persistence.JoinColumns; |
41 | |
import javax.persistence.OneToMany; |
42 | |
import javax.persistence.Table; |
43 | |
import javax.persistence.Transient; |
44 | |
import java.util.List; |
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
@IdClass(RoleDocumentDelegationMemberId.class) |
53 | |
@Entity |
54 | |
@Table(name="KRIM_PND_DLGN_MBR_T") |
55 | 0 | public class RoleDocumentDelegationMember extends KimDocumentBoActivatableToFromBase { |
56 | |
|
57 | |
private static final long serialVersionUID = 1L; |
58 | |
|
59 | |
@Id |
60 | |
@GeneratedValue(generator="KRIM_DLGN_MBR_ID_S") |
61 | |
@GenericGenerator(name="KRIM_DLGN_MBR_ID_S",strategy="org.kuali.rice.core.jpa.spring.RiceNumericStringSequenceStyleGenerator",parameters={ |
62 | |
@Parameter(name="sequence_name",value="KRIM_DLGN_MBR_ID_S"), |
63 | |
@Parameter(name="value_column",value="id") |
64 | |
}) |
65 | |
@Column(name="DLGN_MBR_ID") |
66 | |
protected String delegationMemberId; |
67 | |
|
68 | |
@Column(name="ROLE_MBR_ID") |
69 | |
protected String roleMemberId; |
70 | |
@Transient |
71 | |
protected String roleMemberMemberId; |
72 | |
@Transient |
73 | |
protected String roleMemberMemberTypeCode; |
74 | |
@Transient |
75 | |
protected String roleMemberName; |
76 | |
@Transient |
77 | |
protected String roleMemberNamespaceCode; |
78 | |
|
79 | |
@Transient |
80 | |
private KimTypeAttributesHelper attributesHelper; |
81 | |
|
82 | 0 | @Transient |
83 | |
protected RoleImpl roleImpl = new RoleImpl(); |
84 | |
|
85 | |
@Column(name="DLGN_ID") |
86 | |
protected String delegationId; |
87 | |
|
88 | |
@Column(name="MBR_ID") |
89 | |
protected String memberId; |
90 | |
|
91 | 0 | @Column(name="MBR_TYP_CD") |
92 | |
protected String memberTypeCode = KimConstants.KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE; |
93 | |
|
94 | |
@Transient |
95 | |
protected String memberNamespaceCode; |
96 | |
|
97 | |
@Column(name="MBR_NM") |
98 | |
protected String memberName; |
99 | 0 | @OneToMany(targetEntity=RoleDocumentDelegationMemberQualifier.class, fetch=FetchType.EAGER, cascade={CascadeType.ALL}) |
100 | |
@Fetch(value = FetchMode.SELECT) |
101 | |
@JoinColumns({ |
102 | |
@JoinColumn(name="dlgn_id",insertable=false,updatable=false), |
103 | |
@JoinColumn(name="fdoc_nbr", insertable=false, updatable=false) |
104 | |
}) |
105 | |
protected List <RoleDocumentDelegationMemberQualifier> qualifiers = new AutoPopulatingList(RoleDocumentDelegationMemberQualifier.class); |
106 | |
|
107 | |
@Transient |
108 | |
protected String delegationTypeCode; |
109 | |
|
110 | |
|
111 | |
|
112 | |
|
113 | |
public String getDelegationTypeCode() { |
114 | 0 | return this.delegationTypeCode; |
115 | |
} |
116 | |
|
117 | |
|
118 | |
|
119 | |
|
120 | |
public void setDelegationTypeCode(String delegationTypeCode) { |
121 | 0 | this.delegationTypeCode = delegationTypeCode; |
122 | 0 | } |
123 | |
|
124 | |
public String getDelegationId() { |
125 | 0 | return this.delegationId; |
126 | |
} |
127 | |
|
128 | |
public void setDelegationId(String delegationId) { |
129 | 0 | this.delegationId = delegationId; |
130 | 0 | } |
131 | |
|
132 | |
|
133 | |
|
134 | |
|
135 | |
public List<RoleDocumentDelegationMemberQualifier> getQualifiers() { |
136 | 0 | return this.qualifiers; |
137 | |
} |
138 | |
|
139 | |
public RoleDocumentDelegationMemberQualifier getQualifier(String kimAttributeDefnId) { |
140 | 0 | for(RoleDocumentDelegationMemberQualifier qualifier:qualifiers){ |
141 | 0 | if(qualifier.getKimAttrDefnId().equals(kimAttributeDefnId)) |
142 | 0 | return qualifier; |
143 | |
} |
144 | 0 | return null; |
145 | |
} |
146 | |
|
147 | |
|
148 | |
|
149 | |
|
150 | |
public void setQualifiers(List<RoleDocumentDelegationMemberQualifier> qualifiers) { |
151 | 0 | this.qualifiers = qualifiers; |
152 | 0 | } |
153 | |
|
154 | |
public int getNumberOfQualifiers(){ |
155 | 0 | return qualifiers==null?0:qualifiers.size(); |
156 | |
} |
157 | |
|
158 | |
|
159 | |
|
160 | |
|
161 | |
public String getMemberId() { |
162 | 0 | return this.memberId; |
163 | |
} |
164 | |
|
165 | |
|
166 | |
|
167 | |
|
168 | |
public void setMemberId(String memberId) { |
169 | 0 | this.memberId = memberId; |
170 | 0 | } |
171 | |
|
172 | |
|
173 | |
|
174 | |
|
175 | |
public String getMemberName() { |
176 | 0 | return this.memberName; |
177 | |
} |
178 | |
|
179 | |
|
180 | |
|
181 | |
|
182 | |
public void setMemberName(String memberName) { |
183 | 0 | this.memberName = memberName; |
184 | 0 | } |
185 | |
|
186 | |
|
187 | |
|
188 | |
|
189 | |
public String getDelegationMemberId() { |
190 | 0 | return this.delegationMemberId; |
191 | |
} |
192 | |
|
193 | |
|
194 | |
|
195 | |
|
196 | |
public void setDelegationMemberId(String delegationMemberId) { |
197 | 0 | this.delegationMemberId = delegationMemberId; |
198 | 0 | } |
199 | |
|
200 | |
|
201 | |
|
202 | |
|
203 | |
public String getMemberTypeCode() { |
204 | 0 | return this.memberTypeCode; |
205 | |
} |
206 | |
|
207 | |
|
208 | |
|
209 | |
|
210 | |
public void setMemberTypeCode(String memberTypeCode) { |
211 | 0 | this.memberTypeCode = memberTypeCode; |
212 | 0 | } |
213 | |
|
214 | |
|
215 | |
public boolean isDelegationPrimary(){ |
216 | 0 | return KEWConstants.DELEGATION_PRIMARY.equals(getDelegationTypeCode()); |
217 | |
} |
218 | |
|
219 | |
public boolean isDelegationSecondary(){ |
220 | 0 | return KEWConstants.DELEGATION_SECONDARY.equals(getDelegationTypeCode()); |
221 | |
} |
222 | |
|
223 | |
|
224 | |
|
225 | |
|
226 | |
public String getMemberNamespaceCode() { |
227 | 0 | if ( memberNamespaceCode == null ) { |
228 | 0 | populateDerivedValues(); |
229 | |
} |
230 | 0 | return this.memberNamespaceCode; |
231 | |
} |
232 | |
|
233 | |
|
234 | |
|
235 | |
|
236 | |
public void setMemberNamespaceCode(String memberNamespaceCode) { |
237 | 0 | this.memberNamespaceCode = memberNamespaceCode; |
238 | 0 | } |
239 | |
|
240 | |
protected void populateDerivedValues() { |
241 | 0 | if(KimConstants.KimUIConstants.MEMBER_TYPE_GROUP_CODE.equals(getMemberTypeCode())){ |
242 | 0 | Group groupInfo = null; |
243 | 0 | groupInfo = KimApiServiceLocator.getIdentityManagementService().getGroup(getMemberId()); |
244 | 0 | if (groupInfo != null) { |
245 | 0 | setMemberNamespaceCode(groupInfo.getNamespaceCode()); |
246 | |
} |
247 | 0 | } else if(KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE.equals(getMemberTypeCode())){ |
248 | 0 | KimRoleInfo roleInfo = null; |
249 | 0 | roleInfo = KimApiServiceLocator.getRoleService().getRole(getMemberId()); |
250 | 0 | setMemberNamespaceCode(roleInfo.getNamespaceCode()); |
251 | |
} |
252 | 0 | } |
253 | |
|
254 | |
|
255 | |
|
256 | |
|
257 | |
public String getRoleMemberId() { |
258 | 0 | return this.roleMemberId; |
259 | |
} |
260 | |
|
261 | |
|
262 | |
|
263 | |
|
264 | |
public void setRoleMemberId(String roleMemberId) { |
265 | 0 | this.roleMemberId = roleMemberId; |
266 | 0 | } |
267 | |
|
268 | |
public boolean isRole(){ |
269 | 0 | return getMemberTypeCode()!=null && getMemberTypeCode().equals(KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE); |
270 | |
} |
271 | |
|
272 | |
public boolean isGroup(){ |
273 | 0 | return getMemberTypeCode()!=null && getMemberTypeCode().equals(KimConstants.KimUIConstants.MEMBER_TYPE_GROUP_CODE); |
274 | |
} |
275 | |
|
276 | |
public boolean isPrincipal(){ |
277 | 0 | return getMemberTypeCode()!=null && getMemberTypeCode().equals(KimConstants.KimUIConstants.MEMBER_TYPE_PRINCIPAL_CODE); |
278 | |
} |
279 | |
|
280 | |
|
281 | |
|
282 | |
|
283 | |
public String getRoleMemberName() { |
284 | 0 | return this.roleMemberName; |
285 | |
} |
286 | |
|
287 | |
|
288 | |
|
289 | |
|
290 | |
public void setRoleMemberName(String roleMemberName) { |
291 | 0 | this.roleMemberName = roleMemberName; |
292 | 0 | } |
293 | |
|
294 | |
|
295 | |
|
296 | |
|
297 | |
public String getRoleMemberNamespaceCode() { |
298 | 0 | return this.roleMemberNamespaceCode; |
299 | |
} |
300 | |
|
301 | |
|
302 | |
|
303 | |
|
304 | |
public void setRoleMemberNamespaceCode(String roleMemberNamespaceCode) { |
305 | 0 | this.roleMemberNamespaceCode = roleMemberNamespaceCode; |
306 | 0 | } |
307 | |
|
308 | |
|
309 | |
|
310 | |
|
311 | |
public RoleImpl getRoleImpl() { |
312 | 0 | return this.roleImpl; |
313 | |
} |
314 | |
|
315 | |
|
316 | |
|
317 | |
|
318 | |
public void setRoleImpl(RoleImpl roleImpl) { |
319 | 0 | this.roleImpl = roleImpl; |
320 | 0 | setAttributesHelper(new KimTypeAttributesHelper(KimTypeBo.to(roleImpl.getKimRoleType()))); |
321 | 0 | } |
322 | |
|
323 | |
|
324 | |
|
325 | |
|
326 | |
public KimTypeAttributesHelper getAttributesHelper() { |
327 | 0 | return this.attributesHelper; |
328 | |
} |
329 | |
|
330 | |
|
331 | |
|
332 | |
|
333 | |
public void setAttributesHelper(KimTypeAttributesHelper attributesHelper) { |
334 | 0 | this.attributesHelper = attributesHelper; |
335 | 0 | } |
336 | |
|
337 | |
|
338 | |
|
339 | |
|
340 | |
public String getRoleMemberMemberId() { |
341 | 0 | return this.roleMemberMemberId; |
342 | |
} |
343 | |
|
344 | |
|
345 | |
|
346 | |
|
347 | |
public void setRoleMemberMemberId(String roleMemberMemberId) { |
348 | 0 | this.roleMemberMemberId = roleMemberMemberId; |
349 | 0 | } |
350 | |
|
351 | |
|
352 | |
|
353 | |
|
354 | |
public String getRoleMemberMemberTypeCode() { |
355 | 0 | return this.roleMemberMemberTypeCode; |
356 | |
} |
357 | |
|
358 | |
|
359 | |
|
360 | |
|
361 | |
public void setRoleMemberMemberTypeCode(String roleMemberMemberTypeCode) { |
362 | 0 | this.roleMemberMemberTypeCode = roleMemberMemberTypeCode; |
363 | 0 | } |
364 | |
} |