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