View Javadoc
1   /**
2    * Copyright 2005-2014 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.docsearch.service;
17  
18  import org.kuali.rice.core.api.util.KeyValue;
19  import org.kuali.rice.kew.api.document.search.DocumentSearchCriteria;
20  import org.kuali.rice.kew.api.document.search.DocumentSearchResults;
21  import org.kuali.rice.kew.impl.document.search.DocumentSearchGenerator;
22  import org.kuali.rice.kew.doctype.bo.DocumentType;
23  
24  import java.util.List;
25  
26  
27  /**
28   * Service for data access for document searches.
29   *
30   * @author Kuali Rice Team (rice.collab@kuali.org)
31   */
32  public interface DocumentSearchService {
33  
34      /**
35       * This method performs a standard document search for the given criteria.
36       *
37       * @param principalId the id of the principal who is executing the search, this may be null to indicate the
38       * search could be executed by an arbitrary user
39       * @param criteria criteria to use to search documents
40       * @return the results of the search, will never return null
41       */
42      DocumentSearchResults lookupDocuments(String principalId, DocumentSearchCriteria criteria);
43  
44      /**
45       * Returns a saved search criteria, either explicitly named by the user, or saved automatically as a recent search
46       * @param principalId the user principal id
47       * @param key the user option key under which the criteria is saved
48       * @return the DocumentSearchCriteria or null if not found
49       */
50      DocumentSearchCriteria getSavedSearchCriteria(String principalId, String key);
51  
52      /**
53       * Returns an explicitly named saved search criteria
54       * @param principalId the user principal id
55       * @param savedSearchName the user-provided saved search name
56       * @return the DocumentSearchCriteria or null if not found
57       */
58      DocumentSearchCriteria getNamedSearchCriteria(String principalId, String savedSearchName);
59  
60      /**
61       * Clears all saved searches for the specified user (named and automatic)
62       * @param principalId user principal id
63       */
64      void clearNamedSearches(String principalId);
65  
66      /**
67       * Returns named saved searches for the specified user
68       * @param principalId the user principal id
69       * @return list of search key/label
70       */
71      List<KeyValue> getNamedSearches(String principalId);
72  
73      /**
74       * Returns automatically saved recent searches for the specified user
75       * @param principalId the user principal id
76       * @return list of search key/label
77       */
78      List<KeyValue> getMostRecentSearches(String principalId);
79  
80      DocumentSearchCriteria clearCriteria(DocumentType documentType, DocumentSearchCriteria criteria);
81  
82      DocumentSearchGenerator getStandardDocumentSearchGenerator();
83  
84      void validateDocumentSearchCriteria(DocumentSearchGenerator docSearchGenerator, DocumentSearchCriteria.Builder criteria);
85  
86      /**
87       * Returns the maximum number of results that should be returned from the document search.
88       *
89       * @param criteria the criteria in which to check for a max results value
90       * @return the maximum number of results that should be returned from a document search
91       */
92      public int getMaxResultCap(DocumentSearchCriteria criteria);
93  
94      /**
95       * Returns the number of results that should be returned from an additional fetch against
96       * the document search.
97       *
98       * Default: {@link org.kuali.rice.kew.docsearch.dao.impl.DocumentSearchDAOJdbcImpl.DEFAULT_FETCH_MORE_ITERATION_LIMIT}
99       * Override: {@link org.kuali.rice.kew.api.KewApiConstants#DOC_SEARCH_FETCH_MORE_ITERATION_LIMIT}
100      * @return int
101      */
102     public int getFetchMoreIterationLimit();
103 }