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.GenericGenerator; |
19 | |
import org.hibernate.annotations.Parameter; |
20 | |
import org.kuali.rice.kim.api.group.Group; |
21 | |
import org.kuali.rice.kim.api.identity.principal.Principal; |
22 | |
import org.kuali.rice.kim.api.role.Role; |
23 | |
import org.kuali.rice.kim.api.services.KimApiServiceLocator; |
24 | |
import org.kuali.rice.kim.util.KimConstants; |
25 | |
import org.springframework.util.AutoPopulatingList; |
26 | |
|
27 | |
import javax.persistence.CascadeType; |
28 | |
import javax.persistence.Column; |
29 | |
import javax.persistence.Entity; |
30 | |
import javax.persistence.FetchType; |
31 | |
import javax.persistence.GeneratedValue; |
32 | |
import javax.persistence.Id; |
33 | |
import javax.persistence.IdClass; |
34 | |
import javax.persistence.JoinColumn; |
35 | |
import javax.persistence.JoinColumns; |
36 | |
import javax.persistence.OneToMany; |
37 | |
import javax.persistence.Table; |
38 | |
import javax.persistence.Transient; |
39 | |
import java.util.ArrayList; |
40 | |
import java.util.HashMap; |
41 | |
import java.util.List; |
42 | |
import java.util.Map; |
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
@IdClass(KimDocumentRoleMemberId.class) |
51 | |
@Entity |
52 | |
@Table(name="KRIM_PND_ROLE_MBR_MT") |
53 | |
public class KimDocumentRoleMember extends KimDocumentBoActivatableToFromEditableBase { |
54 | |
private static final long serialVersionUID = -2463865643038170979L; |
55 | |
|
56 | |
@Id |
57 | |
@GeneratedValue(generator="KRIM_ROLE_MBR_ID_S") |
58 | |
@GenericGenerator(name="KRIM_ROLE_MBR_ID_S",strategy="org.kuali.rice.core.jpa.spring.RiceNumericStringSequenceStyleGenerator",parameters={ |
59 | |
@Parameter(name="sequence_name",value="KRIM_ROLE_MBR_ID_S"), |
60 | |
@Parameter(name="value_column",value="id") |
61 | |
}) |
62 | |
@Column(name="ROLE_MBR_ID") |
63 | |
protected String roleMemberId; |
64 | |
|
65 | |
@Column(name="ROLE_ID") |
66 | |
protected String roleId; |
67 | |
@Column(name="MBR_ID") |
68 | |
protected String memberId; |
69 | |
|
70 | |
|
71 | 0 | @Column(name="MBR_TYP_CD") |
72 | |
protected String memberTypeCode = KimConstants.KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE; |
73 | |
@Transient |
74 | |
protected String memberName; |
75 | |
@Transient |
76 | |
protected String memberNamespaceCode; |
77 | |
|
78 | |
protected String memberFullName; |
79 | |
|
80 | 0 | @OneToMany(fetch=FetchType.LAZY,cascade=CascadeType.ALL) |
81 | |
@JoinColumns({ |
82 | |
@JoinColumn(name="ROLE_MBR_ID", insertable = false, updatable = false), |
83 | |
@JoinColumn(name="FDOC_NBR", insertable = false, updatable = false) |
84 | |
}) |
85 | |
protected List <KimDocumentRoleQualifier> qualifiers = new AutoPopulatingList(KimDocumentRoleQualifier.class); |
86 | |
@Transient |
87 | |
protected String qualifiersToDisplay; |
88 | |
|
89 | |
@OneToMany(fetch=FetchType.LAZY,cascade=CascadeType.ALL) |
90 | |
@JoinColumns({ |
91 | |
@JoinColumn(name="ROLE_MBR_ID", insertable = false, updatable = false), |
92 | |
@JoinColumn(name="FDOC_NBR", insertable = false, updatable = false) |
93 | |
}) |
94 | |
private List<KimDocumentRoleResponsibilityAction> roleRspActions; |
95 | |
|
96 | 0 | public KimDocumentRoleMember() { |
97 | 0 | qualifiers = new ArrayList <KimDocumentRoleQualifier>(); |
98 | 0 | roleRspActions = new ArrayList <KimDocumentRoleResponsibilityAction>(); |
99 | 0 | } |
100 | |
|
101 | |
public int getNumberOfQualifiers(){ |
102 | 0 | return qualifiers==null?0:qualifiers.size(); |
103 | |
} |
104 | |
|
105 | |
|
106 | |
|
107 | |
|
108 | |
public String getMemberId() { |
109 | 0 | return this.memberId; |
110 | |
} |
111 | |
|
112 | |
|
113 | |
|
114 | |
|
115 | |
public void setMemberId(String memberId) { |
116 | 0 | this.memberId = memberId; |
117 | 0 | } |
118 | |
|
119 | |
public String getRoleMemberId() { |
120 | 0 | return this.roleMemberId; |
121 | |
} |
122 | |
|
123 | |
public void setRoleMemberId(String roleMemberId) { |
124 | 0 | this.roleMemberId = roleMemberId; |
125 | 0 | } |
126 | |
|
127 | |
public String getRoleId() { |
128 | 0 | return this.roleId; |
129 | |
} |
130 | |
|
131 | |
public void setRoleId(String roleId) { |
132 | 0 | this.roleId = roleId; |
133 | 0 | } |
134 | |
|
135 | |
public KimDocumentRoleQualifier getQualifier(String kimAttributeDefnId) { |
136 | 0 | for(KimDocumentRoleQualifier qualifier:qualifiers){ |
137 | 0 | if(qualifier.getKimAttrDefnId().equals(kimAttributeDefnId)) { |
138 | 0 | return qualifier; |
139 | |
} |
140 | |
} |
141 | 0 | return null; |
142 | |
} |
143 | |
|
144 | |
public List<KimDocumentRoleQualifier> getQualifiers() { |
145 | 0 | return this.qualifiers; |
146 | |
} |
147 | |
|
148 | |
public void setQualifiers(List<KimDocumentRoleQualifier> qualifiers) { |
149 | 0 | this.qualifiers = qualifiers; |
150 | 0 | } |
151 | |
|
152 | |
|
153 | |
|
154 | |
|
155 | |
public String getMemberTypeCode() { |
156 | 0 | return this.memberTypeCode; |
157 | |
} |
158 | |
|
159 | |
|
160 | |
|
161 | |
|
162 | |
public void setMemberTypeCode(String memberTypeCode) { |
163 | 0 | this.memberTypeCode = memberTypeCode; |
164 | 0 | } |
165 | |
|
166 | |
|
167 | |
|
168 | |
|
169 | |
public String getMemberName() { |
170 | 0 | if ( memberName == null ) { |
171 | 0 | populateDerivedValues(); |
172 | |
} |
173 | 0 | return memberName; |
174 | |
} |
175 | |
|
176 | |
|
177 | |
|
178 | |
|
179 | |
public void setMemberName(String memberName) { |
180 | 0 | this.memberName = memberName; |
181 | 0 | } |
182 | |
|
183 | |
public List<KimDocumentRoleResponsibilityAction> getRoleRspActions() { |
184 | 0 | return this.roleRspActions; |
185 | |
} |
186 | |
|
187 | |
public void setRoleRspActions( |
188 | |
List<KimDocumentRoleResponsibilityAction> roleRspActions) { |
189 | 0 | this.roleRspActions = roleRspActions; |
190 | 0 | } |
191 | |
|
192 | |
|
193 | |
|
194 | |
|
195 | |
public String getMemberNamespaceCode() { |
196 | 0 | if ( memberNamespaceCode == null ) { |
197 | 0 | populateDerivedValues(); |
198 | |
} |
199 | 0 | return memberNamespaceCode; |
200 | |
} |
201 | |
|
202 | |
|
203 | |
|
204 | |
|
205 | |
public void setMemberNamespaceCode(String memberNamespaceCode) { |
206 | 0 | this.memberNamespaceCode = memberNamespaceCode; |
207 | 0 | } |
208 | |
|
209 | |
protected void populateDerivedValues() { |
210 | 0 | if(KimConstants.KimUIConstants.MEMBER_TYPE_PRINCIPAL_CODE.equals(getMemberTypeCode())){ |
211 | 0 | Principal principalInfo = KimApiServiceLocator.getIdentityService().getPrincipal(getMemberId()); |
212 | 0 | if (principalInfo != null) { |
213 | 0 | setMemberName(principalInfo.getPrincipalName()); |
214 | |
} |
215 | 0 | } else if(KimConstants.KimUIConstants.MEMBER_TYPE_GROUP_CODE.equals(getMemberTypeCode())){ |
216 | 0 | Group groupInfo = KimApiServiceLocator.getGroupService().getGroup(getMemberId()); |
217 | 0 | if (groupInfo != null) { |
218 | 0 | setMemberName(groupInfo.getName()); |
219 | 0 | setMemberNamespaceCode(groupInfo.getNamespaceCode()); |
220 | |
} |
221 | |
|
222 | 0 | } else if(KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE.equals(getMemberTypeCode())){ |
223 | 0 | Role role = KimApiServiceLocator.getRoleService().getRole(getMemberId()); |
224 | 0 | setMemberName(role.getName()); |
225 | 0 | setMemberNamespaceCode(role.getNamespaceCode()); |
226 | |
} |
227 | 0 | } |
228 | |
|
229 | |
public boolean isRole(){ |
230 | 0 | return getMemberTypeCode()!=null && getMemberTypeCode().equals(KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE); |
231 | |
} |
232 | |
|
233 | |
public boolean isGroup(){ |
234 | 0 | return getMemberTypeCode()!=null && getMemberTypeCode().equals(KimConstants.KimUIConstants.MEMBER_TYPE_GROUP_CODE); |
235 | |
} |
236 | |
|
237 | |
public boolean isPrincipal(){ |
238 | 0 | return getMemberTypeCode()!=null && getMemberTypeCode().equals(KimConstants.KimUIConstants.MEMBER_TYPE_PRINCIPAL_CODE); |
239 | |
} |
240 | |
|
241 | |
public Map<String, String> getQualifierAsMap() { |
242 | 0 | Map<String, String> m = new HashMap<String, String>(); |
243 | 0 | for ( KimDocumentRoleQualifier data : getQualifiers() ) { |
244 | 0 | if (data.getKimAttribute() == null){ |
245 | 0 | data.refreshReferenceObject("kimAttribute"); |
246 | |
} |
247 | 0 | if (data.getKimAttribute() != null){ |
248 | 0 | m.put( data.getKimAttribute().getAttributeName(), data.getAttrVal() ); |
249 | |
} |
250 | |
} |
251 | 0 | return m; |
252 | |
} |
253 | |
|
254 | |
|
255 | |
|
256 | |
|
257 | |
public String getQualifiersToDisplay() { |
258 | 0 | return this.qualifiersToDisplay; |
259 | |
} |
260 | |
|
261 | |
|
262 | |
|
263 | |
|
264 | |
public void setQualifiersToDisplay(String qualifiersToDisplay) { |
265 | 0 | this.qualifiersToDisplay = qualifiersToDisplay; |
266 | 0 | } |
267 | |
|
268 | |
|
269 | |
|
270 | |
|
271 | |
public String getMemberFullName() { |
272 | 0 | return this.memberFullName; |
273 | |
} |
274 | |
|
275 | |
|
276 | |
|
277 | |
|
278 | |
public void setMemberFullName(String memberFullName) { |
279 | 0 | this.memberFullName = memberFullName; |
280 | 0 | } |
281 | |
|
282 | |
} |