1 /**
2 * Copyright 2005-2012 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.rice.kew.api.document.search;
17
18 import org.joda.time.DateTime;
19 import org.kuali.rice.kew.api.document.DocumentStatus;
20 import org.kuali.rice.kew.api.document.DocumentStatusCategory;
21
22 import java.util.List;
23 import java.util.Map;
24
25 /**
26 * Defines the contract for criteria used to perform lookups of workflow document data. None of the elements that can
27 * be defined on the criteria are required. Therefore, any method on this class may return a null value, though in the
28 * case of collections, an empty collection will be returned instead.
29 *
30 * <p>In general, the different values on the criteria allow the standard lookup "operators" as defined by
31 * {@link org.kuali.rice.core.api.search.SearchOperator} unless otherwise noted. The primary place where this differs
32 * is on principal name-based criteria (see below).</p>
33 *
34 * <p><On criteria which contains a principal name, the rules are as follows:</p>
35 *
36 * <ul>
37 * <li>only literal principal names that resolve to a valid principal are allowed</li>
38 * <li>however, if the principal names don't resolve to valid prinicpals, this simply means the lookup will return no results</li>
39 * <li>"!" is allowed before a principal name</li>
40 * <li>when wanting to search for more than one principal, "|" and "&&" is allowed though they cannot be used together</li>
41 * </ul>
42 *
43 * <p>Wildcards, ranges, and other "inequality" operators (such as ">", "<", etc.) are not permitted on principal names.</p>
44 *
45 * <p>In cases where a criteria element takes a list of values, this should be treated as an implicit "OR" by the lookup
46 * implementation. This is true of document attribute values as well, which are passed as a map keyed off the
47 * document attribute name with a list of values representing the document attribute values to be searched for.</p>
48 *
49 * <p>The optional "save name" on the search defines a name under which the criteria can be stored so that it can be
50 * recalled and reused later.</p>
51 *
52 * @author Kuali Rice Team (rice.collab@kuali.org)
53 */
54 public interface DocumentSearchCriteriaContract {
55
56 /**
57 * Returns the document id criteria to search against when executing the document search.
58 *
59 * @return the document id criteria
60 */
61 String getDocumentId();
62
63 /**
64 * Returns an unmodifiable list of document statuses to search against when executing the document search. If there
65 * is more than one of these, then the search should treat this as an "OR" case (i.e. search for documents with one
66 * or more of these statuses).
67 *
68 * @return the document status criteria
69 */
70 List<DocumentStatus> getDocumentStatuses();
71
72 /**
73 * Returns an unmodifiable list of document status categories to search against when executing the document search.
74 * If there is more than one of these, then the search should treat this as an "OR" case (i.e. search for documents
75 * that have a status contained in one or more of these categories).
76 *
77 * @return the document status category criteria
78 */
79 List<DocumentStatusCategory> getDocumentStatusCategories();
80
81 /**
82 * Returns the document title criteria to search against when executing the document search.
83 *
84 * @return the title criteria
85 */
86 String getTitle();
87
88 /**
89 * Returns the application document id criteria to search against when executing the document search.
90 *
91 * @return the application document id criteria
92 */
93 String getApplicationDocumentId();
94
95 /**
96 * Returns the application document status criteria to search against when executing the document search.
97 *
98 * @return the application document status criteria
99 */
100 String getApplicationDocumentStatus();
101
102 /**
103 * Returns the criteria for the principal name of the document initiator to search against when executing the
104 * document search. Follows the rules for principal name criteria (see class-level documentation).
105 *
106 * @return the initiator principal name criteria
107 */
108 String getInitiatorPrincipalName();
109
110 /**
111 * Returns the criteria for the principal name of a "viewer" of a document (someone who received an action request
112 * related to the document) to search against when executing the document search. Follows the rules for principal
113 * name criteria (see class-level documentation).
114 *
115 * @return the viewer principal name criteria
116 */
117 String getViewerPrincipalName();
118
119 /**
120 * Returns the criteria for the id of a group who is a "viewer" of a document (a group who received an action request
121 * related to the document) to search against when executing the document search. Group id criteria follows rules
122 * similar to principal name criteria:
123 *
124 * <ul>
125 * <li>only literal group ids that resolve to a valid group are allowed</li>
126 * <li>however, if the group ids don't resolve to valid groups, this simply means the search will return no results</li>
127 * <li>"!" is allowed before a group id</li>
128 * <li>when wanting to search on more than one viewer group id, use of "|" and "&&" is allowed, though they cannot be used together</li>
129 * </ul>
130 *
131 * @return the viewer principal name criteria
132 */
133 String getGroupViewerId();
134
135 /**
136 * Returns the criteria for the name of a group who is a "viewer" of a document (a group who received an action request
137 * related to the document) to search against when executing the document search. Group name criteria follows rules
138 * similar to principal name criteria:
139 *
140 * <ul>
141 * <li>only literal group names that resolve to a valid group are allowed</li>
142 * <li>however, if the group names don't resolve to valid groups, this simply means the search will return no results</li>
143 * <li>"!" is allowed before a group id</li>
144 * <li>when wanting to search on more than one viewer group name, use of "|" and "&&" is allowed, though they cannot be used together</li>
145 * </ul>
146 *
147 * @return the viewer principal name criteria
148 */
149 String getGroupViewerName();
150
151 /**
152 * Returns the criteria for the principal name of an "approver" of a document (someone who took action against
153 * the document) to search against when executing the document search. Follows the rules for principal name
154 * criteria (see class-level documentation).
155 *
156 * @return the viewer principal name criteria
157 */
158 String getApproverPrincipalName();
159
160 /**
161 * Returns the route node name criteria to search against when executing the document search. By default this will
162 * match only documents which are at the node with the given name, unless {@link #getRouteNodeLookupLogic()} returns
163 * a non-null value that specifies different criteria for how the route node-based lookup should be performed.
164 *
165 * @return the route node name criteria
166 */
167 String getRouteNodeName();
168
169 /**
170 * Returns the logic that should be used when performing a document search against the route name. This essentially
171 * allows for the criteria to specify whether or not it should look at documents which are currently before, exactly
172 * at, or after the specified route node. This value only has an effect if the route node name is also defined
173 * on this criteria.
174 *
175 * @return the route node lookup logic to use in conjunction with the route node name criteria
176 */
177 RouteNodeLookupLogic getRouteNodeLookupLogic();
178
179 /**
180 * Returns the document type name criteria to search against when executing the document search. If the document
181 * type name matches a single document type exactly, this might trigger document search customizations which are
182 * tied to that document type (assuming the document type has such customizations configured).
183 *
184 * <p>In order for the map of document attribute values to be properly searchable, this document type name should
185 * result to a valid document type. This is because the document type itself defines information about custom
186 * document attributes and the parameters around how searches against those attributes can be executed.</p>
187 *
188 * <p>Note that searches against a document type name should be document type hierarchy-aware. Meaning that the
189 * search should also return results for any documents that have document types that are children of the specified
190 * document type name (assuming that the specified document type name is valid and not wildcarded at all).</p>
191 *
192 * @return the document type name criteria
193 */
194 String getDocumentTypeName();
195
196 /**
197 * Returns an optional list of additional document type name criteria against which to search. The search should
198 * effectively return all documents that have a document type name within the set of the main document type name on
199 * the criteria as well as any additional document type names.
200 *
201 * <p>As with {@link #getDocumentTypeName()}, the additional document type name criteria is document type hierarchy
202 * aware.</p>
203 *
204 * @return the list of additional document type names to use on the search criteria
205 */
206 List<String> getAdditionalDocumentTypeNames();
207
208 /**
209 * Returns the inclusive lower end of the date created criteria to search against when executing the document search.
210 *
211 * @return the date created "from" criteria
212 */
213 DateTime getDateCreatedFrom();
214
215 /**
216 * Returns the inclusive upper end of the date created criteria to search against when executing the document search.
217 *
218 * @return the date created "to" criteria
219 */
220 DateTime getDateCreatedTo();
221
222 /**
223 * Returns the inclusive lower end of the date last modified criteria to search against when executing the document search.
224 *
225 * @return the date last modified "from" criteria
226 */
227 DateTime getDateLastModifiedFrom();
228
229 /**
230 * Returns the inclusive upper end of the date last modified criteria to search against when executing the document search.
231 *
232 * @return the date last modified "to" criteria
233 */
234 DateTime getDateLastModifiedTo();
235
236 /**
237 * Returns the inclusive lower end of the date approved criteria to search against when executing the document search.
238 *
239 * @return the date approved "from" criteria
240 */
241 DateTime getDateApprovedFrom();
242
243 /**
244 * Returns the inclusive upper end of the date approved criteria to search against when executing the document search.
245 *
246 * @return the date approved "tp" criteria
247 */
248 DateTime getDateApprovedTo();
249
250 /**
251 * Returns the inclusive lower end of the date finalized criteria to search against when executing the document search.
252 *
253 * @return the date finalized "from" criteria
254 */
255 DateTime getDateFinalizedFrom();
256
257 /**
258 * Returns the inclusive upper end of the date finalized criteria to search against when executing the document search.
259 *
260 * @return the date finalized "to" criteria
261 */
262 DateTime getDateFinalizedTo();
263
264 /**
265 * Returns the inclusive lower end of the date of application document status change criteria to search against when executing the document search.
266 *
267 * @return the date application document status changed "from" criteria
268 */
269 DateTime getDateApplicationDocumentStatusChangedFrom();
270
271 /**
272 * Returns the inclusive upper end of the date of application document status change criteria to search against when executing the document search.
273 *
274 * @return the date application document status changed "to" criteria
275 */
276 DateTime getDateApplicationDocumentStatusChangedTo();
277
278 /**
279 * Returns a map of document attribute values to search against when executing the document search. The key of the
280 * map is the name of the document attribute, while the list of values contains values of those attributes to search
281 * against. These individual attribute values support the different search operations where appropriate. The
282 * resulting List of criteria values however should ultimately be "or"-ed together when executing the document
283 * search.
284 *
285 * <p>In order for the document attribute values to be processed as part of the criteria during the search, the
286 * {@link #getDocumentTypeName()} must return a valid name of a document type which is configured to understand the
287 * attributes passed as part of the document attribute values map.</p>
288 * @return
289 */
290 Map<String, List<String>> getDocumentAttributeValues();
291
292 /**
293 * Return the name under which to save this criteria so that it can be recalled and used again in the future. If no
294 * save name is specified, then this criteria will not be saved for future use.
295 * @return
296 */
297 String getSaveName();
298
299 /**
300 * Returns the 0-based index in the result set at which to start returning results from a document search which is
301 * performed using this criteria. If not specified, results from the search should be returned starting at the
302 * beginning of the result set. If this index is larger then the total number of results returned by the actual
303 * search, then no values should be returned.
304 *
305 * @return the index in the result set at which to begin returning results
306 */
307 Integer getStartAtIndex();
308
309 /**
310 * Returns the requested maximum number of documents that should be returned from a document search performed using this
311 * criteria. If not specified, it is up to the document search implementation to decide how many results to return.
312 * It is likely in such cases that the implementation will use a default result cap in order to prevent too many
313 * documents from being returned.
314 *
315 * <p>It is important to note that this value is meant simply as a request to the document search for the number of
316 * results to return. The implementation may return fewer results then requested if it decides to impose it's own
317 * internal cap on results.</p>
318 *
319 * @return the requested number of maximum document results that should be returned from the search
320 */
321 Integer getMaxResults();
322
323 /**
324 * Returns a string that indicates if a query was run in advanced mode.
325 *
326 * @return whether or not the search was run in advanced mode
327 */
328 String getIsAdvancedSearch();
329 }