1 | |
package org.kuali.rice.kew.api.doctype; |
2 | |
|
3 | |
import java.io.Serializable; |
4 | |
import java.util.Collection; |
5 | |
import java.util.HashMap; |
6 | |
import java.util.Map; |
7 | |
|
8 | |
import javax.xml.bind.annotation.XmlAccessType; |
9 | |
import javax.xml.bind.annotation.XmlAccessorType; |
10 | |
import javax.xml.bind.annotation.XmlAnyElement; |
11 | |
import javax.xml.bind.annotation.XmlElement; |
12 | |
import javax.xml.bind.annotation.XmlRootElement; |
13 | |
import javax.xml.bind.annotation.XmlType; |
14 | |
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; |
15 | |
|
16 | |
import org.apache.commons.lang.StringUtils; |
17 | |
import org.apache.commons.lang.builder.EqualsBuilder; |
18 | |
import org.apache.commons.lang.builder.HashCodeBuilder; |
19 | |
import org.apache.commons.lang.builder.ToStringBuilder; |
20 | |
import org.kuali.rice.core.api.CoreConstants; |
21 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
22 | |
import org.kuali.rice.core.api.mo.ModelObjectComplete; |
23 | |
import org.w3c.dom.Element; |
24 | |
|
25 | |
@XmlRootElement(name = DocumentType.Constants.ROOT_ELEMENT_NAME) |
26 | |
@XmlAccessorType(XmlAccessType.NONE) |
27 | |
@XmlType(name = DocumentType.Constants.TYPE_NAME, propOrder = { |
28 | |
DocumentType.Elements.ID, |
29 | |
DocumentType.Elements.NAME, |
30 | |
DocumentType.Elements.DOCUMENT_TYPE_VERSION, |
31 | |
DocumentType.Elements.LABEL, |
32 | |
DocumentType.Elements.DESCRIPTION, |
33 | |
DocumentType.Elements.PARENT_ID, |
34 | |
DocumentType.Elements.ACTIVE, |
35 | |
DocumentType.Elements.DOC_HANDLER_URL, |
36 | |
DocumentType.Elements.HELP_DEFINITION_URL, |
37 | |
DocumentType.Elements.DOC_SEARCH_HELP_URL, |
38 | |
DocumentType.Elements.POST_PROCESSOR_NAME, |
39 | |
DocumentType.Elements.APPLICATION_ID, |
40 | |
DocumentType.Elements.CURRENT, |
41 | |
DocumentType.Elements.BLANKET_APPROVE_GROUP_ID, |
42 | |
DocumentType.Elements.SUPER_USER_GROUP_ID, |
43 | |
DocumentType.Elements.POLICIES, |
44 | |
CoreConstants.CommonElements.VERSION_NUMBER, |
45 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
46 | |
}) |
47 | 0 | public final class DocumentType implements ModelObjectComplete, DocumentTypeContract { |
48 | |
|
49 | |
private static final long serialVersionUID = 6866926296038814812L; |
50 | |
|
51 | |
@XmlElement(name = Elements.ID, required = false) |
52 | |
private final String id; |
53 | |
|
54 | |
@XmlElement(name = Elements.NAME, required = true) |
55 | |
private final String name; |
56 | |
|
57 | |
@XmlElement(name = Elements.DOCUMENT_TYPE_VERSION, required = false) |
58 | |
private final Integer documentTypeVersion; |
59 | |
|
60 | |
@XmlElement(name = Elements.LABEL, required = false) |
61 | |
private final String label; |
62 | |
|
63 | |
@XmlElement(name = Elements.DESCRIPTION, required = false) |
64 | |
private final String description; |
65 | |
|
66 | |
@XmlElement(name = Elements.PARENT_ID, required = false) |
67 | |
private final String parentId; |
68 | |
|
69 | |
@XmlElement(name = Elements.ACTIVE, required = true) |
70 | |
private final boolean active; |
71 | |
|
72 | |
@XmlElement(name = Elements.DOC_HANDLER_URL, required = false) |
73 | |
private final String docHandlerUrl; |
74 | |
|
75 | |
@XmlElement(name = Elements.HELP_DEFINITION_URL, required = false) |
76 | |
private final String helpDefinitionUrl; |
77 | |
|
78 | |
@XmlElement(name = Elements.DOC_SEARCH_HELP_URL, required = false) |
79 | |
private final String docSearchHelpUrl; |
80 | |
|
81 | |
@XmlElement(name = Elements.POST_PROCESSOR_NAME, required = false) |
82 | |
private final String postProcessorName; |
83 | |
|
84 | |
@XmlElement(name = Elements.APPLICATION_ID, required = false) |
85 | |
private final String applicationId; |
86 | |
|
87 | |
@XmlElement(name = Elements.CURRENT, required = true) |
88 | |
private final boolean current; |
89 | |
|
90 | |
@XmlElement(name = Elements.BLANKET_APPROVE_GROUP_ID, required = false) |
91 | |
private final String blanketApproveGroupId; |
92 | |
|
93 | |
@XmlElement(name = Elements.SUPER_USER_GROUP_ID, required = false) |
94 | |
private final String superUserGroupId; |
95 | |
|
96 | |
@XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false) |
97 | |
private final Long versionNumber; |
98 | |
|
99 | |
@XmlElement(name = Elements.POLICIES, required = false) |
100 | |
@XmlJavaTypeAdapter(DocumentTypePolicyMapAdapter.class) |
101 | |
private final Map<DocumentTypePolicy, String> policies; |
102 | |
|
103 | 0 | @SuppressWarnings("unused") |
104 | |
@XmlAnyElement |
105 | |
private final Collection<Element> _futureElements = null; |
106 | |
|
107 | |
|
108 | |
|
109 | |
|
110 | 0 | private DocumentType() { |
111 | 0 | this.id = null; |
112 | 0 | this.name = null; |
113 | 0 | this.documentTypeVersion = null; |
114 | 0 | this.label = null; |
115 | 0 | this.description = null; |
116 | 0 | this.parentId = null; |
117 | 0 | this.active = false; |
118 | 0 | this.docHandlerUrl = null; |
119 | 0 | this.helpDefinitionUrl = null; |
120 | 0 | this.docSearchHelpUrl = null; |
121 | 0 | this.postProcessorName = null; |
122 | 0 | this.applicationId = null; |
123 | 0 | this.current = false; |
124 | 0 | this.blanketApproveGroupId = null; |
125 | 0 | this.superUserGroupId = null; |
126 | 0 | this.policies = null; |
127 | 0 | this.versionNumber = null; |
128 | 0 | } |
129 | |
|
130 | 0 | private DocumentType(Builder builder) { |
131 | 0 | this.name = builder.getName(); |
132 | 0 | this.id = builder.getId(); |
133 | 0 | this.documentTypeVersion = builder.getDocumentTypeVersion(); |
134 | 0 | this.label = builder.getLabel(); |
135 | 0 | this.description = builder.getDescription(); |
136 | 0 | this.parentId = builder.getParentId(); |
137 | 0 | this.active = builder.isActive(); |
138 | 0 | this.docHandlerUrl = builder.getDocHandlerUrl(); |
139 | 0 | this.helpDefinitionUrl = builder.getHelpDefinitionUrl(); |
140 | 0 | this.docSearchHelpUrl = builder.getDocSearchHelpUrl(); |
141 | 0 | this.postProcessorName = builder.getPostProcessorName(); |
142 | 0 | this.applicationId = builder.getApplicationId(); |
143 | 0 | this.current = builder.isCurrent(); |
144 | 0 | this.blanketApproveGroupId = builder.getBlanketApproveGroupId(); |
145 | 0 | this.superUserGroupId = builder.getSuperUserGroupId(); |
146 | 0 | this.policies = new HashMap<DocumentTypePolicy, String>(builder.getPolicies()); |
147 | 0 | this.versionNumber = builder.getVersionNumber(); |
148 | 0 | } |
149 | |
|
150 | |
@Override |
151 | |
public String getId() { |
152 | 0 | return this.id; |
153 | |
} |
154 | |
|
155 | |
@Override |
156 | |
public String getName() { |
157 | 0 | return this.name; |
158 | |
} |
159 | |
|
160 | |
@Override |
161 | |
public Integer getDocumentTypeVersion() { |
162 | 0 | return this.documentTypeVersion; |
163 | |
} |
164 | |
|
165 | |
@Override |
166 | |
public String getLabel() { |
167 | 0 | return this.label; |
168 | |
} |
169 | |
|
170 | |
@Override |
171 | |
public String getDescription() { |
172 | 0 | return this.description; |
173 | |
} |
174 | |
|
175 | |
@Override |
176 | |
public String getParentId() { |
177 | 0 | return this.parentId; |
178 | |
} |
179 | |
|
180 | |
@Override |
181 | |
public boolean isActive() { |
182 | 0 | return this.active; |
183 | |
} |
184 | |
|
185 | |
@Override |
186 | |
public String getDocHandlerUrl() { |
187 | 0 | return this.docHandlerUrl; |
188 | |
} |
189 | |
|
190 | |
@Override |
191 | |
public String getHelpDefinitionUrl() { |
192 | 0 | return this.helpDefinitionUrl; |
193 | |
} |
194 | |
|
195 | |
@Override |
196 | |
public String getDocSearchHelpUrl() { |
197 | 0 | return this.docSearchHelpUrl; |
198 | |
} |
199 | |
|
200 | |
@Override |
201 | |
public String getPostProcessorName() { |
202 | 0 | return this.postProcessorName; |
203 | |
} |
204 | |
|
205 | |
@Override |
206 | |
public String getApplicationId() { |
207 | 0 | return this.applicationId; |
208 | |
} |
209 | |
|
210 | |
@Override |
211 | |
public boolean isCurrent() { |
212 | 0 | return this.current; |
213 | |
} |
214 | |
|
215 | |
@Override |
216 | |
public String getBlanketApproveGroupId() { |
217 | 0 | return this.blanketApproveGroupId; |
218 | |
} |
219 | |
|
220 | |
@Override |
221 | |
public String getSuperUserGroupId() { |
222 | 0 | return this.superUserGroupId; |
223 | |
} |
224 | |
|
225 | |
@Override |
226 | |
public Map<DocumentTypePolicy, String> getPolicies() { |
227 | 0 | return this.policies; |
228 | |
} |
229 | |
|
230 | |
@Override |
231 | |
public Long getVersionNumber() { |
232 | 0 | return this.versionNumber; |
233 | |
} |
234 | |
|
235 | |
@Override |
236 | |
public int hashCode() { |
237 | 0 | return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
238 | |
} |
239 | |
|
240 | |
@Override |
241 | |
public boolean equals(Object object) { |
242 | 0 | return EqualsBuilder.reflectionEquals(object, this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
243 | |
} |
244 | |
|
245 | |
@Override |
246 | |
public String toString() { |
247 | 0 | return ToStringBuilder.reflectionToString(this); |
248 | |
} |
249 | |
|
250 | |
|
251 | |
|
252 | |
|
253 | |
|
254 | 0 | public final static class Builder implements Serializable, ModelBuilder, DocumentTypeContract { |
255 | |
|
256 | |
private static final long serialVersionUID = 1678979180435181578L; |
257 | |
|
258 | |
private String id; |
259 | |
private String name; |
260 | |
private Integer documentTypeVersion; |
261 | |
private String label; |
262 | |
private String description; |
263 | |
private String parentId; |
264 | |
private boolean active; |
265 | |
private String docHandlerUrl; |
266 | |
private String helpDefinitionUrl; |
267 | |
private String docSearchHelpUrl; |
268 | |
private String postProcessorName; |
269 | |
private String applicationId; |
270 | |
private boolean current; |
271 | |
private String blanketApproveGroupId; |
272 | |
private String superUserGroupId; |
273 | |
private Map<DocumentTypePolicy, String> policies; |
274 | |
private Long versionNumber; |
275 | |
|
276 | 0 | private Builder(String name) { |
277 | 0 | setName(name); |
278 | 0 | setActive(true); |
279 | 0 | setCurrent(true); |
280 | 0 | this.policies = new HashMap<DocumentTypePolicy, String>(); |
281 | 0 | } |
282 | |
|
283 | |
public static Builder create(String name) { |
284 | 0 | return new Builder(name); |
285 | |
} |
286 | |
|
287 | |
public static Builder create(DocumentTypeContract contract) { |
288 | 0 | if (contract == null) { |
289 | 0 | throw new IllegalArgumentException("contract was null"); |
290 | |
} |
291 | 0 | Builder builder = create(contract.getName()); |
292 | 0 | builder.setId(contract.getId()); |
293 | 0 | builder.setDocumentTypeVersion(contract.getDocumentTypeVersion()); |
294 | 0 | builder.setLabel(contract.getLabel()); |
295 | 0 | builder.setDescription(contract.getDescription()); |
296 | 0 | builder.setParentId(contract.getParentId()); |
297 | 0 | builder.setActive(contract.isActive()); |
298 | 0 | builder.setDocHandlerUrl(contract.getDocHandlerUrl()); |
299 | 0 | builder.setHelpDefinitionUrl(contract.getHelpDefinitionUrl()); |
300 | 0 | builder.setDocSearchHelpUrl(contract.getDocSearchHelpUrl()); |
301 | 0 | builder.setPostProcessorName(contract.getPostProcessorName()); |
302 | 0 | builder.setApplicationId(contract.getApplicationId()); |
303 | 0 | builder.setCurrent(contract.isCurrent()); |
304 | 0 | builder.setBlanketApproveGroupId(contract.getBlanketApproveGroupId()); |
305 | 0 | builder.setSuperUserGroupId(contract.getSuperUserGroupId()); |
306 | 0 | builder.setPolicies(new HashMap<DocumentTypePolicy, String>(contract.getPolicies())); |
307 | 0 | builder.setVersionNumber(contract.getVersionNumber()); |
308 | 0 | return builder; |
309 | |
} |
310 | |
|
311 | |
public DocumentType build() { |
312 | 0 | return new DocumentType(this); |
313 | |
} |
314 | |
|
315 | |
@Override |
316 | |
public String getId() { |
317 | 0 | return this.id; |
318 | |
} |
319 | |
|
320 | |
@Override |
321 | |
public String getName() { |
322 | 0 | return this.name; |
323 | |
} |
324 | |
|
325 | |
@Override |
326 | |
public Integer getDocumentTypeVersion() { |
327 | 0 | return this.documentTypeVersion; |
328 | |
} |
329 | |
|
330 | |
@Override |
331 | |
public String getLabel() { |
332 | 0 | return this.label; |
333 | |
} |
334 | |
|
335 | |
@Override |
336 | |
public String getDescription() { |
337 | 0 | return this.description; |
338 | |
} |
339 | |
|
340 | |
@Override |
341 | |
public String getParentId() { |
342 | 0 | return this.parentId; |
343 | |
} |
344 | |
|
345 | |
@Override |
346 | |
public boolean isActive() { |
347 | 0 | return this.active; |
348 | |
} |
349 | |
|
350 | |
@Override |
351 | |
public String getDocHandlerUrl() { |
352 | 0 | return this.docHandlerUrl; |
353 | |
} |
354 | |
|
355 | |
@Override |
356 | |
public String getHelpDefinitionUrl() { |
357 | 0 | return this.helpDefinitionUrl; |
358 | |
} |
359 | |
|
360 | |
@Override |
361 | |
public String getDocSearchHelpUrl() { |
362 | 0 | return this.docSearchHelpUrl; |
363 | |
} |
364 | |
|
365 | |
@Override |
366 | |
public String getPostProcessorName() { |
367 | 0 | return this.postProcessorName; |
368 | |
} |
369 | |
|
370 | |
@Override |
371 | |
public String getApplicationId() { |
372 | 0 | return this.applicationId; |
373 | |
} |
374 | |
|
375 | |
@Override |
376 | |
public boolean isCurrent() { |
377 | 0 | return this.current; |
378 | |
} |
379 | |
|
380 | |
@Override |
381 | |
public String getBlanketApproveGroupId() { |
382 | 0 | return this.blanketApproveGroupId; |
383 | |
} |
384 | |
|
385 | |
@Override |
386 | |
public String getSuperUserGroupId() { |
387 | 0 | return this.superUserGroupId; |
388 | |
} |
389 | |
|
390 | |
@Override |
391 | |
public Map<DocumentTypePolicy, String> getPolicies() { |
392 | 0 | return this.policies; |
393 | |
} |
394 | |
|
395 | |
@Override |
396 | |
public Long getVersionNumber() { |
397 | 0 | return this.versionNumber; |
398 | |
} |
399 | |
|
400 | |
public void setId(String id) { |
401 | 0 | this.id = id; |
402 | 0 | } |
403 | |
|
404 | |
public void setName(String name) { |
405 | 0 | if (StringUtils.isBlank(name)) { |
406 | 0 | throw new IllegalArgumentException("name was null or blank"); |
407 | |
} |
408 | 0 | this.name = name; |
409 | 0 | } |
410 | |
|
411 | |
public void setDocumentTypeVersion(Integer documentTypeVersion) { |
412 | 0 | this.documentTypeVersion = documentTypeVersion; |
413 | 0 | } |
414 | |
|
415 | |
public void setLabel(String label) { |
416 | 0 | this.label = label; |
417 | 0 | } |
418 | |
|
419 | |
public void setDescription(String description) { |
420 | 0 | this.description = description; |
421 | 0 | } |
422 | |
|
423 | |
public void setParentId(String parentId) { |
424 | 0 | this.parentId = parentId; |
425 | 0 | } |
426 | |
|
427 | |
public void setActive(boolean active) { |
428 | 0 | this.active = active; |
429 | 0 | } |
430 | |
|
431 | |
public void setDocHandlerUrl(String docHandlerUrl) { |
432 | 0 | this.docHandlerUrl = docHandlerUrl; |
433 | 0 | } |
434 | |
|
435 | |
public void setHelpDefinitionUrl(String helpDefinitionUrl) { |
436 | 0 | this.helpDefinitionUrl = helpDefinitionUrl; |
437 | 0 | } |
438 | |
|
439 | |
public void setDocSearchHelpUrl(String docSearchHelpUrl) { |
440 | 0 | this.docSearchHelpUrl = docSearchHelpUrl; |
441 | 0 | } |
442 | |
|
443 | |
public void setPostProcessorName(String postProcessorName) { |
444 | 0 | this.postProcessorName = postProcessorName; |
445 | 0 | } |
446 | |
|
447 | |
public void setApplicationId(String applicationId) { |
448 | 0 | this.applicationId = applicationId; |
449 | 0 | } |
450 | |
|
451 | |
public void setCurrent(boolean current) { |
452 | 0 | this.current = current; |
453 | 0 | } |
454 | |
|
455 | |
public void setBlanketApproveGroupId(String blanketApproveGroupId) { |
456 | 0 | this.blanketApproveGroupId = blanketApproveGroupId; |
457 | 0 | } |
458 | |
|
459 | |
public void setSuperUserGroupId(String superUserGroupId) { |
460 | 0 | this.superUserGroupId = superUserGroupId; |
461 | 0 | } |
462 | |
|
463 | |
public void setPolicies(Map<DocumentTypePolicy, String> policies) { |
464 | 0 | this.policies = policies; |
465 | 0 | } |
466 | |
|
467 | |
public void setVersionNumber(Long versionNumber) { |
468 | 0 | this.versionNumber = versionNumber; |
469 | 0 | } |
470 | |
|
471 | |
} |
472 | |
|
473 | |
|
474 | |
|
475 | |
|
476 | 0 | static class Constants { |
477 | |
final static String ROOT_ELEMENT_NAME = "documentType"; |
478 | |
final static String TYPE_NAME = "DocumentTypeType"; |
479 | 0 | final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[]{CoreConstants.CommonElements.FUTURE_ELEMENTS}; |
480 | |
} |
481 | |
|
482 | |
|
483 | |
|
484 | |
|
485 | |
|
486 | 0 | static class Elements { |
487 | |
final static String ID = "id"; |
488 | |
final static String NAME = "name"; |
489 | |
final static String DOCUMENT_TYPE_VERSION = "documentTypeVersion"; |
490 | |
final static String LABEL = "label"; |
491 | |
final static String DESCRIPTION = "description"; |
492 | |
final static String PARENT_ID = "parentId"; |
493 | |
final static String ACTIVE = "active"; |
494 | |
final static String DOC_HANDLER_URL = "docHandlerUrl"; |
495 | |
final static String HELP_DEFINITION_URL = "helpDefinitionUrl"; |
496 | |
final static String DOC_SEARCH_HELP_URL = "docSearchHelpUrl"; |
497 | |
final static String POST_PROCESSOR_NAME = "postProcessorName"; |
498 | |
final static String APPLICATION_ID = "applicationId"; |
499 | |
final static String CURRENT = "current"; |
500 | |
final static String BLANKET_APPROVE_GROUP_ID = "blanketApproveGroupId"; |
501 | |
final static String SUPER_USER_GROUP_ID = "superUserGroupId"; |
502 | |
final static String POLICIES = "policies"; |
503 | |
} |
504 | |
|
505 | |
} |