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.api.membership.MemberType; |
20 | |
import org.kuali.rice.core.web.format.DateDisplayTimestampObjectFormatter; |
21 | |
import org.kuali.rice.kim.api.KimConstants; |
22 | |
import org.kuali.rice.kim.api.services.KimApiServiceLocator; |
23 | |
import org.kuali.rice.kim.api.type.KimType; |
24 | |
import org.kuali.rice.kim.bo.ui.GroupDocumentMember; |
25 | |
import org.kuali.rice.kim.document.IdentityManagementGroupDocument; |
26 | |
import org.kuali.rice.kim.impl.group.GroupBo; |
27 | |
import org.kuali.rice.kim.impl.identity.PersonImpl; |
28 | |
import org.kuali.rice.kim.impl.role.RoleBo; |
29 | |
import org.kuali.rice.kim.impl.type.KimTypeBo; |
30 | |
|
31 | |
import java.util.List; |
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
public class IdentityManagementGroupDocumentForm extends IdentityManagementDocumentFormBase { |
40 | |
protected static final long serialVersionUID = -107836689162363400L; |
41 | |
|
42 | |
{ |
43 | 0 | requiredNonEditableProperties.add("methodToCall"); |
44 | |
} |
45 | |
|
46 | 0 | protected boolean canAssignGroup = true; |
47 | |
|
48 | |
protected KimType kimType; |
49 | 0 | protected GroupDocumentMember member = new GroupDocumentMember(); |
50 | |
protected String groupId; |
51 | |
|
52 | |
public IdentityManagementGroupDocumentForm() { |
53 | 0 | super(); |
54 | 0 | setFormatterType("document.members.activeFromDate", DateDisplayTimestampObjectFormatter.class); |
55 | 0 | setFormatterType("document.members.activeToDate", DateDisplayTimestampObjectFormatter.class); |
56 | 0 | } |
57 | |
|
58 | |
@Override |
59 | |
public String getDefaultDocumentTypeName(){ |
60 | 0 | return "IdentityManagementGroupDocument"; |
61 | |
} |
62 | |
|
63 | |
public IdentityManagementGroupDocument getGroupDocument() { |
64 | 0 | return (IdentityManagementGroupDocument) this.getDocument(); |
65 | |
} |
66 | |
|
67 | |
public String getMemberFieldConversions(){ |
68 | 0 | if(member==null) { |
69 | 0 | return ""; |
70 | |
} |
71 | 0 | return getMemberFieldConversions(member.getMemberTypeCode()); |
72 | |
} |
73 | |
|
74 | |
public String getMemberBusinessObjectName(){ |
75 | 0 | if(member==null) { |
76 | 0 | return ""; |
77 | |
} |
78 | 0 | return getMemberBusinessObjectName(member.getMemberTypeCode()); |
79 | |
} |
80 | |
|
81 | |
protected String getMemberFieldConversions(String memberTypeCode){ |
82 | 0 | if(MemberType.PRINCIPAL.getCode().equals(memberTypeCode)) { |
83 | 0 | return "principalId:member.memberId,principalName:member.memberName"; |
84 | |
} |
85 | 0 | else if(MemberType.ROLE.getCode().equals(memberTypeCode)) { |
86 | 0 | return "roleId:member.memberId,roleName:member.memberName"; |
87 | |
} |
88 | 0 | else if(MemberType.GROUP.getCode().equals(memberTypeCode)) { |
89 | 0 | return "id:member.memberId,name:member.memberName,namespaceCode:member.memberNamespaceCode"; |
90 | |
} |
91 | 0 | return ""; |
92 | |
} |
93 | |
|
94 | |
protected String getMemberBusinessObjectName(String memberTypeCode){ |
95 | 0 | if(MemberType.PRINCIPAL.getCode().equals(memberTypeCode)) { |
96 | 0 | return PersonImpl.class.getName(); |
97 | |
} |
98 | 0 | else if(MemberType.ROLE.getCode().equals(memberTypeCode)) { |
99 | 0 | return RoleBo.class.getName(); |
100 | |
} |
101 | 0 | else if(MemberType.GROUP.getCode().equals(memberTypeCode)) { |
102 | 0 | return GroupBo.class.getName(); |
103 | |
} |
104 | 0 | return ""; |
105 | |
} |
106 | |
|
107 | |
|
108 | |
|
109 | |
|
110 | |
public KimType getKimType() { |
111 | 0 | if(StringUtils.isNotBlank(getGroupDocument().getGroupTypeId())) { |
112 | 0 | return KimApiServiceLocator.getKimTypeInfoService().getKimType(getGroupDocument().getGroupTypeId()); |
113 | |
} |
114 | 0 | else {return kimType;} |
115 | |
} |
116 | |
|
117 | |
public String getKimTypeClass(){ |
118 | 0 | return KimTypeBo.class.getName(); |
119 | |
} |
120 | |
|
121 | |
|
122 | |
|
123 | |
public boolean isCanAssignGroup() { |
124 | 0 | return this.canAssignGroup; |
125 | |
} |
126 | |
|
127 | |
|
128 | |
|
129 | |
|
130 | |
public void setCanAssignGroup(boolean canAssignGroup) { |
131 | 0 | this.canAssignGroup = canAssignGroup; |
132 | 0 | } |
133 | |
|
134 | |
|
135 | |
|
136 | |
|
137 | |
public GroupDocumentMember getMember() { |
138 | 0 | return this.member; |
139 | |
} |
140 | |
|
141 | |
|
142 | |
|
143 | |
|
144 | |
public void setMember(GroupDocumentMember member) { |
145 | 0 | this.member = member; |
146 | 0 | } |
147 | |
|
148 | |
|
149 | |
|
150 | |
|
151 | |
|
152 | |
|
153 | |
@SuppressWarnings("unchecked") |
154 | |
@Override |
155 | |
public List getMemberRows() { |
156 | 0 | return getGroupDocument().getMembers(); |
157 | |
} |
158 | |
|
159 | |
|
160 | |
|
161 | |
|
162 | |
public String getGroupId() { |
163 | 0 | return this.groupId; |
164 | |
} |
165 | |
|
166 | |
|
167 | |
|
168 | |
|
169 | |
public void setGroupId(String groupId) { |
170 | 0 | this.groupId = groupId; |
171 | 0 | } |
172 | |
|
173 | |
|
174 | |
|
175 | |
|
176 | |
public void setKimType(KimType kimType) { |
177 | 0 | this.kimType = kimType; |
178 | 0 | } |
179 | |
|
180 | |
} |