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 org.apache.commons.lang.StringUtils; |
19 | |
import org.joda.time.DateTime; |
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.DateTimeAdapter; |
24 | |
import org.w3c.dom.Element; |
25 | |
|
26 | |
import javax.xml.bind.annotation.XmlAccessType; |
27 | |
import javax.xml.bind.annotation.XmlAccessorType; |
28 | |
import javax.xml.bind.annotation.XmlAnyElement; |
29 | |
import javax.xml.bind.annotation.XmlElement; |
30 | |
import javax.xml.bind.annotation.XmlRootElement; |
31 | |
import javax.xml.bind.annotation.XmlType; |
32 | |
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; |
33 | |
import java.io.Serializable; |
34 | |
import java.util.Collection; |
35 | |
|
36 | |
@XmlRootElement(name = ActionTaken.Constants.ROOT_ELEMENT_NAME) |
37 | |
@XmlAccessorType(XmlAccessType.NONE) |
38 | |
@XmlType(name = ActionTaken.Constants.TYPE_NAME, propOrder = { |
39 | |
ActionTaken.Elements.ID, |
40 | |
ActionTaken.Elements.DOCUMENT_ID, |
41 | |
ActionTaken.Elements.PRINCIPAL_ID, |
42 | |
ActionTaken.Elements.DELEGATOR_PRINCIPAL_ID, |
43 | |
ActionTaken.Elements.DELEGATOR_GROUP_ID, |
44 | |
ActionTaken.Elements.ACTION_TAKEN_CODE, |
45 | |
ActionTaken.Elements.ACTION_DATE, |
46 | |
ActionTaken.Elements.ANNOTATION, |
47 | |
ActionTaken.Elements.CURRENT, |
48 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
49 | |
}) |
50 | 0 | public final class ActionTaken extends AbstractDataTransferObject implements ActionTakenContract { |
51 | |
|
52 | |
private static final long serialVersionUID = 8411150332911080837L; |
53 | |
|
54 | |
@XmlElement(name = Elements.ID, required = true) |
55 | |
private final String id; |
56 | |
|
57 | |
@XmlElement(name = Elements.DOCUMENT_ID, required = true) |
58 | |
private final String documentId; |
59 | |
|
60 | |
@XmlElement(name = Elements.PRINCIPAL_ID, required = true) |
61 | |
private final String principalId; |
62 | |
|
63 | |
@XmlElement(name = Elements.DELEGATOR_PRINCIPAL_ID, required = false) |
64 | |
private final String delegatorPrincipalId; |
65 | |
|
66 | |
@XmlElement(name = Elements.DELEGATOR_GROUP_ID, required = false) |
67 | |
private final String delegatorGroupId; |
68 | |
|
69 | |
@XmlElement(name = Elements.ACTION_TAKEN_CODE, required = true) |
70 | |
private final String actionTakenCode; |
71 | |
|
72 | |
@XmlElement(name = Elements.ACTION_DATE, required = true) |
73 | |
@XmlJavaTypeAdapter(DateTimeAdapter.class) |
74 | |
private final DateTime actionDate; |
75 | |
|
76 | |
@XmlElement(name = Elements.ANNOTATION, required = false) |
77 | |
private final String annotation; |
78 | |
|
79 | |
@XmlElement(name = Elements.CURRENT, required = true) |
80 | |
private final boolean current; |
81 | |
|
82 | 0 | @SuppressWarnings("unused") |
83 | |
@XmlAnyElement |
84 | |
private final Collection<Element> _futureElements = null; |
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | 0 | private ActionTaken() { |
91 | 0 | this.id = null; |
92 | 0 | this.documentId = null; |
93 | 0 | this.principalId = null; |
94 | 0 | this.delegatorPrincipalId = null; |
95 | 0 | this.delegatorGroupId = null; |
96 | 0 | this.actionTakenCode = null; |
97 | 0 | this.actionDate = null; |
98 | 0 | this.annotation = null; |
99 | 0 | this.current = false; |
100 | 0 | } |
101 | |
|
102 | 0 | private ActionTaken(Builder builder) { |
103 | 0 | this.annotation = builder.getAnnotation(); |
104 | 0 | this.id = builder.getId(); |
105 | 0 | this.documentId = builder.getDocumentId(); |
106 | 0 | this.principalId = builder.getPrincipalId(); |
107 | 0 | this.delegatorPrincipalId = builder.getDelegatorPrincipalId(); |
108 | 0 | this.delegatorGroupId = builder.getDelegatorGroupId(); |
109 | 0 | this.actionTakenCode = builder.getActionTaken().getCode(); |
110 | 0 | this.actionDate = builder.getActionDate(); |
111 | 0 | this.current = builder.isCurrent(); |
112 | 0 | } |
113 | |
|
114 | |
@Override |
115 | |
public String getId() { |
116 | 0 | return this.id; |
117 | |
} |
118 | |
|
119 | |
@Override |
120 | |
public String getDocumentId() { |
121 | 0 | return this.documentId; |
122 | |
} |
123 | |
|
124 | |
@Override |
125 | |
public String getPrincipalId() { |
126 | 0 | return this.principalId; |
127 | |
} |
128 | |
|
129 | |
@Override |
130 | |
public String getDelegatorPrincipalId() { |
131 | 0 | return this.delegatorPrincipalId; |
132 | |
} |
133 | |
|
134 | |
@Override |
135 | |
public String getDelegatorGroupId() { |
136 | 0 | return this.delegatorGroupId; |
137 | |
} |
138 | |
|
139 | |
@Override |
140 | |
public ActionType getActionTaken() { |
141 | 0 | return ActionType.fromCode(actionTakenCode); |
142 | |
} |
143 | |
|
144 | |
@Override |
145 | |
public DateTime getActionDate() { |
146 | 0 | return this.actionDate; |
147 | |
} |
148 | |
|
149 | |
@Override |
150 | |
public String getAnnotation() { |
151 | 0 | return this.annotation; |
152 | |
} |
153 | |
|
154 | |
@Override |
155 | |
public boolean isCurrent() { |
156 | 0 | return this.current; |
157 | |
} |
158 | |
|
159 | |
|
160 | |
|
161 | |
|
162 | 0 | public final static class Builder implements Serializable, ModelBuilder, ActionTakenContract { |
163 | |
|
164 | |
private static final long serialVersionUID = -1226075070994810756L; |
165 | |
|
166 | |
private String id; |
167 | |
private String documentId; |
168 | |
private String principalId; |
169 | |
private String delegatorPrincipalId; |
170 | |
private String delegatorGroupId; |
171 | |
private ActionType actionTaken; |
172 | |
private DateTime actionDate; |
173 | |
private String annotation; |
174 | |
private boolean current; |
175 | |
|
176 | 0 | private Builder(String id, String documentId, String principalId, ActionType actionTaken) { |
177 | 0 | setId(id); |
178 | 0 | setDocumentId(documentId); |
179 | 0 | setPrincipalId(principalId); |
180 | 0 | setActionTaken(actionTaken); |
181 | 0 | setActionDate(new DateTime()); |
182 | 0 | setCurrent(true); |
183 | 0 | } |
184 | |
|
185 | |
public static Builder create(String id, String documentId, String principalId, ActionType actionTaken) { |
186 | 0 | return new Builder(id, documentId, principalId, actionTaken); |
187 | |
} |
188 | |
|
189 | |
public static Builder create(ActionTakenContract contract) { |
190 | 0 | if (contract == null) { |
191 | 0 | throw new IllegalArgumentException("contract was null"); |
192 | |
} |
193 | 0 | Builder builder = create(contract.getId(), contract.getDocumentId(), contract.getPrincipalId(), contract.getActionTaken()); |
194 | 0 | builder.setDelegatorPrincipalId(contract.getDelegatorPrincipalId()); |
195 | 0 | builder.setDelegatorGroupId(contract.getDelegatorGroupId()); |
196 | 0 | builder.setActionDate(contract.getActionDate()); |
197 | 0 | builder.setAnnotation(contract.getAnnotation()); |
198 | 0 | builder.setCurrent(contract.isCurrent()); |
199 | 0 | return builder; |
200 | |
} |
201 | |
|
202 | |
public ActionTaken build() { |
203 | 0 | return new ActionTaken(this); |
204 | |
} |
205 | |
|
206 | |
@Override |
207 | |
public String getId() { |
208 | 0 | return this.id; |
209 | |
} |
210 | |
|
211 | |
@Override |
212 | |
public String getDocumentId() { |
213 | 0 | return this.documentId; |
214 | |
} |
215 | |
|
216 | |
@Override |
217 | |
public String getPrincipalId() { |
218 | 0 | return this.principalId; |
219 | |
} |
220 | |
|
221 | |
@Override |
222 | |
public String getDelegatorPrincipalId() { |
223 | 0 | return this.delegatorPrincipalId; |
224 | |
} |
225 | |
|
226 | |
@Override |
227 | |
public String getDelegatorGroupId() { |
228 | 0 | return this.delegatorGroupId; |
229 | |
} |
230 | |
|
231 | |
@Override |
232 | |
public ActionType getActionTaken() { |
233 | 0 | return this.actionTaken; |
234 | |
} |
235 | |
|
236 | |
@Override |
237 | |
public DateTime getActionDate() { |
238 | 0 | return this.actionDate; |
239 | |
} |
240 | |
|
241 | |
@Override |
242 | |
public String getAnnotation() { |
243 | 0 | return this.annotation; |
244 | |
} |
245 | |
|
246 | |
@Override |
247 | |
public boolean isCurrent() { |
248 | 0 | return this.current; |
249 | |
} |
250 | |
|
251 | |
public void setId(String id) { |
252 | 0 | if (StringUtils.isBlank(id)) { |
253 | 0 | throw new IllegalArgumentException("id was null or blank"); |
254 | |
} |
255 | 0 | this.id = id; |
256 | 0 | } |
257 | |
|
258 | |
public void setDocumentId(String documentId) { |
259 | 0 | if (StringUtils.isBlank(documentId)) { |
260 | 0 | throw new IllegalArgumentException("documentId was null or blank"); |
261 | |
} |
262 | 0 | this.documentId = documentId; |
263 | 0 | } |
264 | |
|
265 | |
public void setPrincipalId(String principalId) { |
266 | 0 | if (StringUtils.isBlank(principalId)) { |
267 | 0 | throw new IllegalArgumentException("principalId was null or blank"); |
268 | |
} |
269 | 0 | this.principalId = principalId; |
270 | 0 | } |
271 | |
|
272 | |
public void setDelegatorPrincipalId(String delegatorPrincipalId) { |
273 | 0 | this.delegatorPrincipalId = delegatorPrincipalId; |
274 | 0 | } |
275 | |
|
276 | |
public void setDelegatorGroupId(String delegatorGroupId) { |
277 | 0 | this.delegatorGroupId = delegatorGroupId; |
278 | 0 | } |
279 | |
|
280 | |
public void setActionTaken(ActionType actionTaken) { |
281 | 0 | if (actionTaken == null) { |
282 | 0 | throw new IllegalArgumentException("actionTaken was null"); |
283 | |
} |
284 | 0 | this.actionTaken = actionTaken; |
285 | 0 | } |
286 | |
|
287 | |
public void setActionDate(DateTime actionDate) { |
288 | 0 | if (actionDate == null) { |
289 | 0 | throw new IllegalArgumentException("actionDate was null"); |
290 | |
} |
291 | 0 | this.actionDate = actionDate; |
292 | 0 | } |
293 | |
|
294 | |
public void setAnnotation(String annotation) { |
295 | 0 | this.annotation = annotation; |
296 | 0 | } |
297 | |
|
298 | |
public void setCurrent(boolean current) { |
299 | 0 | this.current = current; |
300 | 0 | } |
301 | |
|
302 | |
} |
303 | |
|
304 | |
|
305 | |
|
306 | |
|
307 | 0 | static class Constants { |
308 | |
final static String ROOT_ELEMENT_NAME = "actionTaken"; |
309 | |
final static String TYPE_NAME = "ActionTakenType"; |
310 | |
} |
311 | |
|
312 | |
|
313 | |
|
314 | |
|
315 | |
|
316 | 0 | static class Elements { |
317 | |
final static String ID = "id"; |
318 | |
final static String DOCUMENT_ID = "documentId"; |
319 | |
final static String PRINCIPAL_ID = "principalId"; |
320 | |
final static String DELEGATOR_PRINCIPAL_ID = "delegatorPrincipalId"; |
321 | |
final static String DELEGATOR_GROUP_ID = "delegatorGroupId"; |
322 | |
final static String ACTION_TAKEN_CODE = "actionTakenCode"; |
323 | |
final static String ACTION_DATE = "actionDate"; |
324 | |
final static String ANNOTATION = "annotation"; |
325 | |
final static String CURRENT = "current"; |
326 | |
} |
327 | |
|
328 | |
} |