1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.kew.api.action; |
18 | |
|
19 | |
import java.io.Serializable; |
20 | |
import java.util.Collection; |
21 | |
|
22 | |
import javax.xml.bind.annotation.XmlAccessType; |
23 | |
import javax.xml.bind.annotation.XmlAccessorType; |
24 | |
import javax.xml.bind.annotation.XmlAnyElement; |
25 | |
import javax.xml.bind.annotation.XmlElement; |
26 | |
import javax.xml.bind.annotation.XmlRootElement; |
27 | |
import javax.xml.bind.annotation.XmlType; |
28 | |
|
29 | |
import org.apache.commons.lang.StringUtils; |
30 | |
import org.kuali.rice.core.api.CoreConstants; |
31 | |
import org.kuali.rice.core.api.mo.AbstractDataTransferObject; |
32 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
33 | |
import org.kuali.rice.kew.api.document.DocumentContentUpdate; |
34 | |
import org.kuali.rice.kew.api.document.DocumentUpdate; |
35 | |
import org.w3c.dom.Element; |
36 | |
|
37 | |
@XmlRootElement(name = DocumentActionParameters.Constants.ROOT_ELEMENT_NAME) |
38 | |
@XmlAccessorType(XmlAccessType.NONE) |
39 | |
@XmlType(name = DocumentActionParameters.Constants.TYPE_NAME, propOrder = { |
40 | |
DocumentActionParameters.Elements.DOCUMENT_ID, |
41 | |
DocumentActionParameters.Elements.PRINCIPAL_ID, |
42 | |
DocumentActionParameters.Elements.ANNOTATION, |
43 | |
DocumentActionParameters.Elements.DOCUMENT_UPDATE, |
44 | |
DocumentActionParameters.Elements.DOCUMENT_CONTENT_UPDATE, |
45 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
46 | |
}) |
47 | 0 | public final class DocumentActionParameters extends AbstractDataTransferObject { |
48 | |
|
49 | |
private static final long serialVersionUID = -7589214734683758734L; |
50 | |
|
51 | |
@XmlElement(name = Elements.DOCUMENT_ID, required = true) |
52 | |
private final String documentId; |
53 | |
|
54 | |
@XmlElement(name = Elements.PRINCIPAL_ID, required = true) |
55 | |
private final String principalId; |
56 | |
|
57 | |
@XmlElement(name = Elements.ANNOTATION, required = false) |
58 | |
private final String annotation; |
59 | |
|
60 | |
@XmlElement(name = Elements.DOCUMENT_UPDATE, required = false) |
61 | |
private final DocumentUpdate documentUpdate; |
62 | |
|
63 | |
@XmlElement(name = Elements.DOCUMENT_CONTENT_UPDATE, required = false) |
64 | |
private final DocumentContentUpdate documentContentUpdate; |
65 | |
|
66 | 0 | @SuppressWarnings("unused") |
67 | |
@XmlAnyElement |
68 | |
private final Collection<Element> _futureElements = null; |
69 | |
|
70 | 0 | private DocumentActionParameters() { |
71 | 0 | this.documentId = null; |
72 | 0 | this.principalId = null; |
73 | 0 | this.annotation = null; |
74 | 0 | this.documentUpdate = null; |
75 | 0 | this.documentContentUpdate = null; |
76 | 0 | } |
77 | |
|
78 | 0 | private DocumentActionParameters(Builder builder) { |
79 | 0 | this.documentId = builder.getDocumentId(); |
80 | 0 | this.principalId = builder.getPrincipalId(); |
81 | 0 | this.annotation = builder.getAnnotation(); |
82 | 0 | this.documentUpdate = builder.getDocumentUpdate(); |
83 | 0 | this.documentContentUpdate = builder.getDocumentContentUpdate(); |
84 | 0 | } |
85 | |
|
86 | |
public static DocumentActionParameters create(String documentId, String principalId) { |
87 | 0 | return create(documentId, principalId, ""); |
88 | |
} |
89 | |
|
90 | |
public static DocumentActionParameters create(String documentId, String principalId, String annotation) { |
91 | 0 | Builder builder = Builder.create(documentId, principalId); |
92 | 0 | builder.setAnnotation(annotation); |
93 | 0 | return builder.build(); |
94 | |
} |
95 | |
|
96 | |
public String getDocumentId() { |
97 | 0 | return documentId; |
98 | |
} |
99 | |
|
100 | |
public String getPrincipalId() { |
101 | 0 | return principalId; |
102 | |
} |
103 | |
|
104 | |
public String getAnnotation() { |
105 | 0 | return annotation; |
106 | |
} |
107 | |
|
108 | |
public DocumentUpdate getDocumentUpdate() { |
109 | 0 | return documentUpdate; |
110 | |
} |
111 | |
|
112 | |
public DocumentContentUpdate getDocumentContentUpdate() { |
113 | 0 | return documentContentUpdate; |
114 | |
} |
115 | |
|
116 | |
|
117 | |
|
118 | |
|
119 | |
|
120 | 0 | public final static class Builder implements Serializable, ModelBuilder { |
121 | |
|
122 | |
private static final long serialVersionUID = -9209748637365086000L; |
123 | |
|
124 | |
private String documentId; |
125 | |
private String principalId; |
126 | |
private String annotation; |
127 | |
private DocumentUpdate documentUpdate; |
128 | |
private DocumentContentUpdate documentContentUpdate; |
129 | |
|
130 | 0 | private Builder(String documentId, String principalId) { |
131 | 0 | setDocumentId(documentId); |
132 | 0 | setPrincipalId(principalId); |
133 | 0 | } |
134 | |
|
135 | |
public static Builder create(String documentId, String principalId) { |
136 | 0 | return new Builder(documentId, principalId); |
137 | |
} |
138 | |
|
139 | |
public DocumentActionParameters build() { |
140 | 0 | return new DocumentActionParameters(this); |
141 | |
} |
142 | |
|
143 | |
public String getDocumentId() { |
144 | 0 | return documentId; |
145 | |
} |
146 | |
|
147 | |
public void setDocumentId(String documentId) { |
148 | 0 | if (StringUtils.isBlank(documentId)) { |
149 | 0 | throw new IllegalArgumentException("documentId was null or blank"); |
150 | |
} |
151 | 0 | this.documentId = documentId; |
152 | 0 | } |
153 | |
|
154 | |
public String getPrincipalId() { |
155 | 0 | return principalId; |
156 | |
} |
157 | |
|
158 | |
public void setPrincipalId(String principalId) { |
159 | 0 | if (StringUtils.isBlank(principalId)) { |
160 | 0 | throw new IllegalArgumentException("principalId was null or blank"); |
161 | |
} |
162 | 0 | this.principalId = principalId; |
163 | 0 | } |
164 | |
|
165 | |
public String getAnnotation() { |
166 | 0 | return annotation; |
167 | |
} |
168 | |
|
169 | |
public void setAnnotation(String annotation) { |
170 | 0 | this.annotation = annotation; |
171 | 0 | } |
172 | |
|
173 | |
public DocumentUpdate getDocumentUpdate() { |
174 | 0 | return documentUpdate; |
175 | |
} |
176 | |
|
177 | |
public void setDocumentUpdate(DocumentUpdate documentUpdate) { |
178 | 0 | this.documentUpdate = documentUpdate; |
179 | 0 | } |
180 | |
|
181 | |
public DocumentContentUpdate getDocumentContentUpdate() { |
182 | 0 | return documentContentUpdate; |
183 | |
} |
184 | |
|
185 | |
public void setDocumentContentUpdate(DocumentContentUpdate documentContentUpdate) { |
186 | 0 | this.documentContentUpdate = documentContentUpdate; |
187 | 0 | } |
188 | |
|
189 | |
} |
190 | |
|
191 | |
|
192 | |
|
193 | |
|
194 | 0 | static class Constants { |
195 | |
final static String ROOT_ELEMENT_NAME = "documentActionParameters"; |
196 | |
final static String TYPE_NAME = "DocumentActionParametersType"; |
197 | |
} |
198 | |
|
199 | |
|
200 | |
|
201 | |
|
202 | 0 | static class Elements { |
203 | |
final static String DOCUMENT_ID = "documentId"; |
204 | |
final static String PRINCIPAL_ID = "principalId"; |
205 | |
final static String ANNOTATION = "annotation"; |
206 | |
final static String DOCUMENT_UPDATE = "documentUpdate"; |
207 | |
final static String DOCUMENT_CONTENT_UPDATE = "documentContentUpdate"; |
208 | |
} |
209 | |
|
210 | |
} |