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