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.apache.commons.lang.builder.EqualsBuilder; |
29 | |
import org.apache.commons.lang.builder.HashCodeBuilder; |
30 | |
import org.apache.commons.lang.builder.ToStringBuilder; |
31 | |
import org.kuali.rice.core.api.CoreConstants; |
32 | |
import org.w3c.dom.Element; |
33 | |
|
34 | |
@XmlRootElement(name = AdHocCommand.Constants.ROOT_ELEMENT_NAME) |
35 | |
@XmlAccessorType(XmlAccessType.NONE) |
36 | |
@XmlType(name = AdHocCommand.Constants.TYPE_NAME, propOrder = { |
37 | |
AdHocCommand.Elements.ACTION_REQUESTED_CODE, |
38 | |
AdHocCommand.Elements.NODE_NAME, |
39 | |
AdHocCommand.Elements.RESPONSIBILITY_DESCRIPTION, |
40 | |
AdHocCommand.Elements.FORCE_ACTION, |
41 | |
AdHocCommand.Elements.REQUEST_LABEL, |
42 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
43 | |
}) |
44 | |
abstract class AdHocCommand implements Serializable { |
45 | |
|
46 | |
private static final long serialVersionUID = -4181802858756667726L; |
47 | |
|
48 | |
@XmlElement(name = Elements.ACTION_REQUESTED_CODE, required = true) |
49 | |
private final String actionRequestedCode; |
50 | |
|
51 | |
@XmlElement(name = Elements.NODE_NAME, required = false) |
52 | |
private final String nodeName; |
53 | |
|
54 | |
@XmlElement(name = Elements.RESPONSIBILITY_DESCRIPTION, required = false) |
55 | |
private final String responsibilityDescription; |
56 | |
|
57 | |
@XmlElement(name = Elements.FORCE_ACTION, required = true) |
58 | |
private final boolean forceAction; |
59 | |
|
60 | |
@XmlElement(name = Elements.REQUEST_LABEL, required = false) |
61 | |
private final String requestLabel; |
62 | |
|
63 | 0 | @SuppressWarnings("unused") |
64 | |
@XmlAnyElement |
65 | |
private final Collection<Element> _futureElements = null; |
66 | |
|
67 | 0 | protected AdHocCommand() { |
68 | 0 | this.actionRequestedCode = null; |
69 | 0 | this.nodeName = null; |
70 | 0 | this.responsibilityDescription = null; |
71 | 0 | this.forceAction = false; |
72 | 0 | this.requestLabel = null; |
73 | 0 | } |
74 | |
|
75 | 0 | protected AdHocCommand(Builder<?> builder) { |
76 | 0 | this.actionRequestedCode = builder.getActionRequested().getCode(); |
77 | 0 | this.nodeName = builder.getNodeName(); |
78 | 0 | this.responsibilityDescription = builder.getResponsibilityDescription(); |
79 | 0 | this.forceAction = builder.isForceAction(); |
80 | 0 | this.requestLabel = builder.getRequestLabel(); |
81 | 0 | } |
82 | |
|
83 | |
public ActionRequestType getActionRequested() { |
84 | 0 | return ActionRequestType.fromCode(actionRequestedCode); |
85 | |
} |
86 | |
|
87 | |
public String getNodeName() { |
88 | 0 | return nodeName; |
89 | |
} |
90 | |
|
91 | |
public String getResponsibilityDescription() { |
92 | 0 | return responsibilityDescription; |
93 | |
} |
94 | |
|
95 | |
public boolean isForceAction() { |
96 | 0 | return forceAction; |
97 | |
} |
98 | |
|
99 | |
public String getRequestLabel() { |
100 | 0 | return requestLabel; |
101 | |
} |
102 | |
|
103 | |
protected static abstract class Builder<T> implements Serializable { |
104 | |
|
105 | |
private static final long serialVersionUID = -3002495884401672488L; |
106 | |
|
107 | |
private ActionRequestType actionRequested; |
108 | |
private String nodeName; |
109 | |
private String responsibilityDescription; |
110 | |
private boolean forceAction; |
111 | |
private String requestLabel; |
112 | |
|
113 | |
public abstract T build(); |
114 | |
|
115 | 0 | protected Builder(ActionRequestType actionRequested, String nodeName) { |
116 | 0 | setActionRequested(actionRequested); |
117 | 0 | setNodeName(nodeName); |
118 | 0 | setForceAction(true); |
119 | 0 | } |
120 | |
|
121 | |
public ActionRequestType getActionRequested() { |
122 | 0 | return actionRequested; |
123 | |
} |
124 | |
|
125 | |
public String getNodeName() { |
126 | 0 | return nodeName; |
127 | |
} |
128 | |
|
129 | |
public String getResponsibilityDescription() { |
130 | 0 | return responsibilityDescription; |
131 | |
} |
132 | |
|
133 | |
public boolean isForceAction() { |
134 | 0 | return forceAction; |
135 | |
} |
136 | |
|
137 | |
public String getRequestLabel() { |
138 | 0 | return requestLabel; |
139 | |
} |
140 | |
|
141 | |
public void setActionRequested(ActionRequestType actionRequested) { |
142 | 0 | if (actionRequested == null) { |
143 | 0 | throw new IllegalArgumentException("actionRequested was null"); |
144 | |
} |
145 | 0 | this.actionRequested = actionRequested; |
146 | 0 | } |
147 | |
|
148 | |
public void setNodeName(String nodeName) { |
149 | 0 | this.nodeName = nodeName; |
150 | 0 | } |
151 | |
|
152 | |
public void setResponsibilityDescription(String responsibilityDescription) { |
153 | 0 | this.responsibilityDescription = responsibilityDescription; |
154 | 0 | } |
155 | |
|
156 | |
public void setForceAction(boolean forceAction) { |
157 | 0 | this.forceAction = forceAction; |
158 | 0 | } |
159 | |
|
160 | |
public void setRequestLabel(String requestLabel) { |
161 | 0 | this.requestLabel = requestLabel; |
162 | 0 | } |
163 | |
|
164 | |
} |
165 | |
|
166 | |
@Override |
167 | |
public int hashCode() { |
168 | 0 | return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
169 | |
} |
170 | |
|
171 | |
@Override |
172 | |
public boolean equals(Object object) { |
173 | 0 | return EqualsBuilder.reflectionEquals(object, this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
174 | |
} |
175 | |
|
176 | |
@Override |
177 | |
public String toString() { |
178 | 0 | return ToStringBuilder.reflectionToString(this); |
179 | |
} |
180 | |
|
181 | |
|
182 | |
|
183 | |
|
184 | 0 | static class Constants { |
185 | |
final static String ROOT_ELEMENT_NAME = "adHocCommand"; |
186 | |
final static String TYPE_NAME = "AdHocCommandType"; |
187 | 0 | final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[] { CoreConstants.CommonElements.FUTURE_ELEMENTS }; |
188 | |
} |
189 | |
|
190 | |
|
191 | |
|
192 | |
|
193 | 0 | static class Elements { |
194 | |
final static String ACTION_REQUESTED_CODE = "actionRequestedCode"; |
195 | |
final static String NODE_NAME = "nodeName"; |
196 | |
final static String RESPONSIBILITY_DESCRIPTION = "responsibilityDescription"; |
197 | |
final static String FORCE_ACTION = "forceAction"; |
198 | |
final static String REQUEST_LABEL = "requestLabel"; |
199 | |
} |
200 | |
|
201 | |
} |