1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kew.framework.docsearch; |
17 | |
|
18 | |
import org.apache.commons.lang.StringUtils; |
19 | |
import org.kuali.rice.core.api.CoreConstants; |
20 | |
import org.kuali.rice.core.api.mo.AbstractDataTransferObject; |
21 | |
import org.kuali.rice.kew.api.document.Document; |
22 | |
import org.kuali.rice.kew.api.document.DocumentContent; |
23 | |
import org.w3c.dom.Element; |
24 | |
|
25 | |
import javax.xml.bind.annotation.XmlAccessType; |
26 | |
import javax.xml.bind.annotation.XmlAccessorType; |
27 | |
import javax.xml.bind.annotation.XmlAnyElement; |
28 | |
import javax.xml.bind.annotation.XmlElement; |
29 | |
import javax.xml.bind.annotation.XmlRootElement; |
30 | |
import javax.xml.bind.annotation.XmlType; |
31 | |
import java.io.Serializable; |
32 | |
import java.util.Collection; |
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
@XmlRootElement(name = DocumentSearchContext.Constants.ROOT_ELEMENT_NAME) |
41 | |
@XmlAccessorType(XmlAccessType.NONE) |
42 | |
@XmlType(name = DocumentSearchContext.Constants.TYPE_NAME, propOrder = { |
43 | |
DocumentSearchContext.Elements.DOCUMENT, |
44 | |
DocumentSearchContext.Elements.DOCUMENT_CONTENT, |
45 | |
DocumentSearchContext.Elements.DOCUMENT_TYPE_NAME, |
46 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
47 | |
}) |
48 | |
public final class DocumentSearchContext extends AbstractDataTransferObject { |
49 | |
|
50 | |
@XmlElement(name = Elements.DOCUMENT, required = false) |
51 | |
private final Document document; |
52 | |
|
53 | |
@XmlElement(name = Elements.DOCUMENT_CONTENT, required = false) |
54 | |
private final DocumentContent documentContent; |
55 | |
|
56 | |
@XmlElement(name = Elements.DOCUMENT_TYPE_NAME, required = false) |
57 | |
private final String documentTypeName; |
58 | |
|
59 | 0 | @SuppressWarnings("unused") |
60 | |
@XmlAnyElement |
61 | |
private final Collection<Element> _futureElements = null; |
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | 0 | private DocumentSearchContext() { |
67 | 0 | this.document = null; |
68 | 0 | this.documentContent = null; |
69 | 0 | this.documentTypeName = null; |
70 | 0 | } |
71 | |
|
72 | 0 | private DocumentSearchContext(Document document, DocumentContent documentContent, String documentTypeName) { |
73 | 0 | this.document = document; |
74 | 0 | this.documentContent = documentContent; |
75 | 0 | this.documentTypeName = documentTypeName; |
76 | 0 | } |
77 | |
|
78 | |
public static DocumentSearchContext createFullContext(Document document, DocumentContent documentContent, String documentTypeName) { |
79 | 0 | if (document == null) { |
80 | 0 | throw new IllegalArgumentException("document was null"); |
81 | |
} |
82 | 0 | if (documentContent == null) { |
83 | 0 | throw new IllegalArgumentException("documentContent was null"); |
84 | |
} |
85 | 0 | if (StringUtils.isBlank(documentTypeName)) { |
86 | 0 | throw new IllegalArgumentException("documentTypeName was null or blank"); |
87 | |
} |
88 | 0 | return new DocumentSearchContext(document, documentContent, documentTypeName); |
89 | |
} |
90 | |
|
91 | |
public static DocumentSearchContext createDocumentTypeNameContext(String documentTypeName) { |
92 | 0 | if (StringUtils.isBlank(documentTypeName)) { |
93 | 0 | throw new IllegalArgumentException("documentTypeName was null or blank"); |
94 | |
} |
95 | 0 | return new DocumentSearchContext(null, null, documentTypeName); |
96 | |
} |
97 | |
|
98 | |
public Document getDocument() { |
99 | 0 | return document; |
100 | |
} |
101 | |
|
102 | |
public DocumentContent getDocumentContent() { |
103 | 0 | return documentContent; |
104 | |
} |
105 | |
|
106 | |
public String getDocumentTypeName() { |
107 | 0 | return documentTypeName; |
108 | |
} |
109 | |
|
110 | |
|
111 | |
|
112 | |
|
113 | 0 | static class Constants { |
114 | |
final static String ROOT_ELEMENT_NAME = "documentSearchContext"; |
115 | |
final static String TYPE_NAME = "DocumentSearchContextType"; |
116 | 0 | final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[] { CoreConstants.CommonElements.FUTURE_ELEMENTS }; |
117 | |
} |
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | 0 | static class Elements { |
123 | |
final static String DOCUMENT = "document"; |
124 | |
final static String DOCUMENT_CONTENT = "documentContent"; |
125 | |
final static String DOCUMENT_TYPE_NAME = "documentTypeName"; |
126 | |
} |
127 | |
|
128 | |
} |