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 java.util.List; |
19 | |
|
20 | |
import org.apache.commons.lang.StringUtils; |
21 | |
import org.kuali.rice.kim.bo.impl.GroupImpl; |
22 | |
import org.kuali.rice.kim.bo.impl.PersonImpl; |
23 | |
import org.kuali.rice.kim.bo.impl.RoleImpl; |
24 | |
import org.kuali.rice.kim.bo.types.dto.KimTypeInfo; |
25 | |
import org.kuali.rice.kim.bo.ui.KimDocumentRoleMember; |
26 | |
import org.kuali.rice.kim.bo.ui.KimDocumentRolePermission; |
27 | |
import org.kuali.rice.kim.bo.ui.KimDocumentRoleQualifier; |
28 | |
import org.kuali.rice.kim.bo.ui.KimDocumentRoleResponsibility; |
29 | |
import org.kuali.rice.kim.bo.ui.RoleDocumentDelegationMember; |
30 | |
import org.kuali.rice.kim.bo.ui.RoleDocumentDelegationMemberQualifier; |
31 | |
import org.kuali.rice.kim.document.IdentityManagementRoleDocument; |
32 | |
import org.kuali.rice.kim.util.KimConstants; |
33 | |
import org.kuali.rice.kns.util.TableRenderUtil; |
34 | |
import org.kuali.rice.kns.web.format.DateDisplayTimestampObjectFormatter; |
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 KimTypeInfo 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 | 0 | return getMemberFieldConversions(member.getMemberTypeCode()); |
146 | |
} |
147 | |
|
148 | |
public String getMemberBusinessObjectName(){ |
149 | 0 | if(member==null) |
150 | 0 | return ""; |
151 | 0 | return getMemberBusinessObjectName(member.getMemberTypeCode()); |
152 | |
} |
153 | |
|
154 | |
public String getDelegationMemberFieldConversions(){ |
155 | 0 | if(getDelegationMember()==null) |
156 | 0 | return ""; |
157 | 0 | String memberTypeCode = getDelegationMember().getMemberTypeCode(); |
158 | 0 | if(KimConstants.KimUIConstants.MEMBER_TYPE_PRINCIPAL_CODE.equals(memberTypeCode)) |
159 | 0 | return "principalId:delegationMember.memberId,principalName:delegationMember.memberName"; |
160 | 0 | else if(KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE.equals(memberTypeCode)) |
161 | 0 | return "roleId:delegationMember.memberId,roleName:delegationMember.memberName,namespaceCode:delegationMember.memberNamespaceCode"; |
162 | 0 | else if(KimConstants.KimUIConstants.MEMBER_TYPE_GROUP_CODE.equals(memberTypeCode)) |
163 | 0 | return "groupId:delegationMember.memberId,groupName:delegationMember.memberName,namespaceCode:delegationMember.memberNamespaceCode"; |
164 | 0 | return ""; |
165 | |
} |
166 | |
|
167 | |
public String getDelegationMemberBusinessObjectName(){ |
168 | 0 | if(getDelegationMember()==null) |
169 | 0 | return ""; |
170 | 0 | return getMemberBusinessObjectName(getDelegationMember().getMemberTypeCode()); |
171 | |
} |
172 | |
|
173 | |
protected String getMemberFieldConversions(String memberTypeCode){ |
174 | 0 | if(KimConstants.KimUIConstants.MEMBER_TYPE_PRINCIPAL_CODE.equals(memberTypeCode)) |
175 | 0 | return "principalId:member.memberId,principalName:member.memberName"; |
176 | 0 | else if(KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE.equals(memberTypeCode)) |
177 | 0 | return "roleId:member.memberId,roleName:member.memberName,namespaceCode:member.memberNamespaceCode"; |
178 | 0 | else if(KimConstants.KimUIConstants.MEMBER_TYPE_GROUP_CODE.equals(memberTypeCode)) |
179 | 0 | return "groupId:member.memberId,groupName:member.memberName,namespaceCode:member.memberNamespaceCode"; |
180 | 0 | return ""; |
181 | |
} |
182 | |
|
183 | |
protected String getMemberBusinessObjectName(String memberTypeCode){ |
184 | 0 | if(KimConstants.KimUIConstants.MEMBER_TYPE_PRINCIPAL_CODE.equals(memberTypeCode)) |
185 | 0 | return PersonImpl.class.getName(); |
186 | 0 | else if(KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE.equals(memberTypeCode)) |
187 | 0 | return RoleImpl.class.getName(); |
188 | 0 | else if(KimConstants.KimUIConstants.MEMBER_TYPE_GROUP_CODE.equals(memberTypeCode)) |
189 | 0 | return GroupImpl.class.getName(); |
190 | 0 | return ""; |
191 | |
} |
192 | |
|
193 | |
|
194 | |
|
195 | |
|
196 | |
public KimTypeInfo getKimType() { |
197 | 0 | return this.kimType; |
198 | |
} |
199 | |
|
200 | |
|
201 | |
|
202 | |
|
203 | |
public void setKimType(KimTypeInfo kimType) { |
204 | 0 | this.kimType = kimType; |
205 | 0 | if ( kimType != null && getRoleDocument() != null ) { |
206 | 0 | getRoleDocument().setKimType(kimType); |
207 | |
} |
208 | 0 | } |
209 | |
|
210 | |
|
211 | |
|
212 | |
|
213 | |
public boolean isCanAssignRole() { |
214 | 0 | return this.canAssignRole; |
215 | |
} |
216 | |
|
217 | |
|
218 | |
|
219 | |
|
220 | |
public void setCanAssignRole(boolean canAssignRole) { |
221 | 0 | this.canAssignRole = canAssignRole; |
222 | 0 | } |
223 | |
|
224 | |
|
225 | |
|
226 | |
|
227 | |
public boolean isCanModifyAssignees() { |
228 | 0 | return this.canModifyAssignees; |
229 | |
} |
230 | |
|
231 | |
|
232 | |
|
233 | |
|
234 | |
public void setCanModifyAssignees(boolean canModifyAssignees) { |
235 | 0 | this.canModifyAssignees = canModifyAssignees; |
236 | 0 | } |
237 | |
|
238 | |
public List<KimDocumentRoleMember> getMemberRows() { |
239 | 0 | return getRoleDocument().getMembers(); |
240 | |
} |
241 | |
|
242 | |
public int getIndexOfRoleMemberFromMemberRows(String roleMemberId){ |
243 | 0 | int index = 0; |
244 | 0 | for(KimDocumentRoleMember roleMember: getMemberRows()){ |
245 | 0 | if(StringUtils.equals(roleMember.getRoleMemberId(), roleMemberId)){ |
246 | 0 | break; |
247 | |
} |
248 | 0 | index++; |
249 | |
} |
250 | 0 | return index; |
251 | |
} |
252 | |
|
253 | |
public int getPageNumberOfRoleMemberId(String roleMemberId){ |
254 | 0 | if(StringUtils.isEmpty(roleMemberId)) return 1; |
255 | 0 | int index = getIndexOfRoleMemberFromMemberRows(roleMemberId); |
256 | 0 | return TableRenderUtil.computeTotalNumberOfPages(index+1, getRecordsPerPage())-1; |
257 | |
} |
258 | |
|
259 | |
|
260 | |
|
261 | |
|
262 | |
public String getRoleId() { |
263 | 0 | return this.roleId; |
264 | |
} |
265 | |
|
266 | |
|
267 | |
|
268 | |
|
269 | |
public void setRoleId(String roleId) { |
270 | 0 | this.roleId = roleId; |
271 | 0 | } |
272 | |
|
273 | |
|
274 | |
|
275 | |
|
276 | |
public String getDelegationMemberRoleMemberId() { |
277 | 0 | return this.delegationMemberRoleMemberId; |
278 | |
} |
279 | |
|
280 | |
|
281 | |
|
282 | |
|
283 | |
public void setDelegationMemberRoleMemberId(String delegationMemberRoleMemberId) { |
284 | 0 | this.delegationMemberRoleMemberId = delegationMemberRoleMemberId; |
285 | 0 | getDelegationMember().setRoleMemberId(delegationMemberRoleMemberId); |
286 | 0 | KimDocumentRoleMember roleMember = getRoleDocument().getMember(delegationMemberRoleMemberId); |
287 | 0 | if(roleMember!=null){ |
288 | 0 | delegationMember.setRoleMemberId(roleMember.getRoleMemberId()); |
289 | 0 | delegationMember.setRoleMemberName(roleMember.getMemberName()); |
290 | 0 | delegationMember.setRoleMemberNamespaceCode(roleMember.getMemberNamespaceCode()); |
291 | |
RoleDocumentDelegationMemberQualifier delegationMemberQualifier; |
292 | 0 | for(KimDocumentRoleQualifier roleQualifier: roleMember.getQualifiers()){ |
293 | 0 | delegationMemberQualifier = getDelegationMember().getQualifier(roleQualifier.getKimAttrDefnId()); |
294 | 0 | delegationMemberQualifier.setAttrVal(roleQualifier.getAttrVal()); |
295 | |
} |
296 | |
} |
297 | 0 | } |
298 | |
|
299 | |
|
300 | |
|
301 | |
|
302 | |
public String getDmrmi() { |
303 | 0 | return this.dmrmi; |
304 | |
} |
305 | |
|
306 | |
|
307 | |
|
308 | |
|
309 | |
public void setDmrmi(String dmrmi) { |
310 | 0 | this.dmrmi = dmrmi; |
311 | 0 | } |
312 | |
|
313 | |
} |