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