1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kim.api.responsibility; |
17 | |
|
18 | |
import com.google.common.collect.Maps; |
19 | |
import org.apache.commons.lang.StringUtils; |
20 | |
import org.kuali.rice.core.api.CoreConstants; |
21 | |
import org.kuali.rice.core.api.mo.AbstractDataTransferObject; |
22 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
23 | |
import org.kuali.rice.core.api.util.jaxb.MapStringStringAdapter; |
24 | |
import org.kuali.rice.kim.api.common.delegate.DelegateType; |
25 | |
import org.kuali.rice.kim.api.common.delegate.DelegateTypeContract; |
26 | |
import org.w3c.dom.Element; |
27 | |
|
28 | |
import javax.xml.bind.annotation.XmlAccessType; |
29 | |
import javax.xml.bind.annotation.XmlAccessorType; |
30 | |
import javax.xml.bind.annotation.XmlAnyElement; |
31 | |
import javax.xml.bind.annotation.XmlElement; |
32 | |
import javax.xml.bind.annotation.XmlRootElement; |
33 | |
import javax.xml.bind.annotation.XmlType; |
34 | |
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; |
35 | |
import java.io.Serializable; |
36 | |
import java.util.ArrayList; |
37 | |
import java.util.Collection; |
38 | |
import java.util.Collections; |
39 | |
import java.util.List; |
40 | |
import java.util.Map; |
41 | |
|
42 | |
@XmlRootElement(name = ResponsibilityAction.Constants.ROOT_ELEMENT_NAME) |
43 | |
@XmlAccessorType(XmlAccessType.NONE) |
44 | |
@XmlType(name = ResponsibilityAction.Constants.TYPE_NAME, propOrder = { |
45 | |
ResponsibilityAction.Elements.PRINCIPAL_ID, |
46 | |
ResponsibilityAction.Elements.ROLE_RESPONSIBILITY_ACTION_ID, |
47 | |
ResponsibilityAction.Elements.PARALLEL_ROUTING_GROUPING_CODE, |
48 | |
ResponsibilityAction.Elements.ACTION_TYPE_CODE, |
49 | |
ResponsibilityAction.Elements.ACTION_POLICY_CODE, |
50 | |
ResponsibilityAction.Elements.PRIORITY_NUMBER, |
51 | |
ResponsibilityAction.Elements.GROUP_ID, |
52 | |
ResponsibilityAction.Elements.MEMBER_ROLE_ID, |
53 | |
ResponsibilityAction.Elements.RESPONSIBILITY_NAME, |
54 | |
ResponsibilityAction.Elements.RESPONSIBILITY_ID, |
55 | |
ResponsibilityAction.Elements.RESPONSIBILITY_NAMESPACE_CODE, |
56 | |
ResponsibilityAction.Elements.FORCE_ACTION, |
57 | |
ResponsibilityAction.Elements.QUALIFIER, |
58 | |
ResponsibilityAction.Elements.DELEGATES, |
59 | |
ResponsibilityAction.Elements.ROLE_ID, |
60 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
61 | |
}) |
62 | 0 | public final class ResponsibilityAction extends AbstractDataTransferObject |
63 | |
implements ResponsibilityActionContract { |
64 | |
|
65 | |
@XmlElement(name = Elements.PRINCIPAL_ID, required = false) |
66 | |
private final String principalId; |
67 | |
@XmlElement(name = Elements.ROLE_RESPONSIBILITY_ACTION_ID, required = false) |
68 | |
private final String roleResponsibilityActionId; |
69 | |
@XmlElement(name = Elements.PARALLEL_ROUTING_GROUPING_CODE, required = false) |
70 | |
private final String parallelRoutingGroupingCode; |
71 | |
@XmlElement(name = Elements.ACTION_TYPE_CODE, required = false) |
72 | |
private final String actionTypeCode; |
73 | |
@XmlElement(name = Elements.ACTION_POLICY_CODE, required = false) |
74 | |
private final String actionPolicyCode; |
75 | |
@XmlElement(name = Elements.PRIORITY_NUMBER, required = false) |
76 | |
private final Integer priorityNumber; |
77 | |
@XmlElement(name = Elements.GROUP_ID, required = true) |
78 | |
private final String groupId; |
79 | |
@XmlElement(name = Elements.MEMBER_ROLE_ID, required = true) |
80 | |
private final String memberRoleId; |
81 | |
@XmlElement(name = Elements.RESPONSIBILITY_NAME, required = true) |
82 | |
private final String responsibilityName; |
83 | |
@XmlElement(name = Elements.RESPONSIBILITY_ID, required = true) |
84 | |
private final String responsibilityId; |
85 | |
@XmlElement(name = Elements.RESPONSIBILITY_NAMESPACE_CODE, required = true) |
86 | |
private final String responsibilityNamespaceCode; |
87 | |
@XmlElement(name = Elements.FORCE_ACTION, required = true) |
88 | |
private final boolean forceAction; |
89 | |
@XmlElement(name = Elements.QUALIFIER, required = true) |
90 | |
@XmlJavaTypeAdapter(value = MapStringStringAdapter.class) |
91 | |
private final Map<String, String> qualifier; |
92 | |
@XmlElement(name = Elements.DELEGATES, required = true) |
93 | |
private final List<DelegateType> delegates; |
94 | |
@XmlElement(name = Elements.ROLE_ID, required = true) |
95 | |
private final String roleId; |
96 | 0 | @SuppressWarnings("unused") |
97 | |
@XmlAnyElement |
98 | |
private final Collection<Element> _futureElements = null; |
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | 0 | private ResponsibilityAction() { |
104 | 0 | this.principalId = null; |
105 | 0 | this.roleResponsibilityActionId = null; |
106 | 0 | this.parallelRoutingGroupingCode = null; |
107 | 0 | this.actionTypeCode = null; |
108 | 0 | this.actionPolicyCode = null; |
109 | 0 | this.priorityNumber = null; |
110 | 0 | this.groupId = null; |
111 | 0 | this.memberRoleId = null; |
112 | 0 | this.responsibilityName = null; |
113 | 0 | this.responsibilityId = null; |
114 | 0 | this.responsibilityNamespaceCode = null; |
115 | 0 | this.forceAction = false; |
116 | 0 | this.qualifier = null; |
117 | 0 | this.delegates = null; |
118 | 0 | this.roleId = null; |
119 | 0 | } |
120 | |
|
121 | 0 | private ResponsibilityAction(Builder builder) { |
122 | 0 | this.principalId = builder.getPrincipalId(); |
123 | 0 | this.roleResponsibilityActionId = builder.getRoleResponsibilityActionId(); |
124 | 0 | this.parallelRoutingGroupingCode = builder.getParallelRoutingGroupingCode(); |
125 | 0 | this.actionTypeCode = builder.getActionTypeCode(); |
126 | 0 | this.actionPolicyCode = builder.getActionPolicyCode(); |
127 | 0 | this.priorityNumber = builder.getPriorityNumber(); |
128 | 0 | this.groupId = builder.getGroupId(); |
129 | 0 | this.memberRoleId = builder.getMemberRoleId(); |
130 | 0 | this.responsibilityName = builder.getResponsibilityName(); |
131 | 0 | this.responsibilityId = builder.getResponsibilityId(); |
132 | 0 | this.responsibilityNamespaceCode = builder.getResponsibilityNamespaceCode(); |
133 | 0 | this.forceAction = builder.isForceAction(); |
134 | 0 | this.qualifier = builder.getQualifier(); |
135 | 0 | final List<DelegateType> ds = new ArrayList<DelegateType>(); |
136 | 0 | for (DelegateType.Builder d : builder.getDelegates()) { |
137 | 0 | if (d != null) { |
138 | 0 | ds.add(d.build()); |
139 | |
} |
140 | |
} |
141 | 0 | this.delegates = ds; |
142 | 0 | this.roleId = builder.getRoleId(); |
143 | 0 | } |
144 | |
|
145 | |
@Override |
146 | |
public String getPrincipalId() { |
147 | 0 | return this.principalId; |
148 | |
} |
149 | |
|
150 | |
@Override |
151 | |
public String getRoleResponsibilityActionId() { |
152 | 0 | return this.roleResponsibilityActionId; |
153 | |
} |
154 | |
|
155 | |
@Override |
156 | |
public String getParallelRoutingGroupingCode() { |
157 | 0 | return this.parallelRoutingGroupingCode; |
158 | |
} |
159 | |
|
160 | |
@Override |
161 | |
public String getActionTypeCode() { |
162 | 0 | return this.actionTypeCode; |
163 | |
} |
164 | |
|
165 | |
@Override |
166 | |
public String getActionPolicyCode() { |
167 | 0 | return this.actionPolicyCode; |
168 | |
} |
169 | |
|
170 | |
@Override |
171 | |
public Integer getPriorityNumber() { |
172 | 0 | return this.priorityNumber; |
173 | |
} |
174 | |
|
175 | |
@Override |
176 | |
public String getGroupId() { |
177 | 0 | return this.groupId; |
178 | |
} |
179 | |
|
180 | |
@Override |
181 | |
public String getMemberRoleId() { |
182 | 0 | return this.memberRoleId; |
183 | |
} |
184 | |
|
185 | |
@Override |
186 | |
public String getResponsibilityName() { |
187 | 0 | return this.responsibilityName; |
188 | |
} |
189 | |
|
190 | |
@Override |
191 | |
public String getResponsibilityId() { |
192 | 0 | return this.responsibilityId; |
193 | |
} |
194 | |
|
195 | |
@Override |
196 | |
public String getResponsibilityNamespaceCode() { |
197 | 0 | return this.responsibilityNamespaceCode; |
198 | |
} |
199 | |
|
200 | |
@Override |
201 | |
public boolean isForceAction() { |
202 | 0 | return this.forceAction; |
203 | |
} |
204 | |
|
205 | |
@Override |
206 | |
public Map<String, String> getQualifier() { |
207 | 0 | return this.qualifier; |
208 | |
} |
209 | |
|
210 | |
@Override |
211 | |
public List<DelegateType> getDelegates() { |
212 | 0 | return Collections.unmodifiableList(this.delegates); |
213 | |
} |
214 | |
|
215 | |
@Override |
216 | |
public String getRoleId() { |
217 | 0 | return this.roleId; |
218 | |
} |
219 | |
|
220 | |
|
221 | |
|
222 | |
|
223 | |
|
224 | 0 | public final static class Builder |
225 | |
implements Serializable, ModelBuilder, ResponsibilityActionContract { |
226 | |
|
227 | |
private String principalId; |
228 | |
private String roleResponsibilityActionId; |
229 | |
private String parallelRoutingGroupingCode; |
230 | |
private String actionTypeCode; |
231 | |
private String actionPolicyCode; |
232 | |
private Integer priorityNumber; |
233 | |
private String groupId; |
234 | |
private String memberRoleId; |
235 | |
private String responsibilityName; |
236 | |
private String responsibilityId; |
237 | |
private String responsibilityNamespaceCode; |
238 | |
private boolean forceAction; |
239 | |
private Map<String, String> qualifier; |
240 | |
private List<DelegateType.Builder> delegates; |
241 | |
private String roleId; |
242 | |
|
243 | 0 | private Builder() { |
244 | 0 | } |
245 | |
|
246 | |
|
247 | |
|
248 | |
|
249 | |
|
250 | |
|
251 | |
|
252 | |
public static Builder create() { |
253 | |
|
254 | 0 | return new Builder(); |
255 | |
} |
256 | |
|
257 | |
public static Builder create(ResponsibilityActionContract contract) { |
258 | 0 | if (contract == null) { |
259 | 0 | throw new IllegalArgumentException("contract was null"); |
260 | |
} |
261 | 0 | Builder builder = create(); |
262 | 0 | builder.setPrincipalId(contract.getPrincipalId()); |
263 | 0 | builder.setRoleResponsibilityActionId(contract.getRoleResponsibilityActionId()); |
264 | 0 | builder.setParallelRoutingGroupingCode(contract.getParallelRoutingGroupingCode()); |
265 | 0 | builder.setActionTypeCode(contract.getActionTypeCode()); |
266 | 0 | builder.setActionPolicyCode(contract.getActionPolicyCode()); |
267 | 0 | builder.setPriorityNumber(contract.getPriorityNumber()); |
268 | 0 | builder.setGroupId(contract.getGroupId()); |
269 | 0 | builder.setMemberRoleId(contract.getMemberRoleId()); |
270 | 0 | builder.setResponsibilityName(contract.getResponsibilityName()); |
271 | 0 | builder.setResponsibilityId(contract.getResponsibilityId()); |
272 | 0 | builder.setResponsibilityNamespaceCode(contract.getResponsibilityNamespaceCode()); |
273 | 0 | builder.setForceAction(contract.isForceAction()); |
274 | 0 | builder.setQualifier(contract.getQualifier()); |
275 | 0 | final List<DelegateType.Builder> dbs = new ArrayList<DelegateType.Builder>(); |
276 | 0 | for (DelegateTypeContract d : contract.getDelegates()) { |
277 | 0 | if (d != null) { |
278 | 0 | dbs.add(DelegateType.Builder.create(d)); |
279 | |
} |
280 | |
} |
281 | 0 | builder.setDelegates(dbs); |
282 | 0 | builder.setRoleId(contract.getRoleId()); |
283 | 0 | return builder; |
284 | |
} |
285 | |
|
286 | |
public ResponsibilityAction build() { |
287 | |
|
288 | 0 | final boolean requiredSet = (groupId != null ^ principalId != null) && |
289 | |
memberRoleId != null && |
290 | |
responsibilityName != null && |
291 | |
responsibilityId != null && |
292 | |
responsibilityNamespaceCode != null && |
293 | |
qualifier != null && |
294 | |
delegates != null && |
295 | |
roleId != null; |
296 | |
|
297 | 0 | if (!requiredSet) { |
298 | 0 | throw new IllegalStateException("all the required fields are not set"); |
299 | |
} |
300 | 0 | return new ResponsibilityAction(this); |
301 | |
} |
302 | |
|
303 | |
@Override |
304 | |
public String getPrincipalId() { |
305 | 0 | return this.principalId; |
306 | |
} |
307 | |
|
308 | |
@Override |
309 | |
public String getRoleResponsibilityActionId() { |
310 | 0 | return this.roleResponsibilityActionId; |
311 | |
} |
312 | |
|
313 | |
@Override |
314 | |
public String getParallelRoutingGroupingCode() { |
315 | 0 | return this.parallelRoutingGroupingCode; |
316 | |
} |
317 | |
|
318 | |
@Override |
319 | |
public String getActionTypeCode() { |
320 | 0 | return this.actionTypeCode; |
321 | |
} |
322 | |
|
323 | |
@Override |
324 | |
public String getActionPolicyCode() { |
325 | 0 | return this.actionPolicyCode; |
326 | |
} |
327 | |
|
328 | |
@Override |
329 | |
public Integer getPriorityNumber() { |
330 | 0 | return this.priorityNumber; |
331 | |
} |
332 | |
|
333 | |
@Override |
334 | |
public String getGroupId() { |
335 | 0 | return this.groupId; |
336 | |
} |
337 | |
|
338 | |
@Override |
339 | |
public String getMemberRoleId() { |
340 | 0 | return this.memberRoleId; |
341 | |
} |
342 | |
|
343 | |
@Override |
344 | |
public String getResponsibilityName() { |
345 | 0 | return this.responsibilityName; |
346 | |
} |
347 | |
|
348 | |
@Override |
349 | |
public String getResponsibilityId() { |
350 | 0 | return this.responsibilityId; |
351 | |
} |
352 | |
|
353 | |
@Override |
354 | |
public String getResponsibilityNamespaceCode() { |
355 | 0 | return this.responsibilityNamespaceCode; |
356 | |
} |
357 | |
|
358 | |
@Override |
359 | |
public boolean isForceAction() { |
360 | 0 | return this.forceAction; |
361 | |
} |
362 | |
|
363 | |
@Override |
364 | |
public Map<String, String> getQualifier() { |
365 | 0 | return this.qualifier; |
366 | |
} |
367 | |
|
368 | |
@Override |
369 | |
public List<DelegateType.Builder> getDelegates() { |
370 | 0 | return Collections.unmodifiableList(this.delegates); |
371 | |
} |
372 | |
|
373 | |
@Override |
374 | |
public String getRoleId() { |
375 | 0 | return this.roleId; |
376 | |
} |
377 | |
|
378 | |
public void setPrincipalId(String principalId) { |
379 | 0 | this.principalId = principalId; |
380 | 0 | } |
381 | |
|
382 | |
public void setRoleResponsibilityActionId(String roleResponsibilityActionId) { |
383 | 0 | this.roleResponsibilityActionId = roleResponsibilityActionId; |
384 | 0 | } |
385 | |
|
386 | |
public void setParallelRoutingGroupingCode(String parallelRoutingGroupingCode) { |
387 | 0 | this.parallelRoutingGroupingCode = parallelRoutingGroupingCode; |
388 | 0 | } |
389 | |
|
390 | |
public void setActionTypeCode(String actionTypeCode) { |
391 | 0 | this.actionTypeCode = actionTypeCode; |
392 | 0 | } |
393 | |
|
394 | |
public void setActionPolicyCode(String actionPolicyCode) { |
395 | 0 | this.actionPolicyCode = actionPolicyCode; |
396 | 0 | } |
397 | |
|
398 | |
public void setPriorityNumber(Integer priorityNumber) { |
399 | 0 | this.priorityNumber = priorityNumber; |
400 | 0 | } |
401 | |
|
402 | |
public void setGroupId(String groupId) { |
403 | 0 | this.groupId = groupId; |
404 | 0 | } |
405 | |
|
406 | |
public void setMemberRoleId(String memberRoleId) { |
407 | 0 | if (StringUtils.isBlank(memberRoleId)) { |
408 | 0 | throw new IllegalArgumentException("memberRoleId is blank"); |
409 | |
} |
410 | |
|
411 | 0 | this.memberRoleId = memberRoleId; |
412 | 0 | } |
413 | |
|
414 | |
public void setResponsibilityName(String responsibilityName) { |
415 | 0 | if (StringUtils.isBlank(responsibilityName)) { |
416 | 0 | throw new IllegalArgumentException("responsibilityName is blank"); |
417 | |
} |
418 | |
|
419 | 0 | this.responsibilityName = responsibilityName; |
420 | 0 | } |
421 | |
|
422 | |
public void setResponsibilityId(String responsibilityId) { |
423 | 0 | if (StringUtils.isBlank(responsibilityId)) { |
424 | 0 | throw new IllegalArgumentException("responsibilityId is blank"); |
425 | |
} |
426 | |
|
427 | 0 | this.responsibilityId = responsibilityId; |
428 | 0 | } |
429 | |
|
430 | |
public void setResponsibilityNamespaceCode(String responsibilityNamespaceCode) { |
431 | 0 | if (StringUtils.isBlank(responsibilityNamespaceCode)) { |
432 | 0 | throw new IllegalArgumentException("responsibilityNamespaceCode is blank"); |
433 | |
} |
434 | 0 | this.responsibilityNamespaceCode = responsibilityNamespaceCode; |
435 | 0 | } |
436 | |
|
437 | |
public void setForceAction(boolean forceAction) { |
438 | 0 | this.forceAction = forceAction; |
439 | 0 | } |
440 | |
|
441 | |
public void setQualifier(Map<String, String> qualifier) { |
442 | 0 | if (qualifier == null) { |
443 | 0 | throw new IllegalArgumentException("qualifier is null"); |
444 | |
} |
445 | 0 | this.qualifier = Collections.unmodifiableMap(Maps.newHashMap(qualifier)); |
446 | 0 | } |
447 | |
|
448 | |
public void setDelegates(List<DelegateType.Builder> delegates) { |
449 | 0 | if (delegates == null) { |
450 | 0 | throw new IllegalArgumentException("delegates is null"); |
451 | |
} |
452 | 0 | this.delegates = new ArrayList<DelegateType.Builder>(delegates); |
453 | 0 | } |
454 | |
|
455 | |
public void setRoleId(String roleId) { |
456 | 0 | if (StringUtils.isBlank(roleId)) { |
457 | 0 | throw new IllegalArgumentException("roleId is blank"); |
458 | |
} |
459 | 0 | this.roleId = roleId; |
460 | 0 | } |
461 | |
|
462 | |
} |
463 | |
|
464 | |
|
465 | |
|
466 | |
|
467 | |
|
468 | 0 | static class Constants { |
469 | |
|
470 | |
final static String ROOT_ELEMENT_NAME = "responsibilityAction"; |
471 | |
final static String TYPE_NAME = "ResponsibilityActionType"; |
472 | |
} |
473 | |
|
474 | |
|
475 | |
|
476 | |
|
477 | |
|
478 | 0 | static class Elements { |
479 | |
|
480 | |
final static String PRINCIPAL_ID = "principalId"; |
481 | |
final static String ROLE_RESPONSIBILITY_ACTION_ID = "roleResponsibilityActionId"; |
482 | |
final static String PARALLEL_ROUTING_GROUPING_CODE = "parallelRoutingGroupingCode"; |
483 | |
final static String ACTION_TYPE_CODE = "actionTypeCode"; |
484 | |
final static String ACTION_POLICY_CODE = "actionPolicyCode"; |
485 | |
final static String PRIORITY_NUMBER = "priorityNumber"; |
486 | |
final static String GROUP_ID = "groupId"; |
487 | |
final static String MEMBER_ROLE_ID = "memberRoleId"; |
488 | |
final static String RESPONSIBILITY_NAME = "responsibilityName"; |
489 | |
final static String RESPONSIBILITY_ID = "responsibilityId"; |
490 | |
final static String RESPONSIBILITY_NAMESPACE_CODE = "responsibilityNamespaceCode"; |
491 | |
final static String FORCE_ACTION = "forceAction"; |
492 | |
final static String QUALIFIER = "qualifier"; |
493 | |
final static String DELEGATES = "delegates"; |
494 | |
final static String ROLE_ID = "roleId"; |
495 | |
|
496 | |
} |
497 | |
|
498 | |
} |