1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kim.web.struts.form; |
17 | |
|
18 | |
import org.apache.commons.lang.StringUtils; |
19 | |
import org.kuali.rice.core.web.format.DateDisplayTimestampObjectFormatter; |
20 | |
import org.kuali.rice.kim.api.type.KimType; |
21 | |
import org.kuali.rice.kim.bo.impl.PersonImpl; |
22 | |
import org.kuali.rice.kim.impl.role.RoleBo; |
23 | |
import org.kuali.rice.kim.bo.ui.KimDocumentRoleMember; |
24 | |
import org.kuali.rice.kim.bo.ui.KimDocumentRolePermission; |
25 | |
import org.kuali.rice.kim.bo.ui.KimDocumentRoleQualifier; |
26 | |
import org.kuali.rice.kim.bo.ui.KimDocumentRoleResponsibility; |
27 | |
import org.kuali.rice.kim.bo.ui.RoleDocumentDelegationMember; |
28 | |
import org.kuali.rice.kim.bo.ui.RoleDocumentDelegationMemberQualifier; |
29 | |
import org.kuali.rice.kim.document.IdentityManagementRoleDocument; |
30 | |
import org.kuali.rice.kim.impl.group.GroupBo; |
31 | |
import org.kuali.rice.kim.util.KimConstants; |
32 | |
import org.kuali.rice.kns.util.TableRenderUtil; |
33 | |
|
34 | |
import java.util.List; |
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
public class IdentityManagementRoleDocumentForm extends IdentityManagementDocumentFormBase { |
43 | |
protected static final long serialVersionUID = 7099079353241080483L; |
44 | |
{ |
45 | 0 | requiredNonEditableProperties.add("methodToCall"); |
46 | 0 | requiredNonEditableProperties.add("roleCommand"); |
47 | |
} |
48 | |
|
49 | |
protected String delegationMemberRoleMemberId; |
50 | |
protected String dmrmi; |
51 | 0 | protected boolean canAssignRole = true; |
52 | 0 | protected boolean canModifyAssignees = true; |
53 | |
protected KimType kimType; |
54 | |
protected KimDocumentRoleMember member; |
55 | |
{ |
56 | 0 | member = new KimDocumentRoleMember(); |
57 | 0 | member.getQualifiers().add(new KimDocumentRoleQualifier()); |
58 | |
} |
59 | |
protected KimDocumentRolePermission permission; |
60 | |
protected KimDocumentRoleResponsibility responsibility; |
61 | |
protected RoleDocumentDelegationMember delegationMember; |
62 | |
{ |
63 | 0 | delegationMember = new RoleDocumentDelegationMember(); |
64 | 0 | delegationMember.getQualifiers().add(new RoleDocumentDelegationMemberQualifier()); |
65 | |
} |
66 | |
protected String roleId; |
67 | |
|
68 | |
|
69 | |
public IdentityManagementRoleDocumentForm() { |
70 | 0 | super(); |
71 | 0 | setFormatterType("document.members.activeFromDate", DateDisplayTimestampObjectFormatter.class); |
72 | 0 | setFormatterType("document.delegationMembers.activeFromDate", DateDisplayTimestampObjectFormatter.class); |
73 | 0 | setFormatterType("document.members.activeToDate", DateDisplayTimestampObjectFormatter.class); |
74 | 0 | setFormatterType("document.delegationMembers.activeToDate", DateDisplayTimestampObjectFormatter.class); |
75 | 0 | } |
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
public RoleDocumentDelegationMember getDelegationMember() { |
81 | 0 | return this.delegationMember; |
82 | |
} |
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
public void setDelegationMember(RoleDocumentDelegationMember delegationMember) { |
88 | 0 | this.delegationMember = delegationMember; |
89 | 0 | } |
90 | |
|
91 | |
@Override |
92 | |
public String getDefaultDocumentTypeName(){ |
93 | 0 | return "IdentityManagementRoleDocument"; |
94 | |
} |
95 | |
|
96 | |
public IdentityManagementRoleDocument getRoleDocument() { |
97 | 0 | return (IdentityManagementRoleDocument) this.getDocument(); |
98 | |
} |
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | |
public KimDocumentRoleMember getMember() { |
104 | 0 | return this.member; |
105 | |
} |
106 | |
|
107 | |
|
108 | |
|
109 | |
|
110 | |
public void setMember(KimDocumentRoleMember member) { |
111 | 0 | this.member = member; |
112 | 0 | } |
113 | |
|
114 | |
|
115 | |
|
116 | |
|
117 | |
public KimDocumentRolePermission getPermission() { |
118 | 0 | return this.permission; |
119 | |
} |
120 | |
|
121 | |
|
122 | |
|
123 | |
|
124 | |
public void setPermission(KimDocumentRolePermission permission) { |
125 | 0 | this.permission = permission; |
126 | 0 | } |
127 | |
|
128 | |
|
129 | |
|
130 | |
|
131 | |
public KimDocumentRoleResponsibility getResponsibility() { |
132 | 0 | return this.responsibility; |
133 | |
} |
134 | |
|
135 | |
|
136 | |
|
137 | |
|
138 | |
public void setResponsibility(KimDocumentRoleResponsibility responsibility) { |
139 | 0 | this.responsibility = responsibility; |
140 | 0 | } |
141 | |
|
142 | |
public String getMemberFieldConversions(){ |
143 | 0 | if(member==null) { |
144 | 0 | return ""; |
145 | |
} |
146 | 0 | return getMemberFieldConversions(member.getMemberTypeCode()); |
147 | |
} |
148 | |
|
149 | |
public String getMemberBusinessObjectName(){ |
150 | 0 | if(member==null) { |
151 | 0 | return ""; |
152 | |
} |
153 | 0 | return getMemberBusinessObjectName(member.getMemberTypeCode()); |
154 | |
} |
155 | |
|
156 | |
public String getDelegationMemberFieldConversions(){ |
157 | 0 | if(getDelegationMember()==null) { |
158 | 0 | return ""; |
159 | |
} |
160 | 0 | String memberTypeCode = getDelegationMember().getMemberTypeCode(); |
161 | 0 | if(KimConstants.KimUIConstants.MEMBER_TYPE_PRINCIPAL_CODE.equals(memberTypeCode)) { |
162 | 0 | return "principalId:delegationMember.memberId,principalName:delegationMember.memberName"; |
163 | |
} |
164 | 0 | else if(KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE.equals(memberTypeCode)) { |
165 | 0 | return "roleId:delegationMember.memberId,roleName:delegationMember.memberName,namespaceCode:delegationMember.memberNamespaceCode"; |
166 | |
} |
167 | 0 | else if(KimConstants.KimUIConstants.MEMBER_TYPE_GROUP_CODE.equals(memberTypeCode)) { |
168 | 0 | return "groupId:delegationMember.memberId,groupName:delegationMember.memberName,namespaceCode:delegationMember.memberNamespaceCode"; |
169 | |
} |
170 | 0 | return ""; |
171 | |
} |
172 | |
|
173 | |
public String getDelegationMemberBusinessObjectName(){ |
174 | 0 | if(getDelegationMember()==null) { |
175 | 0 | return ""; |
176 | |
} |
177 | 0 | return getMemberBusinessObjectName(getDelegationMember().getMemberTypeCode()); |
178 | |
} |
179 | |
|
180 | |
protected String getMemberFieldConversions(String memberTypeCode){ |
181 | 0 | if(KimConstants.KimUIConstants.MEMBER_TYPE_PRINCIPAL_CODE.equals(memberTypeCode)) { |
182 | 0 | return "principalId:member.memberId,principalName:member.memberName"; |
183 | |
} |
184 | 0 | else if(KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE.equals(memberTypeCode)) { |
185 | 0 | return "roleId:member.memberId,roleName:member.memberName,namespaceCode:member.memberNamespaceCode"; |
186 | |
} |
187 | 0 | else if(KimConstants.KimUIConstants.MEMBER_TYPE_GROUP_CODE.equals(memberTypeCode)) { |
188 | 0 | return "groupId:member.memberId,groupName:member.memberName,namespaceCode:member.memberNamespaceCode"; |
189 | |
} |
190 | 0 | return ""; |
191 | |
} |
192 | |
|
193 | |
protected String getMemberBusinessObjectName(String memberTypeCode){ |
194 | 0 | if(KimConstants.KimUIConstants.MEMBER_TYPE_PRINCIPAL_CODE.equals(memberTypeCode)) { |
195 | 0 | return PersonImpl.class.getName(); |
196 | |
} |
197 | 0 | else if(KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE.equals(memberTypeCode)) { |
198 | 0 | return RoleBo.class.getName(); |
199 | |
} |
200 | 0 | else if(KimConstants.KimUIConstants.MEMBER_TYPE_GROUP_CODE.equals(memberTypeCode)) { |
201 | 0 | return GroupBo.class.getName(); |
202 | |
} |
203 | 0 | return ""; |
204 | |
} |
205 | |
|
206 | |
|
207 | |
|
208 | |
|
209 | |
public KimType getKimType() { |
210 | 0 | return this.kimType; |
211 | |
} |
212 | |
|
213 | |
|
214 | |
|
215 | |
|
216 | |
public void setKimType(KimType kimType) { |
217 | 0 | this.kimType = kimType; |
218 | 0 | if ( kimType != null && getRoleDocument() != null ) { |
219 | 0 | getRoleDocument().setKimType(kimType); |
220 | |
} |
221 | 0 | } |
222 | |
|
223 | |
|
224 | |
|
225 | |
|
226 | |
public boolean isCanAssignRole() { |
227 | 0 | return this.canAssignRole; |
228 | |
} |
229 | |
|
230 | |
|
231 | |
|
232 | |
|
233 | |
public void setCanAssignRole(boolean canAssignRole) { |
234 | 0 | this.canAssignRole = canAssignRole; |
235 | 0 | } |
236 | |
|
237 | |
|
238 | |
|
239 | |
|
240 | |
public boolean isCanModifyAssignees() { |
241 | 0 | return this.canModifyAssignees; |
242 | |
} |
243 | |
|
244 | |
|
245 | |
|
246 | |
|
247 | |
public void setCanModifyAssignees(boolean canModifyAssignees) { |
248 | 0 | this.canModifyAssignees = canModifyAssignees; |
249 | 0 | } |
250 | |
|
251 | |
public List<KimDocumentRoleMember> getMemberRows() { |
252 | 0 | return getRoleDocument().getMembers(); |
253 | |
} |
254 | |
|
255 | |
public int getIndexOfRoleMemberFromMemberRows(String roleMemberId){ |
256 | 0 | int index = 0; |
257 | 0 | for(KimDocumentRoleMember roleMember: getMemberRows()){ |
258 | 0 | if(StringUtils.equals(roleMember.getRoleMemberId(), roleMemberId)){ |
259 | 0 | break; |
260 | |
} |
261 | 0 | index++; |
262 | |
} |
263 | 0 | return index; |
264 | |
} |
265 | |
|
266 | |
public int getPageNumberOfRoleMemberId(String roleMemberId){ |
267 | 0 | if(StringUtils.isEmpty(roleMemberId)) {return 1;} |
268 | 0 | int index = getIndexOfRoleMemberFromMemberRows(roleMemberId); |
269 | 0 | return TableRenderUtil.computeTotalNumberOfPages(index + 1, getRecordsPerPage())-1; |
270 | |
} |
271 | |
|
272 | |
|
273 | |
|
274 | |
|
275 | |
public String getRoleId() { |
276 | 0 | return this.roleId; |
277 | |
} |
278 | |
|
279 | |
|
280 | |
|
281 | |
|
282 | |
public void setRoleId(String roleId) { |
283 | 0 | this.roleId = roleId; |
284 | 0 | } |
285 | |
|
286 | |
|
287 | |
|
288 | |
|
289 | |
public String getDelegationMemberRoleMemberId() { |
290 | 0 | return this.delegationMemberRoleMemberId; |
291 | |
} |
292 | |
|
293 | |
|
294 | |
|
295 | |
|
296 | |
public void setDelegationMemberRoleMemberId(String delegationMemberRoleMemberId) { |
297 | 0 | this.delegationMemberRoleMemberId = delegationMemberRoleMemberId; |
298 | 0 | getDelegationMember().setRoleMemberId(delegationMemberRoleMemberId); |
299 | 0 | KimDocumentRoleMember roleMember = getRoleDocument().getMember(delegationMemberRoleMemberId); |
300 | 0 | if(roleMember!=null){ |
301 | 0 | delegationMember.setRoleMemberId(roleMember.getRoleMemberId()); |
302 | 0 | delegationMember.setRoleMemberName(roleMember.getMemberName()); |
303 | 0 | delegationMember.setRoleMemberNamespaceCode(roleMember.getMemberNamespaceCode()); |
304 | |
RoleDocumentDelegationMemberQualifier delegationMemberQualifier; |
305 | 0 | for(KimDocumentRoleQualifier roleQualifier: roleMember.getQualifiers()){ |
306 | 0 | delegationMemberQualifier = getDelegationMember().getQualifier(roleQualifier.getKimAttrDefnId()); |
307 | 0 | delegationMemberQualifier.setAttrVal(roleQualifier.getAttrVal()); |
308 | |
} |
309 | |
} |
310 | 0 | } |
311 | |
|
312 | |
|
313 | |
|
314 | |
|
315 | |
public String getDmrmi() { |
316 | 0 | return this.dmrmi; |
317 | |
} |
318 | |
|
319 | |
|
320 | |
|
321 | |
|
322 | |
public void setDmrmi(String dmrmi) { |
323 | 0 | this.dmrmi = dmrmi; |
324 | 0 | } |
325 | |
|
326 | |
} |