mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Moving to root below branch label
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2005 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
145
source/java/org/alfresco/service/cmr/search/CategoryService.java
Normal file
145
source/java/org/alfresco/service/cmr/search/CategoryService.java
Normal file
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
package org.alfresco.service.cmr.search;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Category Service
|
||||
*
|
||||
* The service for querying and creating categories.
|
||||
* All other management can be carried out using the node service.
|
||||
*
|
||||
* Classification - the groupings of categories. There is a one-to-one mapping with aspects. For example, Region.
|
||||
* Root Category - the top level categories in a classification. For example, Northern Europe
|
||||
* Category - any other category below a root category
|
||||
*
|
||||
* @author Andy Hind
|
||||
*
|
||||
*/
|
||||
public interface CategoryService
|
||||
{
|
||||
/**
|
||||
* Enumeration for navigation control.
|
||||
*
|
||||
* MEMBERS - get only category members (the things that have been classified in a category, not the sub categories)
|
||||
* SUB_CATEGORIES - get sub categories only, not the things that hyave been classified.
|
||||
* ALL - get both of the above
|
||||
*/
|
||||
public enum Mode {MEMBERS, SUB_CATEGORIES, ALL};
|
||||
|
||||
/**
|
||||
* Depth from which to get nodes.
|
||||
*
|
||||
* IMMEDIATE - only immediate sub categories or members
|
||||
* ANY - find subcategories or members at any level
|
||||
*/
|
||||
public enum Depth {IMMEDIATE, ANY};
|
||||
|
||||
/**
|
||||
* Get the children of a given category node
|
||||
*
|
||||
* @param categoryRef - the category node
|
||||
* @param mode - the enumeration mode for what to recover
|
||||
* @param depth - the enumeration depth for what level to recover
|
||||
* @return a collection of all the nodes found identified by their ChildAssocRef's
|
||||
*/
|
||||
public Collection<ChildAssociationRef> getChildren(NodeRef categoryRef, Mode mode, Depth depth );
|
||||
|
||||
/**
|
||||
* Get a list of all the categories appropriate for a given property.
|
||||
* The full list of categories that may be assigned for this aspect.
|
||||
*
|
||||
* @param aspectQName
|
||||
* @param depth - the enumeration depth for what level to recover
|
||||
* @return a collection of all the nodes found identified by their ChildAssocRef's
|
||||
*/
|
||||
public Collection<ChildAssociationRef> getCategories(StoreRef storeRef, QName aspectQName, Depth depth );
|
||||
|
||||
/**
|
||||
* Get all the classification entries
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Collection<ChildAssociationRef> getClassifications(StoreRef storeRef);
|
||||
|
||||
/**
|
||||
* Get the root categories for an aspect/classification
|
||||
*
|
||||
* @param storeRef
|
||||
* @param aspectName
|
||||
* @return
|
||||
*/
|
||||
public Collection<ChildAssociationRef> getRootCategories(StoreRef storeRef, QName aspectName);
|
||||
|
||||
/**
|
||||
* Get all the types that represent categories
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Collection<QName> getClassificationAspects();
|
||||
|
||||
/**
|
||||
* Create a new category.
|
||||
*
|
||||
* This will extend the category types in the data dictionary
|
||||
* All it needs is the type name and the attribute in which to store noderefs to categories.
|
||||
*
|
||||
* @param aspectName
|
||||
* @param attributeName
|
||||
*/
|
||||
public NodeRef createClassifiction(StoreRef storeRef, QName aspectName, String attributeName);
|
||||
|
||||
/**
|
||||
* Create a new root category in the given classification
|
||||
*
|
||||
* @param storeRef
|
||||
* @param aspectName
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public NodeRef createRootCategory(StoreRef storeRef, QName aspectName, String name);
|
||||
|
||||
/**
|
||||
* Create a new category.
|
||||
*
|
||||
* @param parent
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public NodeRef createCategory(NodeRef parent, String name);
|
||||
|
||||
/**
|
||||
* Delete a classification
|
||||
*
|
||||
* @param storeRef
|
||||
* @param aspectName
|
||||
*/
|
||||
public void deleteClassification(StoreRef storeRef, QName aspectName);
|
||||
|
||||
/**
|
||||
* Delete a category
|
||||
*
|
||||
* @param nodeRef
|
||||
*/
|
||||
public void deleteCategory(NodeRef nodeRef);
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
package org.alfresco.service.cmr.search;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
public interface NamedQueryParameterDefinition
|
||||
{
|
||||
|
||||
/**
|
||||
* Get the name of this parameter. It could be used as the well known name for the parameter.
|
||||
*
|
||||
* Not null
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public QName getQName();
|
||||
|
||||
/**
|
||||
* Get the query parameter definition
|
||||
* @return
|
||||
*/
|
||||
public QueryParameterDefinition getQueryParameterDefinition();
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
package org.alfresco.service.cmr.search;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Encapsulates a query parameter
|
||||
*
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public class QueryParameter
|
||||
{
|
||||
private QName qName;
|
||||
|
||||
private Serializable value;
|
||||
|
||||
public QueryParameter(QName qName, Serializable value)
|
||||
{
|
||||
this.qName = qName;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public QName getQName()
|
||||
{
|
||||
return qName;
|
||||
}
|
||||
|
||||
|
||||
public Serializable getValue()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
package org.alfresco.service.cmr.search;
|
||||
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
|
||||
public interface QueryParameterDefinition extends NamedQueryParameterDefinition
|
||||
{
|
||||
/**
|
||||
* This parameter may apply to a well known property type.
|
||||
*
|
||||
* May be null
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public PropertyDefinition getPropertyDefinition();
|
||||
|
||||
/**
|
||||
* Get the property type definition for this parameter.
|
||||
* It could come from the property type definition if there is one
|
||||
*
|
||||
* Not null
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public DataTypeDefinition getDataTypeDefinition();
|
||||
|
||||
/**
|
||||
* Get the default value for this parameter.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getDefault();
|
||||
|
||||
/**
|
||||
* Has this parameter got a default value?
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean hasDefaultValue();
|
||||
}
|
78
source/java/org/alfresco/service/cmr/search/ResultSet.java
Normal file
78
source/java/org/alfresco/service/cmr/search/ResultSet.java
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
package org.alfresco.service.cmr.search;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.Path;
|
||||
|
||||
/**
|
||||
* An iterable result set from a searcher query. TODO: Expose meta data and XML
|
||||
*
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public interface ResultSet extends Iterable<ResultSetRow> // Specfic iterator
|
||||
// over
|
||||
// ResultSetRows
|
||||
{
|
||||
/**
|
||||
* Get the relative paths to all the elements contained in this result set
|
||||
*/
|
||||
Path[] getPropertyPaths();
|
||||
|
||||
/**
|
||||
* Get the size of the result set
|
||||
*/
|
||||
int length();
|
||||
|
||||
/**
|
||||
* Get the id of the node at the given index
|
||||
*/
|
||||
NodeRef getNodeRef(int n);
|
||||
|
||||
/**
|
||||
* Get the score for the node at the given position
|
||||
*/
|
||||
float getScore(int n);
|
||||
|
||||
/**
|
||||
* Generate the XML form of this result set
|
||||
*/
|
||||
// Dom getXML(int page, int pageSize, boolean includeMetaData);
|
||||
/**
|
||||
* Generate as XML for Reading
|
||||
*/
|
||||
// Stream getStream(int page, int pageSize, boolean includeMetaData);
|
||||
/**
|
||||
* toString() as above but for the whole set
|
||||
*/
|
||||
// String toString();
|
||||
// ResultSetMetaData getMetaData();
|
||||
|
||||
void close();
|
||||
|
||||
ResultSetRow getRow(int i);
|
||||
|
||||
List<NodeRef> getNodeRefs();
|
||||
|
||||
List<ChildAssociationRef> getChildAssocRefs();
|
||||
|
||||
ChildAssociationRef getChildAssocRef(int n);
|
||||
}
|
101
source/java/org/alfresco/service/cmr/search/ResultSetRow.java
Normal file
101
source/java/org/alfresco/service/cmr/search/ResultSetRow.java
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
package org.alfresco.service.cmr.search;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.Path;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* A row in a result set
|
||||
*
|
||||
* TODO: Support for other non attribute features such as parents and path
|
||||
*
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public interface ResultSetRow
|
||||
{
|
||||
/**
|
||||
* Get the values of all available node properties
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<Path, Serializable> getValues();
|
||||
|
||||
/**
|
||||
* Get a node property by path
|
||||
*
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
public Serializable getValue(Path path);
|
||||
|
||||
/**
|
||||
* Get a node value by name
|
||||
*
|
||||
* @param qname
|
||||
* @return
|
||||
*/
|
||||
public Serializable getValue(QName qname);
|
||||
|
||||
/**
|
||||
* The refernce to the node that equates to this row in the result set
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public NodeRef getNodeRef();
|
||||
|
||||
/**
|
||||
* Get the score for this row in the result set
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public float getScore(); // Score is score + rank + potentially other
|
||||
// stuff
|
||||
|
||||
/**
|
||||
* Get the containing result set
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ResultSet getResultSet();
|
||||
|
||||
/**
|
||||
* Return the QName of the node in the context in which it was found.
|
||||
* @return
|
||||
*/
|
||||
|
||||
public QName getQName();
|
||||
|
||||
/**
|
||||
* Get the position of this row in the containing set.
|
||||
* @return
|
||||
*/
|
||||
public int getIndex();
|
||||
|
||||
/**
|
||||
* Return the child assoc ref for this row
|
||||
* @return
|
||||
*/
|
||||
public ChildAssociationRef getChildAssocRef();
|
||||
|
||||
}
|
@@ -0,0 +1,194 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
package org.alfresco.service.cmr.search;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.alfresco.service.cmr.repository.Path;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
|
||||
/**
|
||||
* This class provides parameters to define a search.
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
public class SearchParameters extends SearchStatement
|
||||
{
|
||||
public static final SortDefinition SORT_IN_DOCUMENT_ORDER_ASCENDING = new SortDefinition(SortDefinition.SortType.DOCUMENT, null, true);
|
||||
public static final SortDefinition SORT_IN_DOCUMENT_ORDER_DESCENDING = new SortDefinition(SortDefinition.SortType.DOCUMENT, null, false);
|
||||
public static final SortDefinition SORT_IN_SCORE_ORDER_ASCENDING = new SortDefinition(SortDefinition.SortType.SCORE, null, false);
|
||||
public static final SortDefinition SORT_IN_SCORE_ORDER_DESCENDING = new SortDefinition(SortDefinition.SortType.SCORE, null, true);
|
||||
|
||||
public enum Operator
|
||||
{
|
||||
OR, AND
|
||||
}
|
||||
|
||||
public static final Operator OR = Operator.OR;
|
||||
public static final Operator AND = Operator.AND;
|
||||
|
||||
private ArrayList<StoreRef> stores = new ArrayList<StoreRef>(1);
|
||||
private ArrayList<Path> attributePaths = new ArrayList<Path>(1);
|
||||
private ArrayList<QueryParameterDefinition> queryParameterDefinitions = new ArrayList<QueryParameterDefinition>(1);
|
||||
private boolean excludeDataInTheCurrentTransaction = false;
|
||||
private ArrayList<SortDefinition> sortDefinitions = new ArrayList<SortDefinition>(1);
|
||||
private Operator defaultOperator = Operator.OR;
|
||||
|
||||
public SearchParameters()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the stores to be supported - currently there can be only one
|
||||
*
|
||||
* @param store
|
||||
*/
|
||||
public void addStore(StoreRef store)
|
||||
{
|
||||
if(stores.size() != 0)
|
||||
{
|
||||
throw new IllegalStateException("At the moment, there can only be one store set for the search");
|
||||
}
|
||||
stores.add(store);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add paths for attributes in the result set
|
||||
*
|
||||
* @param attributePath
|
||||
*/
|
||||
public void addAttrbutePath(Path attributePath)
|
||||
{
|
||||
attributePaths.add(attributePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add parameter definitions for the query - used to parameterise the query string
|
||||
*
|
||||
* @param queryParameterDefinition
|
||||
*/
|
||||
public void addQueryParameterDefinition(QueryParameterDefinition queryParameterDefinition)
|
||||
{
|
||||
queryParameterDefinitions.add(queryParameterDefinition);
|
||||
}
|
||||
|
||||
/**
|
||||
* If true, any data in the current transaction will be ignored in the search.
|
||||
* You will not see anything you have added in the current transaction.
|
||||
*
|
||||
* @param excludeDataInTheCurrentTransaction
|
||||
*/
|
||||
public void excludeDataInTheCurrentTransaction(boolean excludeDataInTheCurrentTransaction)
|
||||
{
|
||||
this.excludeDataInTheCurrentTransaction = excludeDataInTheCurrentTransaction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a sort to the query (for those query languages that do not support it directly)
|
||||
*
|
||||
* @param field - this is intially a direct attribute on a node not an attribute on the parent etc
|
||||
* TODO: It could be a relative path at some time.
|
||||
*
|
||||
*
|
||||
* @param ascending
|
||||
*/
|
||||
public void addSort(String field, boolean ascending)
|
||||
{
|
||||
addSort(new SortDefinition(SortDefinition.SortType.FIELD, field, ascending));
|
||||
}
|
||||
|
||||
public void addSort(SortDefinition sortDefinition)
|
||||
{
|
||||
sortDefinitions.add(sortDefinition);
|
||||
}
|
||||
|
||||
/**
|
||||
* A helper class for sort definition
|
||||
* @author andyh
|
||||
*
|
||||
* TODO To change the template for this generated type comment go to
|
||||
* Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public static class SortDefinition
|
||||
{
|
||||
|
||||
public enum SortType {FIELD, DOCUMENT, SCORE};
|
||||
|
||||
SortType sortType;
|
||||
String field;
|
||||
boolean ascending;
|
||||
|
||||
SortDefinition(SortType sortType, String field, boolean ascending)
|
||||
{
|
||||
this.sortType = sortType;
|
||||
this.field = field;
|
||||
this.ascending = ascending;
|
||||
}
|
||||
|
||||
public boolean isAscending()
|
||||
{
|
||||
return ascending;
|
||||
}
|
||||
|
||||
public String getField()
|
||||
{
|
||||
return field;
|
||||
}
|
||||
|
||||
public SortType getSortType()
|
||||
{
|
||||
return sortType;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<Path> getAttributePaths()
|
||||
{
|
||||
return attributePaths;
|
||||
}
|
||||
|
||||
public boolean excludeDataInTheCurrentTransaction()
|
||||
{
|
||||
return excludeDataInTheCurrentTransaction;
|
||||
}
|
||||
|
||||
public ArrayList<QueryParameterDefinition> getQueryParameterDefinitions()
|
||||
{
|
||||
return queryParameterDefinitions;
|
||||
}
|
||||
|
||||
public ArrayList<SortDefinition> getSortDefinitions()
|
||||
{
|
||||
return sortDefinitions;
|
||||
}
|
||||
|
||||
public ArrayList<StoreRef> getStores()
|
||||
{
|
||||
return stores;
|
||||
}
|
||||
|
||||
public void setDefaultOperator(Operator defaultOperator)
|
||||
{
|
||||
this.defaultOperator = defaultOperator;
|
||||
}
|
||||
|
||||
public Operator getDefaultOperator()
|
||||
{
|
||||
return defaultOperator;
|
||||
}
|
||||
}
|
264
source/java/org/alfresco/service/cmr/search/SearchService.java
Normal file
264
source/java/org/alfresco/service/cmr/search/SearchService.java
Normal file
@@ -0,0 +1,264 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
package org.alfresco.service.cmr.search;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.Path;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.repository.XPathException;
|
||||
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* This encapsulates the execution of search against different indexing
|
||||
* mechanisms.
|
||||
*
|
||||
* Canned queries have been translated into the query string by this stage.
|
||||
* Handling of parameterisation is left to the implementation.
|
||||
*
|
||||
* @author Andy hind
|
||||
*
|
||||
*/
|
||||
public interface SearchService
|
||||
{
|
||||
public static final String LANGUAGE_LUCENE = "lucene";
|
||||
|
||||
public static final String LANGUAGE_XPATH = "xpath";
|
||||
|
||||
public static final String LANGUAGE_JCR_XPATH = "jcr-xpath";
|
||||
|
||||
/**
|
||||
* Search against a store.
|
||||
*
|
||||
* @param store -
|
||||
* the store against which to search
|
||||
* @param language -
|
||||
* the query language
|
||||
* @param query -
|
||||
* the query string - which may include parameters
|
||||
* @param attributePaths -
|
||||
* explicit list of attributes/properties to extract for the
|
||||
* selected nodes in xpath style syntax
|
||||
* @param queryParameterDefinition -
|
||||
* query parameter definitions - the default value is used for
|
||||
* the value.
|
||||
* @return Returns the query results
|
||||
*/
|
||||
public ResultSet query(StoreRef store, String language, String query, Path[] attributePaths,
|
||||
QueryParameterDefinition[] queryParameterDefinitions);
|
||||
|
||||
/**
|
||||
* Search against a store. Pulls back all attributes on each node. Does not
|
||||
* allow parameterisation.
|
||||
*
|
||||
* @param store -
|
||||
* the store against which to search
|
||||
* @param language -
|
||||
* the query language
|
||||
* @param query -
|
||||
* the query string - which may include parameters
|
||||
* @return Returns the query results
|
||||
*/
|
||||
public ResultSet query(StoreRef store, String language, String query);
|
||||
|
||||
/**
|
||||
* Search against a store.
|
||||
*
|
||||
* @param store -
|
||||
* the store against which to search
|
||||
* @param language -
|
||||
* the query language
|
||||
* @param query -
|
||||
* the query string - which may include parameters
|
||||
* @param queryParameterDefinition -
|
||||
* query parameter definitions - the default value is used for
|
||||
* the value.
|
||||
* @return Returns the query results
|
||||
*/
|
||||
public ResultSet query(StoreRef store, String language, String query,
|
||||
QueryParameterDefinition[] queryParameterDefintions);
|
||||
|
||||
/**
|
||||
* Search against a store.
|
||||
*
|
||||
* @param store -
|
||||
* the store against which to search
|
||||
* @param language -
|
||||
* the query language
|
||||
* @param query -
|
||||
* the query string - which may include parameters
|
||||
* @param attributePaths -
|
||||
* explicit list of attributes/properties to extract for the
|
||||
* selected nodes in xpath style syntax
|
||||
* @return Returns the query results
|
||||
*/
|
||||
public ResultSet query(StoreRef store, String language, String query, Path[] attributePaths);
|
||||
|
||||
/**
|
||||
* Execute a canned query
|
||||
*
|
||||
* @param store -
|
||||
* the store against which to search
|
||||
* @param queryId -
|
||||
* the query identifier
|
||||
* @param queryParameters -
|
||||
* parameterisation for the canned query
|
||||
* @return Returns the query results
|
||||
*/
|
||||
public ResultSet query(StoreRef store, QName queryId, QueryParameter[] queryParameters);
|
||||
|
||||
/**
|
||||
* Search using the given SearchParameters
|
||||
*/
|
||||
|
||||
public ResultSet query(SearchParameters searchParameters);
|
||||
|
||||
/**
|
||||
* Select nodes using an xpath expression.
|
||||
*
|
||||
* @param contextNodeRef -
|
||||
* the context node for relative expressions etc
|
||||
* @param xpath -
|
||||
* the xpath string to evaluate
|
||||
* @param parameters -
|
||||
* parameters to bind in to the xpath expression
|
||||
* @param namespacePrefixResolver -
|
||||
* prefix to namespace mappings
|
||||
* @param followAllParentLinks -
|
||||
* if false ".." follows only the primary parent links, if true
|
||||
* it follows all
|
||||
* @return a list of all the child assoc relationships to the selected nodes
|
||||
*/
|
||||
public List<NodeRef> selectNodes(NodeRef contextNodeRef, String xpath, QueryParameterDefinition[] parameters,
|
||||
NamespacePrefixResolver namespacePrefixResolver, boolean followAllParentLinks)
|
||||
throws InvalidNodeRefException, XPathException;
|
||||
|
||||
/**
|
||||
* Select nodes using an xpath expression.
|
||||
*
|
||||
* @param contextNodeRef -
|
||||
* the context node for relative expressions etc
|
||||
* @param xpath -
|
||||
* the xpath string to evaluate
|
||||
* @param parameters -
|
||||
* parameters to bind in to the xpath expression
|
||||
* @param namespacePrefixResolver -
|
||||
* prefix to namespace mappings
|
||||
* @param followAllParentLinks -
|
||||
* if false ".." follows only the primary parent links, if true
|
||||
* it follows all
|
||||
* @param langauage -
|
||||
* the xpath variant
|
||||
* @return a list of all the child assoc relationships to the selected nodes
|
||||
*/
|
||||
public List<NodeRef> selectNodes(NodeRef contextNodeRef, String xpath, QueryParameterDefinition[] parameters,
|
||||
NamespacePrefixResolver namespacePrefixResolver, boolean followAllParentLinks, String language)
|
||||
throws InvalidNodeRefException, XPathException;
|
||||
|
||||
/**
|
||||
* Select properties using an xpath expression
|
||||
*
|
||||
* @param contextNodeRef -
|
||||
* the context node for relative expressions etc
|
||||
* @param xpath -
|
||||
* the xpath string to evaluate
|
||||
* @param parameters -
|
||||
* parameters to bind in to the xpath expression
|
||||
* @param namespacePrefixResolver -
|
||||
* prefix to namespace mappings
|
||||
* @param followAllParentLinks -
|
||||
* if false ".." follows only the primary parent links, if true
|
||||
* it follows all
|
||||
* @return a list of property values
|
||||
*/
|
||||
public List<Serializable> selectProperties(NodeRef contextNodeRef, String xpath,
|
||||
QueryParameterDefinition[] parameters, NamespacePrefixResolver namespacePrefixResolver,
|
||||
boolean followAllParentLinks) throws InvalidNodeRefException, XPathException;
|
||||
|
||||
/**
|
||||
* Select properties using an xpath expression
|
||||
*
|
||||
* @param contextNodeRef -
|
||||
* the context node for relative expressions etc
|
||||
* @param xpath -
|
||||
* the xpath string to evaluate
|
||||
* @param parameters -
|
||||
* parameters to bind in to the xpath expression
|
||||
* @param namespacePrefixResolver -
|
||||
* prefix to namespace mappings
|
||||
* @param followAllParentLinks -
|
||||
* if false ".." follows only the primary parent links, if true
|
||||
* it follows all
|
||||
* @param langauage -
|
||||
* the xpath variant
|
||||
* @return a list of property values
|
||||
*/
|
||||
public List<Serializable> selectProperties(NodeRef contextNodeRef, String xpath,
|
||||
QueryParameterDefinition[] parameters, NamespacePrefixResolver namespacePrefixResolver,
|
||||
boolean followAllParentLinks, String language) throws InvalidNodeRefException, XPathException;
|
||||
|
||||
/**
|
||||
* Search for string pattern in both the node text (if present) and node
|
||||
* properties
|
||||
*
|
||||
* @param nodeRef
|
||||
* the node to get
|
||||
* @param propertyQName
|
||||
* the name of the property
|
||||
* @param googleLikePattern
|
||||
* a Google-like pattern to search for in the property value
|
||||
* @return Returns true if the pattern could be found - uses the default OR operator
|
||||
*/
|
||||
public boolean contains(NodeRef nodeRef, QName propertyQName, String googleLikePattern)
|
||||
throws InvalidNodeRefException;
|
||||
|
||||
/**
|
||||
* Search for string pattern in both the node text (if present) and node
|
||||
* properties
|
||||
*
|
||||
* @param nodeRef
|
||||
* the node to get
|
||||
* @param propertyQName
|
||||
* the name of the property
|
||||
* @param googleLikePattern
|
||||
* a Google-like pattern to search for in the property value
|
||||
* @return Returns true if the pattern could be found
|
||||
*/
|
||||
public boolean contains(NodeRef nodeRef, QName propertyQName, String googleLikePattern, SearchParameters.Operator defaultOperator)
|
||||
throws InvalidNodeRefException;
|
||||
|
||||
/**
|
||||
* Search for string pattern in both the node text (if present) and node
|
||||
* properties
|
||||
*
|
||||
* @param nodeRef
|
||||
* the node to get
|
||||
* @param propertyQName
|
||||
* the name of the property (mandatory)
|
||||
* @param sqlLikePattern
|
||||
* a SQL-like pattern to search for
|
||||
* @param includeFTS -
|
||||
* include full text search matches in the like test
|
||||
* @return Returns true if the pattern could be found
|
||||
*/
|
||||
public boolean like(NodeRef nodeRef, QName propertyQName, String sqlLikePattern, boolean includeFTS)
|
||||
throws InvalidNodeRefException;
|
||||
}
|
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
package org.alfresco.service.cmr.search;
|
||||
|
||||
/**
|
||||
* A search string and language.
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
public class SearchStatement
|
||||
{
|
||||
|
||||
private String language;
|
||||
private String query;
|
||||
|
||||
SearchStatement()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
SearchStatement(String language, String query)
|
||||
{
|
||||
this.language = language;
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
public String getLanguage()
|
||||
{
|
||||
return language;
|
||||
}
|
||||
|
||||
public String getQuery()
|
||||
{
|
||||
return query;
|
||||
}
|
||||
|
||||
public void setLanguage(String language)
|
||||
{
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
public void setQuery(String query)
|
||||
{
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user