atg.repository
Interface QueryBuilder

All Known Subinterfaces:
ContentQueryBuilder, ParameterSupportQueryBuilder
All Known Implementing Classes:
Builder

public interface QueryBuilder

This object is used to build Query objects that can be passed to the Repository. Repositories do not need to implement all the query operations below. If an operation is not supported it is best to throw a RepositoryException. The Query and QueryExpression interfaces are designed to be open and flexible to allow different internal representations of query operations. An implementation of this interface is provided in QueryBuilderImpl. This class uses specific classes (e.g. AndQuery, PropertyQueryExpression, etc) to represent the query data structure. A developer wishing to create their own QueryBuilder does not have to subclass these classes.

See Also:
Query, QueryExpression, QueryBuilderImpl, RepositoryView.getQueryBuilder(), RepositoryView.executeQuery(atg.repository.Query)

Field Summary
static java.lang.String CLASS_VERSION
           
static int CONTAINS
          Pattern matching operation CONTAINS.
static int ENDS_WITH
          Pattern matching operation ENDS_WITH.
static int EQUALS
          Comparison Relation ==
static int GREATER_THAN
          Comparison Relation >
static int GREATER_THAN_OR_EQUALS
          Comparison Relation >=
static int LESS_THAN
          Comparison Relation <
static int LESS_THAN_OR_EQUALS
          Comparison Relation <=
static int NOT_CONTAINS
          Pattern matching operation NOT_CONTAINS.
static int NOT_ENDS_WITH
          Pattern matching operation NOT_ENDS_WITH.
static int NOT_EQUALS
          Comparison Relation !=
static int NOT_STARTS_WITH
          Pattern matching operation NOT_STARTS_WITH.
static int STARTS_WITH
          Pattern matching operation STARTS_WITH.
 
Method Summary
 Query createAndQuery(Query[] pQueryElements)
          Creates a query representing the logical AND of several queries.
 Query createComparisonQuery(QueryExpression pExpression1, QueryExpression pExpression2, int pComparisonRelation)
          Creates a query representing an equivalence relationship between two expressions.
 QueryExpression createConstantQueryExpression(java.lang.Object pValue)
          Returns a QueryExpression for the supplied constant object
 QueryExpression createCountQueryExpression(QueryExpression pCollection)
          Returns a QueryExpression which represents the total number of elements for a collection for the given item.
 QueryExpression createElementAtQueryExpression(QueryExpression pIndex, QueryExpression pCollection)
          Returns a QueryExpression which represents an element in a collection of a property at a specified index.
 Query createIdMatchingQuery(java.lang.String[] pIds)
          Creates a query which when executed will return all items with the given ids.
 Query createIncludesAllQuery(QueryExpression pCollection1, QueryExpression pCollection2)
          Creates a query that is matched if the property, which must evaluate to a Collection-like object, includes all of the values in the second Collection-like object.
 Query createIncludesAnyQuery(QueryExpression pCollection1, QueryExpression pCollection2)
          Creates a query that is matched if the property, which must evaluate to a Collection-like object, includes any of the values in the second Collection-like object.
 Query createIncludesItemQuery(QueryExpression pCollection, Query pQuery)
          This query takes two parameters.
 Query createIncludesQuery(QueryExpression pCollection, QueryExpression pItem)
          Creates a query that is matched if the property, which must evaluate to a Collection-like object, includes the supplied value.
 QueryExpression createIndexOfQueryExpression(QueryExpression pItem, QueryExpression pCollection)
          Returns a QueryExpression which represents the numeric index location of the supplied object in the given collection
 Query createIsNullQuery(QueryExpression pProperty)
          Creates a query that is matched if the property is null (not defined).
 Query createNotQuery(Query pQueryElement)
          Creates a query representing the logical NOT of a query
 Query createOrQuery(Query[] pQueryElements)
          Creates a query representing the logical OR of several queries.
 Query createPatternMatchQuery(QueryExpression pContainerString, QueryExpression pContainedString, int pMatchingOperation)
          Creates a query representing a pattern matching operation.
 Query createPatternMatchQuery(QueryExpression pContainerString, QueryExpression pContainedString, int pMatchingOperation, boolean pIgnoreCase)
          Creates a query representing a pattern matching operation.
 QueryExpression createPropertyQueryExpression(QueryExpression pParentProperty, java.lang.String pPropertyName)
          If the repository supports sub-property queries, returns a property query expression for the named property of the supplied property query expression.
 QueryExpression createPropertyQueryExpression(java.lang.String pPropertyName)
          Returns a property query expression for the supplied property name.
 Query createTextSearchQuery(QueryExpression pSearchString, QueryExpression pSearchStringFormat, QueryExpression pMinScore)
          Creates a query representing the full text search query operation.
 Query createTextSearchQuery(QueryExpression pProperty, QueryExpression pSearchString, QueryExpression pSearchStringFormat, QueryExpression pMinScore)
          Creates a query representing the full text search query operation.
 Query createUnconstrainedQuery()
          Creates a query which when executed would return all the items available from this view.
 RepositoryView getRepositoryView()
          Returns the repository view that this query builder was created from.
 

Field Detail

CLASS_VERSION

static final java.lang.String CLASS_VERSION
See Also:
Constant Field Values

EQUALS

static final int EQUALS
Comparison Relation ==

See Also:
createComparisonQuery, Constant Field Values

NOT_EQUALS

static final int NOT_EQUALS
Comparison Relation !=

See Also:
createComparisonQuery, Constant Field Values

LESS_THAN

static final int LESS_THAN
Comparison Relation <

See Also:
createComparisonQuery, Constant Field Values

GREATER_THAN

static final int GREATER_THAN
Comparison Relation >

See Also:
createComparisonQuery, Constant Field Values

LESS_THAN_OR_EQUALS

static final int LESS_THAN_OR_EQUALS
Comparison Relation <=

See Also:
createComparisonQuery, Constant Field Values

GREATER_THAN_OR_EQUALS

static final int GREATER_THAN_OR_EQUALS
Comparison Relation >=

See Also:
createComparisonQuery, Constant Field Values

CONTAINS

static final int CONTAINS
Pattern matching operation CONTAINS. e.g. "foobar" contains "foo"

See Also:
createPatternMatchQuery, Constant Field Values

STARTS_WITH

static final int STARTS_WITH
Pattern matching operation STARTS_WITH. e.g. "foobar" starts with "foo"

See Also:
createPatternMatchQuery, Constant Field Values

ENDS_WITH

static final int ENDS_WITH
Pattern matching operation ENDS_WITH. e.g. "foobar" ends with "bar"

See Also:
createPatternMatchQuery, Constant Field Values

NOT_CONTAINS

static final int NOT_CONTAINS
Pattern matching operation NOT_CONTAINS. e.g. not "foobar" contains "foo"

See Also:
createPatternMatchQuery, Constant Field Values

NOT_STARTS_WITH

static final int NOT_STARTS_WITH
Pattern matching operation NOT_STARTS_WITH. e.g. not "foobar" starts with "foo"

See Also:
createPatternMatchQuery, Constant Field Values

NOT_ENDS_WITH

static final int NOT_ENDS_WITH
Pattern matching operation NOT_ENDS_WITH. e.g. not "foobar" ends with "bar"

See Also:
createPatternMatchQuery, Constant Field Values
Method Detail

getRepositoryView

RepositoryView getRepositoryView()
Returns the repository view that this query builder was created from.


createAndQuery

Query createAndQuery(Query[] pQueryElements)
                     throws RepositoryException
Creates a query representing the logical AND of several queries. The method expects one or more query elements.

Throws:
RepositoryException - if there was an error building the query operation

createOrQuery

Query createOrQuery(Query[] pQueryElements)
                    throws RepositoryException
Creates a query representing the logical OR of several queries. The method expects one or more query elements.

Throws:
RepositoryException - if there was an error building the query operation

createNotQuery

Query createNotQuery(Query pQueryElement)
                     throws RepositoryException
Creates a query representing the logical NOT of a query

Throws:
RepositoryException - if there was an error building the query operation

createUnconstrainedQuery

Query createUnconstrainedQuery()
                               throws RepositoryException
Creates a query which when executed would return all the items available from this view.

Throws:
RepositoryException - if there was an error building the query operation

createIdMatchingQuery

Query createIdMatchingQuery(java.lang.String[] pIds)
                            throws RepositoryException
Creates a query which when executed will return all items with the given ids.

Throws:
RepositoryException - if there was an error building the query operation

createComparisonQuery

Query createComparisonQuery(QueryExpression pExpression1,
                            QueryExpression pExpression2,
                            int pComparisonRelation)
                            throws RepositoryException
Creates a query representing an equivalence relationship between two expressions. The Comparison Relation should be one of EQUALS, NOT_EQUALS, GREATER_THAN, LESS_THAN, GREATER_THAN_OR_EQUALS, or LESS_THAN_OR_EQUALS.

Parameters:
pExpression1 - first item in the equivalence relationship
pExpression2 - second item in the equivalence relationship
pComparisonRelation - the comparison relation to evaluate, EQUALS, NOT_EQUALS, GREATER_THAN, LESS_THAN, GREATER_THAN_OR_EQUALS, or LESS_THAN_OR_EQUALS.
Throws:
RepositoryException - if there was an error building the query operation

createIncludesQuery

Query createIncludesQuery(QueryExpression pCollection,
                          QueryExpression pItem)
                          throws RepositoryException
Creates a query that is matched if the property, which must evaluate to a Collection-like object, includes the supplied value.

Parameters:
pCollection - should evaluate into a collection
pItem - should evaluate into a value which will be looked for in the collection
Throws:
RepositoryException - if there was an error building the query operation

createIncludesAnyQuery

Query createIncludesAnyQuery(QueryExpression pCollection1,
                             QueryExpression pCollection2)
                             throws RepositoryException
Creates a query that is matched if the property, which must evaluate to a Collection-like object, includes any of the values in the second Collection-like object.

Parameters:
pCollection1 - should evaluate into a collection
pCollection2 - should evaluate into a collection of values which will be looked for in the first collection
Throws:
RepositoryException - if there was an error building the query operation

createIncludesAllQuery

Query createIncludesAllQuery(QueryExpression pCollection1,
                             QueryExpression pCollection2)
                             throws RepositoryException
Creates a query that is matched if the property, which must evaluate to a Collection-like object, includes all of the values in the second Collection-like object.

Parameters:
pCollection1 - should evaluate into a collection
pCollection2 - should evaluate into a collection of values which will be looked for in the first collection
Throws:
RepositoryException - if there was an error building the query operation

createIncludesItemQuery

Query createIncludesItemQuery(QueryExpression pCollection,
                              Query pQuery)
                              throws RepositoryException
This query takes two parameters. One is a QueryExpression which evaluates to a property which is a collection of items. The other is a sub-query which is defined for the type of items in this collection. This query matches an item if its collection property has at least one item which matches the sub-query.

Note that the sub-query should be defined using a query builder for the repository view of the item type referenced in the collection. This is often different from the query builder used to create this particular query operation.

For example, if you have a category item type, which has a collection of products. This query can be used to return categories which have at least one product which has type="shorts" and size="medium". In this case, the sub-query (type="shorts" and size="medium") should be created using the query builder for the products repository view.

Parameters:
pCollection - should be a PropertyQueryExpression which refers to a collection of items
pQuery - a query which should match the referenced repository items
Throws:
RepositoryException - if there was an error building the query operation

createPatternMatchQuery

Query createPatternMatchQuery(QueryExpression pContainerString,
                              QueryExpression pContainedString,
                              int pMatchingOperation)
                              throws RepositoryException
Creates a query representing a pattern matching operation. The MatchingType should be one of CONTAINS, STARTS_WITH, ENDS_WITH, EQUALS.

Parameters:
pContainerString - the string which could contain the substring
pContainedString - the substring to perform the checking against
pMatchingOperation - the matching process to evaluate, CONTAINS, STARTS_WITH, ENDS_WITH
Throws:
RepositoryException - if there was an error building the query operation

createPatternMatchQuery

Query createPatternMatchQuery(QueryExpression pContainerString,
                              QueryExpression pContainedString,
                              int pMatchingOperation,
                              boolean pIgnoreCase)
                              throws RepositoryException
Creates a query representing a pattern matching operation. The MatchingType should be one of CONTAINS, STARTS_WITH, ENDS_WITH, EQUALS.

Parameters:
pContainerString - the string which could contain the substring
pContainedString - the substring to perform the checking against
pMatchingOperation - the matching process to evaluate, CONTAINS,
pIgnoreCase - true if the match performed is case insensitive STARTS_WITH, ENDS_WITH
Throws:
RepositoryException - if there was an error building the query operation

createTextSearchQuery

Query createTextSearchQuery(QueryExpression pProperty,
                            QueryExpression pSearchString,
                            QueryExpression pSearchStringFormat,
                            QueryExpression pMinScore)
                            throws RepositoryException
Creates a query representing the full text search query operation. In addition to the search string itself, you provide an optional property to search and the name of the format of the search string.

Parameters:
pProperty - should be a PropertyQueryExpression specifying the property whose text value should be searched. This value can be null to search the default set of properties for this item descriptor in this repository.
pSearchString - the string containing the full text search query
pSearchStringFormat - the name of the format that the full text search query. If you specify null here, a default format is used. To see the list of formats supported by a particular repository, check the SupportedQueries.getTextSearchFormats() property.
pMinScore - This specifies an integer value from 0 to 100. It can be used as a hint to the search engine to control how close a match must be for an item to be returned.
Throws:
RepositoryException - if there was an error building the query operation

createTextSearchQuery

Query createTextSearchQuery(QueryExpression pSearchString,
                            QueryExpression pSearchStringFormat,
                            QueryExpression pMinScore)
                            throws RepositoryException
Creates a query representing the full text search query operation. This version of this method searches the default set of searchable properties for a particular repository.

Parameters:
pSearchString - the string containing the full text search query
pSearchStringFormat - the name of the format that the full text search query. If you specify null here, a default format is used. To see the list of formats supported by a particular repository, check the SupportedQueries.getSearchStringFormatsSupported() property.
pMinScore - This specifies an integer value from 0 to 100. It can be used as a hint to the search engine to control how close a match must be for an item to be returned.
Throws:
RepositoryException - if there was an error building the query operation

createIsNullQuery

Query createIsNullQuery(QueryExpression pProperty)
                        throws RepositoryException
Creates a query that is matched if the property is null (not defined).

Throws:
RepositoryException - if there was an error building the query operation

createPropertyQueryExpression

QueryExpression createPropertyQueryExpression(java.lang.String pPropertyName)
                                              throws RepositoryException
Returns a property query expression for the supplied property name. If the repository supports sub-property queries and pPropertyName contains one or more dot characters '.', the name is assumed to refer to a subproperty and an attempt is made to create the appropriate subproperty.

Parameters:
pPropertyName - the name of the property to evaluate
Throws:
RepositoryException - if there was an error building the query operation

createPropertyQueryExpression

QueryExpression createPropertyQueryExpression(QueryExpression pParentProperty,
                                              java.lang.String pPropertyName)
                                              throws RepositoryException
If the repository supports sub-property queries, returns a property query expression for the named property of the supplied property query expression. (e.g. represents address.city)

Parameters:
pParentProperty - the property expression which contains the property named by pPropertyName
pPropertyName - the name of the property to evaluate
Throws:
RepositoryException - if there was an error building the query operation

createConstantQueryExpression

QueryExpression createConstantQueryExpression(java.lang.Object pValue)
                                              throws RepositoryException
Returns a QueryExpression for the supplied constant object

Parameters:
pValue - a "constant object" whose value can be determined immediately. (e.g. Integer, Boolean, String, Vector)
Throws:
RepositoryException - if there was an error building the query operation

createElementAtQueryExpression

QueryExpression createElementAtQueryExpression(QueryExpression pIndex,
                                               QueryExpression pCollection)
                                               throws RepositoryException
Returns a QueryExpression which represents an element in a collection of a property at a specified index.

Parameters:
pCollection - should evaluate into a collection
pIndex - should evaluate into a value which can be used to return the element at specific location of the collection. like operation (e.g. an int or long)
Throws:
RepositoryException - if there was an error building the query operation

createIndexOfQueryExpression

QueryExpression createIndexOfQueryExpression(QueryExpression pItem,
                                             QueryExpression pCollection)
                                             throws RepositoryException
Returns a QueryExpression which represents the numeric index location of the supplied object in the given collection

Parameters:
pCollection - should evaluate into a collection
pItem - should evaluate into a value which will be looked for in the collection
Throws:
RepositoryException - if there was an error building the query operation

createCountQueryExpression

QueryExpression createCountQueryExpression(QueryExpression pCollection)
                                           throws RepositoryException
Returns a QueryExpression which represents the total number of elements for a collection for the given item.

Parameters:
pCollection - should evaluate into a collection of items which can be counted.
Throws:
RepositoryException - if there was an error building the query operation