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