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