KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > service > cmr > search > SearchService


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.service.cmr.search;
18
19 import java.io.Serializable JavaDoc;
20 import java.util.List JavaDoc;
21
22 import org.alfresco.service.cmr.repository.InvalidNodeRefException;
23 import org.alfresco.service.cmr.repository.NodeRef;
24 import org.alfresco.service.cmr.repository.Path;
25 import org.alfresco.service.cmr.repository.StoreRef;
26 import org.alfresco.service.cmr.repository.XPathException;
27 import org.alfresco.service.namespace.NamespacePrefixResolver;
28 import org.alfresco.service.namespace.QName;
29
30 /**
31  * This encapsulates the execution of search against different indexing
32  * mechanisms.
33  *
34  * Canned queries have been translated into the query string by this stage.
35  * Handling of parameterisation is left to the implementation.
36  *
37  * @author Andy hind
38  *
39  */

40 public interface SearchService
41 {
42     public static final String JavaDoc LANGUAGE_LUCENE = "lucene";
43
44     public static final String JavaDoc LANGUAGE_XPATH = "xpath";
45
46     public static final String JavaDoc LANGUAGE_JCR_XPATH = "jcr-xpath";
47
48     /**
49      * Search against a store.
50      *
51      * @param store -
52      * the store against which to search
53      * @param language -
54      * the query language
55      * @param query -
56      * the query string - which may include parameters
57      * @param attributePaths -
58      * explicit list of attributes/properties to extract for the
59      * selected nodes in xpath style syntax
60      * @param queryParameterDefinition -
61      * query parameter definitions - the default value is used for
62      * the value.
63      * @return Returns the query results
64      */

65     public ResultSet query(StoreRef store, String JavaDoc language, String JavaDoc query, Path[] attributePaths,
66             QueryParameterDefinition[] queryParameterDefinitions);
67
68     /**
69      * Search against a store. Pulls back all attributes on each node. Does not
70      * allow parameterisation.
71      *
72      * @param store -
73      * the store against which to search
74      * @param language -
75      * the query language
76      * @param query -
77      * the query string - which may include parameters
78      * @return Returns the query results
79      */

80     public ResultSet query(StoreRef store, String JavaDoc language, String JavaDoc query);
81
82     /**
83      * Search against a store.
84      *
85      * @param store -
86      * the store against which to search
87      * @param language -
88      * the query language
89      * @param query -
90      * the query string - which may include parameters
91      * @param queryParameterDefinition -
92      * query parameter definitions - the default value is used for
93      * the value.
94      * @return Returns the query results
95      */

96     public ResultSet query(StoreRef store, String JavaDoc language, String JavaDoc query,
97             QueryParameterDefinition[] queryParameterDefintions);
98
99     /**
100      * Search against a store.
101      *
102      * @param store -
103      * the store against which to search
104      * @param language -
105      * the query language
106      * @param query -
107      * the query string - which may include parameters
108      * @param attributePaths -
109      * explicit list of attributes/properties to extract for the
110      * selected nodes in xpath style syntax
111      * @return Returns the query results
112      */

113     public ResultSet query(StoreRef store, String JavaDoc language, String JavaDoc query, Path[] attributePaths);
114
115     /**
116      * Execute a canned query
117      *
118      * @param store -
119      * the store against which to search
120      * @param queryId -
121      * the query identifier
122      * @param queryParameters -
123      * parameterisation for the canned query
124      * @return Returns the query results
125      */

126     public ResultSet query(StoreRef store, QName queryId, QueryParameter[] queryParameters);
127
128     /**
129      * Search using the given SearchParameters
130      */

131
132     public ResultSet query(SearchParameters searchParameters);
133
134     /**
135      * Select nodes using an xpath expression.
136      *
137      * @param contextNodeRef -
138      * the context node for relative expressions etc
139      * @param xpath -
140      * the xpath string to evaluate
141      * @param parameters -
142      * parameters to bind in to the xpath expression
143      * @param namespacePrefixResolver -
144      * prefix to namespace mappings
145      * @param followAllParentLinks -
146      * if false ".." follows only the primary parent links, if true
147      * it follows all
148      * @return a list of all the child assoc relationships to the selected nodes
149      */

150     public List JavaDoc<NodeRef> selectNodes(NodeRef contextNodeRef, String JavaDoc xpath, QueryParameterDefinition[] parameters,
151             NamespacePrefixResolver namespacePrefixResolver, boolean followAllParentLinks)
152             throws InvalidNodeRefException, XPathException;
153
154     /**
155      * Select nodes using an xpath expression.
156      *
157      * @param contextNodeRef -
158      * the context node for relative expressions etc
159      * @param xpath -
160      * the xpath string to evaluate
161      * @param parameters -
162      * parameters to bind in to the xpath expression
163      * @param namespacePrefixResolver -
164      * prefix to namespace mappings
165      * @param followAllParentLinks -
166      * if false ".." follows only the primary parent links, if true
167      * it follows all
168      * @param langauage -
169      * the xpath variant
170      * @return a list of all the child assoc relationships to the selected nodes
171      */

172     public List JavaDoc<NodeRef> selectNodes(NodeRef contextNodeRef, String JavaDoc xpath, QueryParameterDefinition[] parameters,
173             NamespacePrefixResolver namespacePrefixResolver, boolean followAllParentLinks, String JavaDoc language)
174             throws InvalidNodeRefException, XPathException;
175
176     /**
177      * Select properties using an xpath expression
178      *
179      * @param contextNodeRef -
180      * the context node for relative expressions etc
181      * @param xpath -
182      * the xpath string to evaluate
183      * @param parameters -
184      * parameters to bind in to the xpath expression
185      * @param namespacePrefixResolver -
186      * prefix to namespace mappings
187      * @param followAllParentLinks -
188      * if false ".." follows only the primary parent links, if true
189      * it follows all
190      * @return a list of property values
191      */

192     public List JavaDoc<Serializable JavaDoc> selectProperties(NodeRef contextNodeRef, String JavaDoc xpath,
193             QueryParameterDefinition[] parameters, NamespacePrefixResolver namespacePrefixResolver,
194             boolean followAllParentLinks) throws InvalidNodeRefException, XPathException;
195
196     /**
197      * Select properties using an xpath expression
198      *
199      * @param contextNodeRef -
200      * the context node for relative expressions etc
201      * @param xpath -
202      * the xpath string to evaluate
203      * @param parameters -
204      * parameters to bind in to the xpath expression
205      * @param namespacePrefixResolver -
206      * prefix to namespace mappings
207      * @param followAllParentLinks -
208      * if false ".." follows only the primary parent links, if true
209      * it follows all
210      * @param langauage -
211      * the xpath variant
212      * @return a list of property values
213      */

214     public List JavaDoc<Serializable JavaDoc> selectProperties(NodeRef contextNodeRef, String JavaDoc xpath,
215             QueryParameterDefinition[] parameters, NamespacePrefixResolver namespacePrefixResolver,
216             boolean followAllParentLinks, String JavaDoc language) throws InvalidNodeRefException, XPathException;
217
218     /**
219      * Search for string pattern in both the node text (if present) and node
220      * properties
221      *
222      * @param nodeRef
223      * the node to get
224      * @param propertyQName
225      * the name of the property
226      * @param googleLikePattern
227      * a Google-like pattern to search for in the property value
228      * @return Returns true if the pattern could be found - uses the default OR operator
229      */

230     public boolean contains(NodeRef nodeRef, QName propertyQName, String JavaDoc googleLikePattern)
231             throws InvalidNodeRefException;
232     
233     /**
234      * Search for string pattern in both the node text (if present) and node
235      * properties
236      *
237      * @param nodeRef
238      * the node to get
239      * @param propertyQName
240      * the name of the property
241      * @param googleLikePattern
242      * a Google-like pattern to search for in the property value
243      * @return Returns true if the pattern could be found
244      */

245     public boolean contains(NodeRef nodeRef, QName propertyQName, String JavaDoc googleLikePattern, SearchParameters.Operator defaultOperator)
246             throws InvalidNodeRefException;
247
248     /**
249      * Search for string pattern in both the node text (if present) and node
250      * properties
251      *
252      * @param nodeRef
253      * the node to get
254      * @param propertyQName
255      * the name of the property (mandatory)
256      * @param sqlLikePattern
257      * a SQL-like pattern to search for
258      * @param includeFTS -
259      * include full text search matches in the like test
260      * @return Returns true if the pattern could be found
261      */

262     public boolean like(NodeRef nodeRef, QName propertyQName, String JavaDoc sqlLikePattern, boolean includeFTS)
263             throws InvalidNodeRefException;
264 }
265
Popular Tags