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