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