1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kew.api.action; |
17 | |
|
18 | |
import java.io.Serializable; |
19 | |
import java.util.Collection; |
20 | |
|
21 | |
import javax.xml.bind.annotation.XmlAccessType; |
22 | |
import javax.xml.bind.annotation.XmlAccessorType; |
23 | |
import javax.xml.bind.annotation.XmlAnyElement; |
24 | |
import javax.xml.bind.annotation.XmlElement; |
25 | |
import javax.xml.bind.annotation.XmlRootElement; |
26 | |
import javax.xml.bind.annotation.XmlType; |
27 | |
|
28 | |
import org.kuali.rice.core.api.CoreConstants; |
29 | |
import org.kuali.rice.core.api.mo.AbstractDataTransferObject; |
30 | |
import org.w3c.dom.Element; |
31 | |
|
32 | |
@XmlRootElement(name = AdHocCommand.Constants.ROOT_ELEMENT_NAME) |
33 | |
@XmlAccessorType(XmlAccessType.NONE) |
34 | |
@XmlType(name = AdHocCommand.Constants.TYPE_NAME, propOrder = { |
35 | |
AdHocCommand.Elements.ACTION_REQUESTED_CODE, |
36 | |
AdHocCommand.Elements.NODE_NAME, |
37 | |
AdHocCommand.Elements.RESPONSIBILITY_DESCRIPTION, |
38 | |
AdHocCommand.Elements.FORCE_ACTION, |
39 | |
AdHocCommand.Elements.REQUEST_LABEL, |
40 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
41 | |
}) |
42 | |
abstract class AdHocCommand extends AbstractDataTransferObject { |
43 | |
|
44 | |
private static final long serialVersionUID = -4181802858756667726L; |
45 | |
|
46 | |
@XmlElement(name = Elements.ACTION_REQUESTED_CODE, required = true) |
47 | |
private final String actionRequestedCode; |
48 | |
|
49 | |
@XmlElement(name = Elements.NODE_NAME, required = false) |
50 | |
private final String nodeName; |
51 | |
|
52 | |
@XmlElement(name = Elements.RESPONSIBILITY_DESCRIPTION, required = false) |
53 | |
private final String responsibilityDescription; |
54 | |
|
55 | |
@XmlElement(name = Elements.FORCE_ACTION, required = true) |
56 | |
private final boolean forceAction; |
57 | |
|
58 | |
@XmlElement(name = Elements.REQUEST_LABEL, required = false) |
59 | |
private final String requestLabel; |
60 | |
|
61 | 0 | @SuppressWarnings("unused") |
62 | |
@XmlAnyElement |
63 | |
private final Collection<Element> _futureElements = null; |
64 | |
|
65 | 0 | protected AdHocCommand() { |
66 | 0 | this.actionRequestedCode = null; |
67 | 0 | this.nodeName = null; |
68 | 0 | this.responsibilityDescription = null; |
69 | 0 | this.forceAction = false; |
70 | 0 | this.requestLabel = null; |
71 | 0 | } |
72 | |
|
73 | 0 | protected AdHocCommand(Builder<?> builder) { |
74 | 0 | this.actionRequestedCode = builder.getActionRequested().getCode(); |
75 | 0 | this.nodeName = builder.getNodeName(); |
76 | 0 | this.responsibilityDescription = builder.getResponsibilityDescription(); |
77 | 0 | this.forceAction = builder.isForceAction(); |
78 | 0 | this.requestLabel = builder.getRequestLabel(); |
79 | 0 | } |
80 | |
|
81 | |
public ActionRequestType getActionRequested() { |
82 | 0 | return ActionRequestType.fromCode(actionRequestedCode); |
83 | |
} |
84 | |
|
85 | |
public String getNodeName() { |
86 | 0 | return nodeName; |
87 | |
} |
88 | |
|
89 | |
public String getResponsibilityDescription() { |
90 | 0 | return responsibilityDescription; |
91 | |
} |
92 | |
|
93 | |
public boolean isForceAction() { |
94 | 0 | return forceAction; |
95 | |
} |
96 | |
|
97 | |
public String getRequestLabel() { |
98 | 0 | return requestLabel; |
99 | |
} |
100 | |
|
101 | |
protected static abstract class Builder<T> implements Serializable { |
102 | |
|
103 | |
private static final long serialVersionUID = -3002495884401672488L; |
104 | |
|
105 | |
private ActionRequestType actionRequested; |
106 | |
private String nodeName; |
107 | |
private String responsibilityDescription; |
108 | |
private boolean forceAction; |
109 | |
private String requestLabel; |
110 | |
|
111 | |
public abstract T build(); |
112 | |
|
113 | 0 | protected Builder(ActionRequestType actionRequested, String nodeName) { |
114 | 0 | setActionRequested(actionRequested); |
115 | 0 | setNodeName(nodeName); |
116 | 0 | setForceAction(true); |
117 | 0 | } |
118 | |
|
119 | |
public ActionRequestType getActionRequested() { |
120 | 0 | return actionRequested; |
121 | |
} |
122 | |
|
123 | |
public String getNodeName() { |
124 | 0 | return nodeName; |
125 | |
} |
126 | |
|
127 | |
public String getResponsibilityDescription() { |
128 | 0 | return responsibilityDescription; |
129 | |
} |
130 | |
|
131 | |
public boolean isForceAction() { |
132 | 0 | return forceAction; |
133 | |
} |
134 | |
|
135 | |
public String getRequestLabel() { |
136 | 0 | return requestLabel; |
137 | |
} |
138 | |
|
139 | |
public void setActionRequested(ActionRequestType actionRequested) { |
140 | 0 | if (actionRequested == null) { |
141 | 0 | throw new IllegalArgumentException("actionRequested was null"); |
142 | |
} |
143 | 0 | this.actionRequested = actionRequested; |
144 | 0 | } |
145 | |
|
146 | |
public void setNodeName(String nodeName) { |
147 | 0 | this.nodeName = nodeName; |
148 | 0 | } |
149 | |
|
150 | |
public void setResponsibilityDescription(String responsibilityDescription) { |
151 | 0 | this.responsibilityDescription = responsibilityDescription; |
152 | 0 | } |
153 | |
|
154 | |
public void setForceAction(boolean forceAction) { |
155 | 0 | this.forceAction = forceAction; |
156 | 0 | } |
157 | |
|
158 | |
public void setRequestLabel(String requestLabel) { |
159 | 0 | this.requestLabel = requestLabel; |
160 | 0 | } |
161 | |
|
162 | |
} |
163 | |
|
164 | |
|
165 | |
|
166 | |
|
167 | 0 | static class Constants { |
168 | |
final static String ROOT_ELEMENT_NAME = "adHocCommand"; |
169 | |
final static String TYPE_NAME = "AdHocCommandType"; |
170 | |
} |
171 | |
|
172 | |
|
173 | |
|
174 | |
|
175 | 0 | static class Elements { |
176 | |
final static String ACTION_REQUESTED_CODE = "actionRequestedCode"; |
177 | |
final static String NODE_NAME = "nodeName"; |
178 | |
final static String RESPONSIBILITY_DESCRIPTION = "responsibilityDescription"; |
179 | |
final static String FORCE_ACTION = "forceAction"; |
180 | |
final static String REQUEST_LABEL = "requestLabel"; |
181 | |
} |
182 | |
|
183 | |
} |