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.types.impl.KimTypeImpl; |
26 | |
import org.kuali.rice.kim.bo.ui.GroupDocumentMember; |
27 | |
import org.kuali.rice.kim.document.IdentityManagementGroupDocument; |
28 | |
import org.kuali.rice.kim.service.KIMServiceLocator; |
29 | |
import org.kuali.rice.kim.util.KimConstants; |
30 | |
import org.kuali.rice.kns.web.format.DateDisplayTimestampObjectFormatter; |
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 KimTypeInfo 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 | 0 | else if(KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE.equals(memberTypeCode)) |
84 | 0 | return "roleId:member.memberId,roleName:member.memberName"; |
85 | 0 | else if(KimConstants.KimUIConstants.MEMBER_TYPE_GROUP_CODE.equals(memberTypeCode)) |
86 | 0 | return "groupId:member.memberId,groupName:member.memberName,namespaceCode:member.memberNamespaceCode"; |
87 | 0 | return ""; |
88 | |
} |
89 | |
|
90 | |
protected String getMemberBusinessObjectName(String memberTypeCode){ |
91 | 0 | if(KimConstants.KimUIConstants.MEMBER_TYPE_PRINCIPAL_CODE.equals(memberTypeCode)) |
92 | 0 | return PersonImpl.class.getName(); |
93 | 0 | else if(KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE.equals(memberTypeCode)) |
94 | 0 | return RoleImpl.class.getName(); |
95 | 0 | else if(KimConstants.KimUIConstants.MEMBER_TYPE_GROUP_CODE.equals(memberTypeCode)) |
96 | 0 | return GroupImpl.class.getName(); |
97 | 0 | return ""; |
98 | |
} |
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | |
public KimTypeInfo getKimType() { |
104 | 0 | if(StringUtils.isNotBlank(getGroupDocument().getGroupTypeId())) |
105 | 0 | return KIMServiceLocator.getTypeInfoService().getKimType(getGroupDocument().getGroupTypeId()); |
106 | 0 | else return kimType; |
107 | |
} |
108 | |
|
109 | |
public String getKimTypeClass(){ |
110 | 0 | return KimTypeImpl.class.getName(); |
111 | |
} |
112 | |
|
113 | |
|
114 | |
|
115 | |
public boolean isCanAssignGroup() { |
116 | 0 | return this.canAssignGroup; |
117 | |
} |
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
public void setCanAssignGroup(boolean canAssignGroup) { |
123 | 0 | this.canAssignGroup = canAssignGroup; |
124 | 0 | } |
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | |
public GroupDocumentMember getMember() { |
130 | 0 | return this.member; |
131 | |
} |
132 | |
|
133 | |
|
134 | |
|
135 | |
|
136 | |
public void setMember(GroupDocumentMember member) { |
137 | 0 | this.member = member; |
138 | 0 | } |
139 | |
|
140 | |
|
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | |
@SuppressWarnings("unchecked") |
146 | |
@Override |
147 | |
public List getMemberRows() { |
148 | 0 | return getGroupDocument().getMembers(); |
149 | |
} |
150 | |
|
151 | |
|
152 | |
|
153 | |
|
154 | |
public String getGroupId() { |
155 | 0 | return this.groupId; |
156 | |
} |
157 | |
|
158 | |
|
159 | |
|
160 | |
|
161 | |
public void setGroupId(String groupId) { |
162 | 0 | this.groupId = groupId; |
163 | 0 | } |
164 | |
|
165 | |
|
166 | |
|
167 | |
|
168 | |
public void setKimType(KimTypeInfo kimType) { |
169 | 0 | this.kimType = kimType; |
170 | 0 | } |
171 | |
|
172 | |
} |