atg.adapter.gsa.query
Class Builder

java.lang.Object
  extended by atg.adapter.gsa.query.Builder
All Implemented Interfaces:
atg.adapter.gsa.Constants, atg.repository.CompositeIdQueryBuilder, ContentQueryBuilder, atg.repository.dp.DerivedPropertyQueryBuilder, ParameterSupportQueryBuilder, QueryBuilder, java.io.Serializable

public class Builder
extends java.lang.Object
implements ParameterSupportQueryBuilder, atg.adapter.gsa.Constants, java.io.Serializable, ContentQueryBuilder, atg.repository.dp.DerivedPropertyQueryBuilder, atg.repository.CompositeIdQueryBuilder

A query builder that builds queries for a sepcific type of RepositoryItem. The type of item is defined by the property itemDescriptor.

See Also:
Serialized Form

Nested Class Summary
protected  class Builder.GroupPropertyExpression
          Used internally to mark a property expression which refers to a group.
 
Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 atg.adapter.gsa.query.ParameterExpression mSingleParameterExpression
          A single instance of a ParameterExpression that will be used as a placeholder for parameters in a query
 
Fields inherited from interface atg.adapter.gsa.Constants
ATTR_CASCADE_DELETE_ORDER, ATTR_CSW_PROPERTIES, ATTR_CSW_QUERIES, ATTR_DEFAULT_UNCACHED_ITEM_QUERIES, ATTR_LAZY_ITEM_LOADING, ATTR_SPLIT_QUERIES, ATTR_TEXT_HANDLE_COLUMN, ATTR_TEXT_INDEX_TABLE, ATTR_UPDATE_LAST_MODIFIED, CASCADE_DELETE_AFTER_AUX_BEFORE_PRI, CASCADE_DELETE_FIRST, CASCADE_DELETE_LAST, CASCADE_DELETE_ORDER_NAMES, DEFAULT_EVENT_SERVER, DEFAULT_INVALIDATOR_SERVICE, ERR_ADD_MISSING_PROPERTIES, ERR_ADD_NON_TRANSIENT, ERR_ARGS_FOR_NON_PARAMETER_QUERY, ERR_BAD_EVENT_DATA, ERR_BAD_TABLE, ERR_CIRCULAR_REFERENCE, ERR_CLASS_NOT_FOUND, ERR_COLLECTION_LOAD_ID, ERR_COMPARE_MULTI, ERR_COMPARE_NONCOMPARABLE, ERR_CONTENT_PROPERTIES_NOT_DEFINED, ERR_COULD_NOT_UNSUBSCRIBE, ERR_DEPENDENT_PROP_NOT_EXISTS, ERR_DEPENDENT_PROP_NULL, ERR_DS_PREPARE, ERR_DS_SWITCH, ERR_EXC_COLLECTION_LOAD_FULL, ERR_EXC_COLLECTION_LOAD_SINGLE, ERR_FOLDER_PROPERTIES_NOT_DEFINED, ERR_HANDLING_INVALIDATE_CACHE_ENTRY, ERR_ID_SPACE_CONFIGURATION, ERR_ILLEGAL_PARAM_TYPE, ERR_INITIALIZING_ID_GENERATOR, ERR_INVALID_COMPARISON_QUERY, ERR_INVALID_DATA_TYPE_NAME, ERR_INVALID_ITEM, ERR_INVALID_ITEM_DESCRIPTOR_NAME, ERR_INVALID_KEY, ERR_INVALID_KEY_ELEMENT, ERR_INVALID_KEY_ENCODING, ERR_INVALID_KEY_VALUES, ERR_INVALID_LIST_INDEX, ERR_INVALID_PATTERNMATCH_QUERY, ERR_INVALID_PROPERTY, ERR_INVALID_QUERY, ERR_INVALID_QUERY_ELEMENT, ERR_INVALID_TEXT_SEARCH_QUERY, ERR_INVALID_TM_DS_COMBO, ERR_ITEM_NOT_EXIST, ERR_LOAD_COLUMN_INFO, ERR_MISSING_ID_SPACE, ERR_NO_ARGS_FOR_QUERY, ERR_NO_DATABASE_TABLE_INFO, ERR_NO_DATATYPE_FOR_PROPERTY, ERR_NO_DB2_HANDLE, ERR_NO_DEFAULT_SEARCH_PROPERTIES, ERR_NO_EVENT_SERVER, ERR_NO_IDS, ERR_NO_LOWER_FUNCTION, ERR_NO_PARAMETER_EXPRESSION, ERR_NO_PARSER, ERR_NO_PRIMARY_TABLE, ERR_NO_SUB_PROPERTIES, ERR_NO_SUBSCRIBER_ITEM_DESCRIPTOR, ERR_NO_SYB_TEXT_INDEX, ERR_NO_TEMPLATE_FILES, ERR_NO_TRANSACTION, ERR_NO_TRANSIENT_QUERIES, ERR_NOT_DISTRIBUTED_MODE, ERR_NULL_ARGUMENT, ERR_NULL_ID, ERR_NULL_ITEM, ERR_NULL_QUERY_OPTIONS, ERR_PARSING_TEMPLATE, ERR_PROCEDURE_HELPER_INIT, ERR_PROPERTY_NOT_QUERYABLE, ERR_RETURN_PROP_NOT_EXISTS, ERR_RETURN_PROP_NOT_GSA, ERR_RETURN_PROP_NOT_READ, ERR_RETURN_PROP_NULL, ERR_RQL_FILTER, ERR_SQL_STRING_NULL, ERR_SUB_TYPE_PROPERTY_ON_NON_ROOT_TYPE, ERR_TABLE_KEY_UNMATCHED, ERR_TRANSACTION, ERR_TYPE_MATCHING, ERR_UNABLE_TO_READ_TEMPLATE_FILE, ERR_UNKNOWN_EVENT_TYPE, ERR_VERSION_PROPERTY_INVALID_TYPE, ERR_VIEW_IS_TRANSIENT, ERR_WRONG_NUMBER_ARGS_FOR_QUERY, FTS_LANG_DB2, FTS_LANG_MSSQL, FTS_LANG_MSSQL_INLINE, FTS_LANG_ORACLE, FTS_LANG_SYBASE, INFO_STARTUP_BEGIN, INFO_STARTUP_END, ISOLATION_LEVEL_NAMES, READ_COMMITTED, REPEATABLE_READ, REPOSITORY_COMPONENT_NAME, RESOURCE_BUNDLE_NAME, SERIALIZABLE, SUBSCRIBER_ADDRESS_PROPERTY, SUBSCRIBER_ITEM_DESCRIPTOR_NAME, SUBSCRIBER_ITEM_DESCRIPTOR_PROPERTY, SUBSCRIBER_PORT_PROPERTY, SUBSCRIBER_REPOSITORY_PROPERTY, WARN_PROBLEM_SENDING_EVENT, WARN_RETURN_PROP_MULTI, WARN_RETURN_PROP_TRANSIENT
 
Constructor Summary
Builder(GSAItemDescriptor pItemDescriptor)
          Construct a builder for the given item descriptor
 
Method Summary
protected  Query constantQuery(boolean pValue)
          Utility routine for generating a query which always evaluates to true or false.
 Query createAndQuery(Query[] pQueryElements)
          Creates a query representing the logical AND of several queries.
 Query createComparisonQuery(QueryExpression pLeft, QueryExpression pRight, int pComparisonOperator)
          Create a query representing a logical comparison between two expressions.
 Query createComparisonQuery(atg.adapter.gsa.query.Value pLeft, atg.adapter.gsa.query.Value pRight, int pComparisonOperator)
          Create a query representing a logical comparison between two constant value 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.
 Query createDirectSqlQuery(java.lang.String pQuery, RepositoryPropertyDescriptor[] pReturnedProps, RepositoryPropertyDescriptor[] pDependentProps, java.lang.Class[] pInputParameterClasses)
          This is a variation of the SqlPassThroughQuery that can call stored procedures as well as execute straight sql.
 Query createDirectSqlQuery(java.lang.String pQuery, RepositoryPropertyDescriptor[] pReturnedProps, RepositoryPropertyDescriptor[] pDependentProps, java.lang.Class[] pInputParameterClasses, boolean pIsStoredProcedure)
          This is a variation of the SqlPassThroughQuery that can call stored procedures as well as execute straight sql.
 QueryExpression createElementAtQueryExpression(QueryExpression pIndex, QueryExpression pCollection)
          Returns a QueryExpression which represents an element in a collection of a property at a specified index.
protected  Query createGroupComparisonQuery(QueryExpression pExpr1, QueryExpression pExpr2, int pRelation)
          Creates a comparison query where one operator is a constant and the other is a group.
 Query createIdMatchingQuery(atg.repository.CompositeKey[] pIds)
          Create a query which returns the items that have the supplied ids.
 Query createIdMatchingQuery(java.lang.String[] pIds)
          Create a query which returns the items that have the supplied 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)
          Creates a query that is matched if the property, which must evaluate to a Collection, Map, or array of repository items, has at least one item which matches the query provided.
 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 createInFoldersQuery(atg.repository.CompositeKey[] pFolderIds)
          Returns a query which when executed would return all the pieces of content which are contained within the supplied folders.
 Query createInFoldersQuery(java.lang.String[] pFolderIds)
          Returns a query which when executed would return all the pieces of content which are contained within the supplied folders.
 Query createIsNullQuery(QueryExpression pProperty)
          Creates a query that is matched if the property is null.
 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 createParameterComparisonQuery(atg.adapter.gsa.query.Atom pLeft, atg.adapter.gsa.query.Atom pRight, atg.adapter.gsa.query.Operator pComparisonOperator)
          Creates a comparison query where one or more expressions in the query is a ParameterExpression
 Query createParameterPatternMatchQuery(QueryExpression pValueString, atg.adapter.gsa.query.ParameterExpression pPatternString, int pMatchingOperation, boolean pIgnoreCase, boolean pEscapeWildcards)
          Creates a case-sensitive query representing a pattern matching operation.
 QueryExpression createParameterQueryExpression()
          Creates a parameter QueryExpression, which is just a placeholder in a Query for a parameter to be determined at execution time When inserted into a query object the index of this expression could be changed at runtime, since it could be ANDed or ORed multiple times
protected  Query createParameterTextSearchQuery(atg.adapter.gsa.query.PropertyExpression pProperty, atg.adapter.gsa.query.ParameterExpression pSearchString, java.lang.String pSearchStringFormat, atg.adapter.gsa.query.Value pMinScore)
          Creates a query representing the full text search query operation.
 Query createPatternMatchQuery(QueryExpression pValueString, QueryExpression pPatternString, int pMatchingOperation)
          Creates a case-sensitive query representing a pattern matching operation.
 Query createPatternMatchQuery(QueryExpression pValueString, QueryExpression pPatternString, int pMatchingOperation, boolean pIgnoreCase)
          Creates a case-sensitive query representing a pattern matching operation.
 Query createPatternMatchQuery(QueryExpression pValueString, QueryExpression pPatternString, int pMatchingOperation, boolean pIgnoreCase, boolean pEscapeWildcards)
          Creates a query representing a pattern matching operation.
 QueryExpression createPropertyQueryExpression(QueryExpression pParentProperty, java.lang.String pPropertyName)
          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 createSqlPassthroughQuery(java.lang.String pSqlString, java.lang.Object[] pArgs)
          Returns a query which when executed performs a query against the database with the specified SQL string, which overrides SQL string which would be used by the GSA to perform this query, or any query built using this query.
 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 returns all of the items in the repository, Nota Bene: This is a potentially very expensive operation.
 java.lang.String format(java.lang.String pMsgKey)
          Utility for formatting messages with no arguments.
 java.lang.String format(java.lang.String pMsgKey, java.lang.Object pArg)
           
 java.lang.String format(java.lang.String pMsgKey, java.lang.Object[] pArgs)
          Utility for formatting predefined messages using our respository's resource bundle.
 java.lang.String format(java.lang.String pMsgKey, java.lang.Object pArg1, java.lang.Object pArg2)
           
 GSAItemDescriptor getItemDescriptor()
          Get property itemDescriptor.
 ApplicationLogging getLogger()
          Get a logger to use for derived property related errors and debug messages.
 atg.adapter.gsa.GSARepository getRepository()
          Get property Repository
 RepositoryView getRepositoryView()
          Gets the repository view for this query builder
protected  atg.adapter.gsa.query.Operator getValidOperator(int pCode)
          Get the operator specified, by the code.
 Query rebuild(Query pQuery, atg.repository.dp.TranslationContext pContext)
          Rebuild the specified query using the specified query builder.
 java.lang.String toString()
          Get a string representation of this object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static final java.lang.String CLASS_VERSION
Class version string

See Also:
Constant Field Values

mSingleParameterExpression

public atg.adapter.gsa.query.ParameterExpression mSingleParameterExpression
A single instance of a ParameterExpression that will be used as a placeholder for parameters in a query

Constructor Detail

Builder

public Builder(GSAItemDescriptor pItemDescriptor)
Construct a builder for the given item descriptor

Method Detail

getItemDescriptor

public GSAItemDescriptor getItemDescriptor()
Get property itemDescriptor. The item descriptor describing the item type which we know how to query.

Returns:
itemDescriptor

getRepositoryView

public RepositoryView getRepositoryView()
Gets the repository view for this query builder

Specified by:
getRepositoryView in interface QueryBuilder

getRepository

public atg.adapter.gsa.GSARepository getRepository()
Get property Repository

Returns:
Repository

createIdMatchingQuery

public Query createIdMatchingQuery(java.lang.String[] pIds)
                            throws RepositoryException
Create a query which returns the items that have the supplied ids.

Specified by:
createIdMatchingQuery in interface QueryBuilder
Parameters:
pIds - array of desired ids, must contain at least one id
Returns:
the query
Throws:
RepositoryException - if pIds is null or zero-lengh or if there is an error building the query

createIdMatchingQuery

public Query createIdMatchingQuery(atg.repository.CompositeKey[] pIds)
                            throws RepositoryException
Create a query which returns the items that have the supplied ids.

Specified by:
createIdMatchingQuery in interface atg.repository.CompositeIdQueryBuilder
Parameters:
pIds - array of desired ids
Returns:
the query
Throws:
RepositoryException - if pIds is null or zero-lengh or if there is an error building the query

createConstantQueryExpression

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

Specified by:
createConstantQueryExpression in interface QueryBuilder
Parameters:
pValue - a "constant object" whose value can be determined immediately. For scalar values this can be one of:
  • java.lang.Boolean
  • java.lang.Byte
  • java.lang.Character
  • java.lang.Integer
  • java.lang.Long
  • java.lang.String
  • java.lang.Float
  • java.lang.Double
  • java.util.Date
  • java.sql.Date
  • java.sql.Timestamp

For collection like values this can be one of:

  • java.util.Collection
  • Object[]

Eeach element of the Collection or array must be a scalar primitive object, as defined above. The Collection or array is used as-is, no copy is made.

Returns:
the query
Throws:
RepositoryException - if there is an error building the query

createParameterQueryExpression

public QueryExpression createParameterQueryExpression()
                                               throws RepositoryException
Creates a parameter QueryExpression, which is just a placeholder in a Query for a parameter to be determined at execution time When inserted into a query object the index of this expression could be changed at runtime, since it could be ANDed or ORed multiple times

Specified by:
createParameterQueryExpression in interface ParameterSupportQueryBuilder
Returns:
a parameter QueryExpression
Throws:
a - RepositoryException if an expression cannot be made using this QueryBuilder
RepositoryException - if an expression cannot be made using this QueryBuilder

createPropertyQueryExpression

public QueryExpression createPropertyQueryExpression(java.lang.String pPropertyName)
                                              throws RepositoryException
Returns a property query expression for the supplied property name. If the name 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.

Specified by:
createPropertyQueryExpression in interface atg.repository.dp.DerivedPropertyQueryBuilder
Specified by:
createPropertyQueryExpression in interface QueryBuilder
Parameters:
pPropertyName - the name of the property to evaluate
Returns:
the query
Throws:
RepositoryException - if there is an error building the query

createPropertyQueryExpression

public QueryExpression createPropertyQueryExpression(QueryExpression pParentProperty,
                                                     java.lang.String pPropertyName)
                                              throws RepositoryException
Returns a property query expression for the named property of the supplied property query expression.

Specified by:
createPropertyQueryExpression in interface QueryBuilder
Parameters:
pParentProperty - the property expression which contains the property named by pPropertyName
pPropertyName - the name of the property to evaluate
Returns:
the query
Throws:
RepositoryException - if the query is invalid

createAndQuery

public Query createAndQuery(Query[] pQueryElements)
                     throws RepositoryException
Creates a query representing the logical AND of several queries.

Specified by:
createAndQuery in interface QueryBuilder
Returns:
the query
Throws:
RepositoryException - if there is an error building the query

createOrQuery

public Query createOrQuery(Query[] pQueryElements)
                    throws RepositoryException
Creates a query representing the logical OR of several queries.

Specified by:
createOrQuery in interface QueryBuilder
Returns:
the query
Throws:
RepositoryException - if there is an error building the query

createNotQuery

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

Specified by:
createNotQuery in interface QueryBuilder
Returns:
the query
Throws:
RepositoryException - if there is an error building the query

createComparisonQuery

public Query createComparisonQuery(QueryExpression pLeft,
                                   QueryExpression pRight,
                                   int pComparisonOperator)
                            throws RepositoryException
Create a query representing a logical comparison between two expressions.

Specified by:
createComparisonQuery in interface QueryBuilder
Parameters:
pLeft - first (LHS) item in the comparison
pRight - second (RHS) item in the comparison
pComparisonOperator - the comparison operator to use, one of:
  • EQUALS
  • NOT_EQUALS
  • GREATER_THAN
  • LESS_THAN
  • GREATER_THAN_OR_EQUALS
  • LESS_THAN_OR_EQUALS

NB: the caller is responsible for insuring that pComparisonOperator is one of the valid choices

Returns:
the query
Throws:
RepositoryException - if there is an error building the query
See Also:
QueryBuilder

createComparisonQuery

public Query createComparisonQuery(atg.adapter.gsa.query.Value pLeft,
                                   atg.adapter.gsa.query.Value pRight,
                                   int pComparisonOperator)
                            throws RepositoryException
Create a query representing a logical comparison between two constant value expressions. The comparison is performed inline and a constant query is returned.

Parameters:
pLeft - first (LHS) item in the comparison, must implement Comparable
pRight - second (RHS) item in the comparison, must be supported by pLeft for comparisons
pComparisonOperator - comparison operator to use
Returns:
the query
Throws:
RepositoryException - if there is an error building the query

createParameterComparisonQuery

public Query createParameterComparisonQuery(atg.adapter.gsa.query.Atom pLeft,
                                            atg.adapter.gsa.query.Atom pRight,
                                            atg.adapter.gsa.query.Operator pComparisonOperator)
                                     throws RepositoryException
Creates a comparison query where one or more expressions in the query is a ParameterExpression

Parameters:
pLeft - the left expression
pRight - the right expression
pComparisonOperator - the operator used to compare the left and right expressions
Returns:
a comparison query
Throws:
RepositoryException - if an error occurs while creating the query

getValidOperator

protected final atg.adapter.gsa.query.Operator getValidOperator(int pCode)
                                                         throws RepositoryException
Get the operator specified, by the code.

Parameters:
pCode - int code of operator to get
Throws:
RepositoryException - if the code is invalid

createGroupComparisonQuery

protected Query createGroupComparisonQuery(QueryExpression pExpr1,
                                           QueryExpression pExpr2,
                                           int pRelation)
                                    throws RepositoryException
Creates a comparison query where one operator is a constant and the other is a group.

Throws:
RepositoryException

createIsNullQuery

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

Specified by:
createIsNullQuery in interface QueryBuilder
Returns:
the query
Throws:
RepositoryException - if there is an error building the query

createPatternMatchQuery

public Query createPatternMatchQuery(QueryExpression pValueString,
                                     QueryExpression pPatternString,
                                     int pMatchingOperation)
                              throws RepositoryException
Creates a case-sensitive query representing a pattern matching operation. pMatchingOperation must be once of:

Be advised that STARTS_WITH and EQUALS queries can be optimized easily using DB indexes. The other pattern match queries generally cannot be.

Specified by:
createPatternMatchQuery in interface QueryBuilder
Parameters:
pValueString - the string which is searched for the substring. This must have been created with createPropertyQueryExpression() or createConstantQueryExpression
pPatternString - the pattern to search for. This must have been created with createConstantQueryExpression
pMatchingOperation - the type of match to search for
Throws:
RepositoryException - if there is an error building the query

createPatternMatchQuery

public Query createPatternMatchQuery(QueryExpression pValueString,
                                     QueryExpression pPatternString,
                                     int pMatchingOperation,
                                     boolean pIgnoreCase)
                              throws RepositoryException
Creates a case-sensitive query representing a pattern matching operation. pMatchingOperation must be once of:

Be advised that STARTS_WITH and EQUALS queries can be optimized easily using DB indexes. The other pattern match queries generally cannot be.

Specified by:
createPatternMatchQuery in interface QueryBuilder
Parameters:
pValueString - the string which is searched for the substring. This must have been created with createPropertyQueryExpression() or createConstantQueryExpression
pPatternString - the pattern to search for. This must have been created with createConstantQueryExpression or createParameterQueryExpression
pMatchingOperation - the type of match to search for
pIgnoreCase - if false match is case-sensitive, if true match is case-insensitive
Throws:
RepositoryException - if there is an error building the query

createPatternMatchQuery

public Query createPatternMatchQuery(QueryExpression pValueString,
                                     QueryExpression pPatternString,
                                     int pMatchingOperation,
                                     boolean pIgnoreCase,
                                     boolean pEscapeWildcards)
                              throws RepositoryException
Creates a query representing a pattern matching operation. It may be case-sensitive or case-insensitvie. pMatchingOperation must be one of:

Be advised that STARTS_WITH and EQUALS queries can be optimized easily using DB indexes. The other pattern match queries generally cannot be. Likewise case-insensitive pattern matching may affect the ability of the database to optimize the query.

Parameters:
pValueString - the string which is searched for the substring. This must have been created with createPropertyQueryExpression() or createConstantQueryExpression
pPatternString - the pattern to search for. This must have been created with createConstantQueryExpression
pMatchingOperation - the type of match to search for
pIgnoreCase - if false match is case-sensitive, if true match is case-insensitive
pEscapeWildcards - escape wildcards in search string
Throws:
RepositoryException - if there is an error building the query

createParameterPatternMatchQuery

public Query createParameterPatternMatchQuery(QueryExpression pValueString,
                                              atg.adapter.gsa.query.ParameterExpression pPatternString,
                                              int pMatchingOperation,
                                              boolean pIgnoreCase,
                                              boolean pEscapeWildcards)
                                       throws RepositoryException
Creates a case-sensitive query representing a pattern matching operation. pMatchingOperation must be once of:

Be advised that STARTS_WITH and EQUALS queries can be optimized easily using DB indexes. The other pattern match queries generally cannot be.

Parameters:
pValueString - the string which is searched for the substring. This must have been created with createPropertyQueryExpression() or createConstantQueryExpression
pPatternString - the pattern to search for. This must have been created with createParameterQueryExpression
pMatchingOperation - the type of match to search for
pIgnoreCase - if false match is case-sensitive, if true match is case-insensitive
Throws:
RepositoryException - if there is an error building the query

createTextSearchQuery

public 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.

Specified by:
createTextSearchQuery in interface QueryBuilder
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.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 is an error building the query

createTextSearchQuery

public 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.

Specified by:
createTextSearchQuery in interface QueryBuilder
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 is an error building the query

createParameterTextSearchQuery

protected Query createParameterTextSearchQuery(atg.adapter.gsa.query.PropertyExpression pProperty,
                                               atg.adapter.gsa.query.ParameterExpression pSearchString,
                                               java.lang.String pSearchStringFormat,
                                               atg.adapter.gsa.query.Value 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.
Throws:
RepositoryException - if there is an error building the query

createUnconstrainedQuery

public Query createUnconstrainedQuery()
Creates a query which when executed returns all of the items in the repository, Nota Bene: This is a potentially very expensive operation. Be sure that this is what you need to do before doing it.

Specified by:
createUnconstrainedQuery in interface QueryBuilder
Returns:
the potentially very expensive query

createElementAtQueryExpression

public 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.

Specified by:
createElementAtQueryExpression in interface QueryBuilder
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)
Returns:
the query
Throws:
RepositoryException - if there is an error building the query

createIndexOfQueryExpression

public 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

Specified by:
createIndexOfQueryExpression in interface QueryBuilder
Parameters:
pCollection - should evaluate into a collection
pItem - should evaluate into a value which will be looked for in the collection
Returns:
the query
Throws:
RepositoryException - if there is an error building the query

createIncludesQuery

public 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.

Specified by:
createIncludesQuery in interface QueryBuilder
Parameters:
pCollection - should evaluate into a collection
pItem - should evaluate into a value which will be looked for in the collection
Returns:
the query
Throws:
RepositoryException - if there is an error building the query

createIncludesAnyQuery

public 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.

Specified by:
createIncludesAnyQuery in interface QueryBuilder
Parameters:
pCollection1 - should evaluate into a collection
pCollection2 - should evaluate into a collection of values which will be looked for in the first collection
Returns:
the query
Throws:
RepositoryException - if there is an error building the query

createIncludesAllQuery

public 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.

Specified by:
createIncludesAllQuery in interface QueryBuilder
Parameters:
pCollection1 - should evaluate into a collection
pCollection2 - should evaluate into a collection of values which will be looked for in the first collection
Returns:
the query
Throws:
RepositoryException - if there is an error building the query

createIncludesItemQuery

public Query createIncludesItemQuery(QueryExpression pCollection,
                                     Query pQuery)
                              throws RepositoryException
Creates a query that is matched if the property, which must evaluate to a Collection, Map, or array of repository items, has at least one item which matches the query provided. This query should be created using the query builder for the repository view of the referenced collection, not the query builder for the original item.

Specified by:
createIncludesItemQuery in interface QueryBuilder
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 the query is invalid

createCountQueryExpression

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

Specified by:
createCountQueryExpression in interface QueryBuilder
Parameters:
pCollection - should evaluate into a collection of items which can be counted.
Returns:
the query
Throws:
RepositoryException - if there is an error building the query

createInFoldersQuery

public Query createInFoldersQuery(java.lang.String[] pFolderIds)
                           throws RepositoryException
Returns a query which when executed would return all the pieces of content which are contained within the supplied folders.

Specified by:
createInFoldersQuery in interface ContentQueryBuilder
Parameters:
pFolderIds - an array of ids which represent folders
Throws:
RepositoryException - if there was an error building the query operation

createInFoldersQuery

public Query createInFoldersQuery(atg.repository.CompositeKey[] pFolderIds)
                           throws RepositoryException
Returns a query which when executed would return all the pieces of content which are contained within the supplied folders.

Specified by:
createInFoldersQuery in interface atg.repository.CompositeIdQueryBuilder
Parameters:
pFolderIds - an array of ids which represent folders
Throws:
RepositoryException - if there was an error building the query operation

createSqlPassthroughQuery

public Query createSqlPassthroughQuery(java.lang.String pSqlString,
                                       java.lang.Object[] pArgs)
                                throws RepositoryException
Returns a query which when executed performs a query against the database with the specified SQL string, which overrides SQL string which would be used by the GSA to perform this query, or any query built using this query.

Caution: The repository cannot use the results of arbitrary queries to generate repository items. The query must return the ID column or columns in their declared order from the repository template. Sql passed to this method is not validated to check if it meets this requirement.

Parameters:
pSqlString - the SQL string to use
Throws:
RepositoryException - if there was an error building the query operation

createDirectSqlQuery

public Query createDirectSqlQuery(java.lang.String pQuery,
                                  RepositoryPropertyDescriptor[] pReturnedProps,
                                  RepositoryPropertyDescriptor[] pDependentProps,
                                  java.lang.Class[] pInputParameterClasses)
                           throws RepositoryException
This is a variation of the SqlPassThroughQuery that can call stored procedures as well as execute straight sql. Unlike the SqlPassThroughQuery, this query can preload property information if more than just the id property is selected. This is indicated by the pReturnedProps property. Also, these Queries can be cached and can have property dependencies like other queries

Parameters:
pQuery - the SQL string to execute
pReturnedProps - an array of property descriptors that are expected to be returned from the query when the SQL is executed. Note that this may or may not include an id property if one is defined for the view this Builder pertains to. Also note that the order that the properties appear in this array is the order that the associated columns for the properties must be returned. These properties must fit the following rules: 1) Must not be transient 2) Must not be multi-valued 3) Must be readable
pDependentProps - an array of property descriptors that this query will depend upon for caching. So if any of these properties change for a given item that is returned from this query, it will be removed from the query cache
pInputParameterClasses - an array of Classes that correspond to the types of the input parameters in this query, if any. The first element in the array maps to the first input parameter in the query, and so on
Returns:
a query that executes straight sql
Throws:
a - RepositoryException if the arguments are incorrect
RepositoryException

createDirectSqlQuery

public Query createDirectSqlQuery(java.lang.String pQuery,
                                  RepositoryPropertyDescriptor[] pReturnedProps,
                                  RepositoryPropertyDescriptor[] pDependentProps,
                                  java.lang.Class[] pInputParameterClasses,
                                  boolean pIsStoredProcedure)
                           throws RepositoryException
This is a variation of the SqlPassThroughQuery that can call stored procedures as well as execute straight sql. Unlike the SqlPassThroughQuery, this query can preload property information if more than just the id property is selected. This is indicated by the pReturnedProps property. Also, these Queries can be cached and can have property dependencies like other queries

Parameters:
pQuery - the SQL string to execute
pReturnedProps - an array of property descriptors that are expected to be returned from the query when the SQL is executed. Note that this may or may not include an id property if one is defined for the view this Builder pertains to. Also note that the order that the properties appear in this array is the order that the associated columns for the properties must be returned, if pStrictOrdering is true. These properties must fit the following rules: 1) Must not be transient 2) Must not be multi-valued 3) Must be readable
pDependentProps - an array of property descriptors that this query will depend upon for caching. So if any of these properties change for a given item that is returned from this query, it will be removed from the query cache
pInputParameterClasses - an array of Classes that correspond to the types of the input parameters in this query, if any. The first element in the array maps to the first input parameter in the query, and so on
pIsStoredProcedure - if this is true, then the pQuery string is assumed to be a call to a stored procedure. A JDBC CallableStatement will be used to issue this SQL, so users must make sure that these calls are escaped properly. Usually this means that calls must be enclosed by curly braces '{}' e.g. {call myprocedure}. If this is false, then it's assumed that a regular sql statement is being passed in. NOTE: When using a stored procedure, the expected return value is a valid single ResultSet
Returns:
a query that executes straight sql
Throws:
a - RepositoryException if the arguments are incorrect
RepositoryException

constantQuery

protected Query constantQuery(boolean pValue)
Utility routine for generating a query which always evaluates to true or false.


format

public java.lang.String format(java.lang.String pMsgKey,
                               java.lang.Object[] pArgs)
Utility for formatting predefined messages using our respository's resource bundle. Pass through to item descriptor.

Parameters:
pMsgKey - message id to format
pArgs - arguments to fill in in message

format

public java.lang.String format(java.lang.String pMsgKey)
Utility for formatting messages with no arguments.


format

public java.lang.String format(java.lang.String pMsgKey,
                               java.lang.Object pArg)

format

public java.lang.String format(java.lang.String pMsgKey,
                               java.lang.Object pArg1,
                               java.lang.Object pArg2)

toString

public java.lang.String toString()
Get a string representation of this object

Overrides:
toString in class java.lang.Object

rebuild

public Query rebuild(Query pQuery,
                     atg.repository.dp.TranslationContext pContext)
              throws RepositoryException
Rebuild the specified query using the specified query builder.

Specified by:
rebuild in interface atg.repository.dp.DerivedPropertyQueryBuilder
Parameters:
pQuery - the query to rebuild, which must have been built by this query builder
pContext - translation context to use for this rebuild
Returns:
the query equivalent to pQuery only built entirely by pBuilder
Throws:
RepositoryException - if pQuery is invalid or could not be built

getLogger

public ApplicationLogging getLogger()
Get a logger to use for derived property related errors and debug messages.

Specified by:
getLogger in interface atg.repository.dp.DerivedPropertyQueryBuilder
Returns:
the logger for our repository