1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sec.businessobject;
17
18 import java.sql.Timestamp;
19
20 import org.apache.commons.lang.StringUtils;
21 import org.kuali.ole.sys.context.SpringContext;
22 import org.kuali.rice.core.api.membership.MemberType;
23 import org.kuali.rice.core.api.util.type.KualiInteger;
24 import org.kuali.rice.kim.api.group.Group;
25 import org.kuali.rice.kim.api.group.GroupService;
26 import org.kuali.rice.kim.api.identity.Person;
27 import org.kuali.rice.kim.api.identity.PersonService;
28 import org.kuali.rice.kim.api.role.Role;
29 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
30 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
31
32
33
34
35
36 public class SecurityModelMember extends PersistableBusinessObjectBase {
37 protected KualiInteger modelId;
38 protected String memberId;
39 protected String memberTypeCode;
40 protected Timestamp activeFromDate;
41 protected Timestamp activeToDate;
42
43 protected SecurityModel securityModel;
44
45
46 protected String memberName = "";
47
48 protected ModelMember modelMember;
49
50
51
52
53
54
55 public KualiInteger getModelId() {
56 return modelId;
57 }
58
59
60
61
62
63
64
65 public void setModelId(KualiInteger modelId) {
66 this.modelId = modelId;
67 }
68
69
70
71
72
73
74
75 public String getMemberId() {
76 return memberId;
77 }
78
79
80
81
82
83
84
85 public void setMemberId(String memberId) {
86 this.memberId = memberId;
87 memberName = "";
88 }
89
90
91
92
93
94
95
96 public String getMemberTypeCode() {
97 return memberTypeCode;
98 }
99
100
101
102
103
104
105
106 public void setMemberTypeCode(String memberTypeCode) {
107 this.memberTypeCode = memberTypeCode;
108 memberName = "";
109 }
110
111
112
113
114
115
116
117 public Timestamp getActiveFromDate() {
118 return activeFromDate;
119 }
120
121
122
123
124
125
126
127 public void setActiveFromDate(Timestamp activeFromDate) {
128 this.activeFromDate = activeFromDate;
129 }
130
131
132
133
134
135
136
137 public Timestamp getActiveToDate() {
138 return activeToDate;
139 }
140
141
142
143
144
145
146
147 public void setActiveToDate(Timestamp activeToDate) {
148 this.activeToDate = activeToDate;
149 }
150
151
152
153
154
155
156
157 public String getMemberName() {
158 if ( StringUtils.isBlank(memberName) ) {
159 if (StringUtils.isNotBlank(memberTypeCode) && StringUtils.isNotBlank(memberId)) {
160 if (MemberType.PRINCIPAL.getCode().equals(memberTypeCode)) {
161 Person person = SpringContext.getBean(PersonService.class).getPerson(memberId);
162 if (person != null) {
163 memberName = person.getName();
164 }
165 } else if (MemberType.ROLE.getCode().equals(memberTypeCode)) {
166 Role roleInfo = KimApiServiceLocator.getRoleService().getRole(memberId);
167 if (roleInfo != null) {
168 memberName = roleInfo.getName();
169 }
170 } else if (MemberType.GROUP.getCode().equals(memberTypeCode)) {
171 Group groupInfo = KimApiServiceLocator.getGroupService().getGroup(memberId);
172 if (groupInfo != null) {
173 memberName = groupInfo.getName();
174 }
175 }
176 }
177 }
178
179 return memberName;
180 }
181
182
183
184
185
186
187
188 public void setMemberName(String memberName) {
189 this.memberName = memberName;
190 }
191
192
193
194
195
196
197
198 public SecurityModel getSecurityModel() {
199 return securityModel;
200 }
201
202
203
204
205
206
207
208 public void setSecurityModel(SecurityModel securityModel) {
209 this.securityModel = securityModel;
210 }
211
212
213
214
215
216
217
218 public ModelMember getModelMember() {
219 return modelMember;
220 }
221
222
223
224
225
226
227
228 public void setModelMember(ModelMember modelMember) {
229 this.modelMember = modelMember;
230 }
231
232
233
234
235
236
237 public String getModelDefinitionSummary() {
238 String summary = "";
239
240 for (SecurityModelDefinition modelDefinition : securityModel.getModelDefinitions()) {
241 summary += "Definition Name: " + modelDefinition.getSecurityDefinition().getName();
242 summary += ", Constraint Code: " + modelDefinition.getConstraintCode();
243 summary += ", Operator Code: " + modelDefinition.getOperatorCode();
244 summary += ", Value: " + modelDefinition.getAttributeValue();
245 summary += "; ";
246 }
247
248 return summary;
249 }
250
251
252 @Override
253 public String toString() {
254 StringBuilder builder = new StringBuilder();
255 builder.append("SecurityModelMember [");
256 if (modelId != null) {
257 builder.append("modelId=");
258 builder.append(modelId);
259 builder.append(", ");
260 }
261 if (memberId != null) {
262 builder.append("memberId=");
263 builder.append(memberId);
264 builder.append(", ");
265 }
266 if (memberTypeCode != null) {
267 builder.append("memberTypeCode=");
268 builder.append(memberTypeCode);
269 builder.append(", ");
270 }
271 if (activeFromDate != null) {
272 builder.append("activeFromDate=");
273 builder.append(activeFromDate);
274 builder.append(", ");
275 }
276 if (activeToDate != null) {
277 builder.append("activeToDate=");
278 builder.append(activeToDate);
279 builder.append(", ");
280 }
281 if (getMemberName() != null) {
282 builder.append("getMemberName()=");
283 builder.append(getMemberName());
284 builder.append(", ");
285 }
286 if (getModelDefinitionSummary() != null) {
287 builder.append("getModelDefinitionSummary()=");
288 builder.append(getModelDefinitionSummary());
289 }
290 builder.append("]");
291 return builder.toString();
292 }
293
294
295 }