atg.commerce.csr.search
Class RepositorySearcher

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.logging.ApplicationLoggingImpl
          extended by atg.commerce.csr.search.RepositorySearcher
All Implemented Interfaces:
atg.nucleus.logging.ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging

public class RepositorySearcher
extends atg.nucleus.logging.ApplicationLoggingImpl

This class encapsulates some generic searching functionality to be used by repository searchers, such as SearchFormHandler, and its subclasses. This class' job is to build search queries and manage attributes and properties.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
protected static java.lang.String SEARCHRESOURCES
           
protected static java.util.ResourceBundle sResourceBundle
           
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
RepositorySearcher()
           
 
Method Summary
 atg.repository.Query createAndQuery(atg.repository.Query[] pAndableQueries, atg.repository.Repository pRepository, java.lang.String pViewName)
          Return the query that should be executed on the Repository View.
protected  java.lang.String formatSearchString(java.lang.String pSearchString, java.lang.String pFormatString)
          Return a formatted text search string based on the input pSearchString and pFormatString.
protected  atg.repository.Query generateAdvancedSearchQuery(SearchAttribute pAttribute, atg.repository.QueryBuilder pQueryBuilder, atg.repository.RepositoryView pView)
          Return a query which represents an advanced search based on selected property values.
protected  atg.repository.Query generateKeywordSearchQuery(SearchAttribute pSearchAttribute, atg.repository.QueryBuilder pQueryBuilder, atg.repository.RepositoryView pView)
          Return a query which represents a keyword search.
 atg.repository.Query generateSearchQuery(SearchAttribute[] pSearchAttributes, atg.repository.Repository pSearchRepository, java.lang.String pViewName, java.util.Locale locale)
          Return the query that should be executed on the Repository View.
 java.util.Collection<atg.repository.RepositoryItem> generateSearchResult(atg.repository.Query pQuery, atg.repository.QueryOptions pQueryOptions, atg.repository.Repository pSearchRepository, java.lang.String pViewName)
           
 int generateSearchResultCount(atg.repository.Query pQuery, atg.repository.Repository pSearchRepository, java.lang.String pViewName)
           
protected  atg.repository.Query generateSingleKeywordQuery(atg.repository.QueryBuilder pQueryBuilder, java.lang.String pPropertyName, java.lang.String[] pKeywords, atg.repository.RepositoryView pView, boolean pIgnorecase)
          Return a query for the given property name against the set of supplied keywords.
protected  atg.repository.Query generateSubQuery(SearchAttribute pSearchAttribute, atg.repository.QueryBuilder pQueryBuilder, atg.repository.RepositoryView pView)
          generate subquery using RQL
protected  atg.repository.Query generateSubtypeQuery(SearchAttribute pSearchAttribute, atg.repository.QueryBuilder pQueryBuilder, atg.repository.RepositoryView pView, atg.repository.Repository pRepository)
          This method build query on subtype item properties.
protected  atg.repository.Query generateTextSearchQuery(SearchAttribute pAttribute, atg.repository.QueryBuilder pQueryBuilder, atg.repository.RepositoryView pView)
          Return a query which represents a text search query.
protected  atg.repository.Query generateValueSearchQuery(SearchAttribute pAttribute, atg.repository.QueryBuilder pQueryBuilder, atg.repository.RepositoryView pView, java.util.Locale locale)
          Based on the input SearchAttribute value, this method constructs an appropriate comparison Query.
 java.lang.String getLoggingIdentifier()
          Returns property LoggingIdentifier
 java.lang.Integer getMinScore()
          Returns property MinScore
protected  java.lang.String[] getMutiPropertyName(SearchAttribute pSearchAttribute)
           
protected  java.beans.PropertyEditor getPropertyEditor(java.lang.String displayName, atg.repository.RepositoryView pView)
          given a display name for a property looks up and returns the property type
protected  java.lang.String getPropertyName(java.lang.String displayName, atg.repository.RepositoryView pView)
          given a display name for a property looks up and returns the real name
 atg.repository.QueryBuilder getQueryBuilder(atg.repository.RepositoryView pView)
          Returns a QueryBuilder based on the Repository's View
protected  atg.repository.RepositoryItemDescriptor getRepositoryItemDescriptor(atg.repository.RepositoryView pView)
          Returns the item descriptor for the repository
 atg.repository.RepositoryView getRepositoryView(atg.repository.Repository pRepository, java.lang.String pViewName)
          Returns the repository view for the repository
protected  java.lang.Object getSearchAttributeValue(SearchAttribute pAttribute, atg.repository.RepositoryView pView, java.util.Locale locale)
          Based on the set SearchAttribute returns that property value
 java.lang.String getSearchStringFormat()
          Returns property SearchStringFormat
 java.lang.String getTextSearchStringFormat()
          Returns property mTextSearchStringFormat
 boolean getTrimString()
          Returns property TrimString
protected  void init()
           
 void setLoggingIdentifier(java.lang.String pLoggingIdentifier)
          Sets property LoggingIdentifier
 void setMinScore(java.lang.Integer pMinScore)
          Sets property MinScore
 void setSearchStringFormat(java.lang.String pSearchStringFormat)
          Sets property SearchStringFormat
 void setTextSearchStringFormat(java.lang.String pTextSearchStringFormat)
          Sets property mTextSearchStringFormat
 void setTrimString(boolean pTrimString)
          Sets property TrimString
 
Methods inherited from class atg.nucleus.logging.ApplicationLoggingImpl
addGlobalLogListeners, addLogListener, getLoggingForVlogging, getLoggingIdentifer, getLogListenerCount, getLogListeners, initializeFromServiceEvent, isAutoInitListeners, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, removeLogListener, sendLogEvent, setAutoInitListeners, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

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

See Also:
Constant Field Values

SEARCHRESOURCES

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

sResourceBundle

protected static final java.util.ResourceBundle sResourceBundle
Constructor Detail

RepositorySearcher

public RepositorySearcher()
Method Detail

setLoggingIdentifier

public void setLoggingIdentifier(java.lang.String pLoggingIdentifier)
Sets property LoggingIdentifier

Overrides:
setLoggingIdentifier in class atg.nucleus.logging.ApplicationLoggingImpl
Parameters:
pLoggingIdentifier - the property which identifies this object as the Repository Search.

getLoggingIdentifier

public java.lang.String getLoggingIdentifier()
Returns property LoggingIdentifier

Overrides:
getLoggingIdentifier in class atg.nucleus.logging.ApplicationLoggingImpl
Returns:
The value of the property LoggingIdentifier.

setSearchStringFormat

public void setSearchStringFormat(java.lang.String pSearchStringFormat)
Sets property SearchStringFormat

Parameters:
pSearchStringFormat - the property to store any string formatting information parameters for searching.

getSearchStringFormat

public java.lang.String getSearchStringFormat()
Returns property SearchStringFormat

Returns:
The value of the property SearchStringFormat.

setTextSearchStringFormat

public void setTextSearchStringFormat(java.lang.String pTextSearchStringFormat)
Sets property mTextSearchStringFormat

Parameters:
pTextSearchStringFormat - the property to store any string formatting parameters for text searching. # such as fussy, soundex, .......

getTextSearchStringFormat

public java.lang.String getTextSearchStringFormat()
Returns property mTextSearchStringFormat

Returns:
The value of the property mTextSearchStringFormat.

setTrimString

public void setTrimString(boolean pTrimString)
Sets property TrimString

Parameters:
pTrimString - the property to store the flag to trim strings or not.

getTrimString

public boolean getTrimString()
Returns property TrimString

Returns:
The value of the property TrimString

setMinScore

public void setMinScore(java.lang.Integer pMinScore)
Sets property MinScore

Parameters:
pMinScore - the property to store the minimum scoring used for text searching.

getMinScore

public java.lang.Integer getMinScore()
Returns property MinScore

Returns:
The value of the property MinScore

init

protected void init()

getRepositoryView

public atg.repository.RepositoryView getRepositoryView(atg.repository.Repository pRepository,
                                                       java.lang.String pViewName)
                                                throws atg.repository.RepositoryException
Returns the repository view for the repository

Returns:
repository view
Throws:
atg.repository.RepositoryException

getRepositoryItemDescriptor

protected atg.repository.RepositoryItemDescriptor getRepositoryItemDescriptor(atg.repository.RepositoryView pView)
                                                                       throws atg.repository.RepositoryException
Returns the item descriptor for the repository

Returns:
repository item descriptor
Throws:
atg.repository.RepositoryException

getQueryBuilder

public atg.repository.QueryBuilder getQueryBuilder(atg.repository.RepositoryView pView)
                                            throws atg.repository.RepositoryException
Returns a QueryBuilder based on the Repository's View

Returns:
QueryBuilder instance
Throws:
atg.repository.RepositoryException

getPropertyName

protected java.lang.String getPropertyName(java.lang.String displayName,
                                           atg.repository.RepositoryView pView)
given a display name for a property looks up and returns the real name

Parameters:
displayName -
Returns:
realName

getPropertyEditor

protected java.beans.PropertyEditor getPropertyEditor(java.lang.String displayName,
                                                      atg.repository.RepositoryView pView)
given a display name for a property looks up and returns the property type

Parameters:
displayName -
Returns:
the property type

getMutiPropertyName

protected java.lang.String[] getMutiPropertyName(SearchAttribute pSearchAttribute)
Parameters:
pSearchAttribute -

createAndQuery

public atg.repository.Query createAndQuery(atg.repository.Query[] pAndableQueries,
                                           atg.repository.Repository pRepository,
                                           java.lang.String pViewName)
                                    throws atg.repository.RepositoryException
Return the query that should be executed on the Repository View. This method attempts to build its query from value, keyword, text, advanced, and wildcard search subqueries. It calls each sub method to build the sub query. The method attempts to build an AND query only

Throws:
atg.repository.RepositoryException - if an error occured while forming the query

generateSearchQuery

public atg.repository.Query generateSearchQuery(SearchAttribute[] pSearchAttributes,
                                                atg.repository.Repository pSearchRepository,
                                                java.lang.String pViewName,
                                                java.util.Locale locale)
                                         throws atg.repository.RepositoryException
Return the query that should be executed on the Repository View. This method attempts to build its query from value, keyword, text, advanced, and wildcard search subqueries. It calls each sub method to build the sub query. The method attempts to build an AND query only

Parameters:
pSearchAttributes -
Throws:
atg.repository.RepositoryException - if an error occured while forming the query

generateSearchResult

public java.util.Collection<atg.repository.RepositoryItem> generateSearchResult(atg.repository.Query pQuery,
                                                                                atg.repository.QueryOptions pQueryOptions,
                                                                                atg.repository.Repository pSearchRepository,
                                                                                java.lang.String pViewName)
                                                                         throws atg.repository.RepositoryException
Parameters:
pQuery - the search query to execute.
pQueryOptions -
Returns:
null if no items could be found
Throws:
atg.repository.RepositoryException

generateSearchResultCount

public int generateSearchResultCount(atg.repository.Query pQuery,
                                     atg.repository.Repository pSearchRepository,
                                     java.lang.String pViewName)
                              throws atg.repository.RepositoryException
Parameters:
pQuery - the search query to execute.
pSearchRepository -
pViewName -
Returns:
null if no items could be found
Throws:
atg.repository.RepositoryException

getSearchAttributeValue

protected java.lang.Object getSearchAttributeValue(SearchAttribute pAttribute,
                                                   atg.repository.RepositoryView pView,
                                                   java.util.Locale locale)
                                            throws java.lang.IllegalArgumentException,
                                                   atg.repository.RepositoryException
Based on the set SearchAttribute returns that property value

Returns:
propertyValue
Throws:
java.lang.IllegalArgumentException
atg.repository.RepositoryException

generateValueSearchQuery

protected atg.repository.Query generateValueSearchQuery(SearchAttribute pAttribute,
                                                        atg.repository.QueryBuilder pQueryBuilder,
                                                        atg.repository.RepositoryView pView,
                                                        java.util.Locale locale)
                                                 throws atg.repository.RepositoryException
Based on the input SearchAttribute value, this method constructs an appropriate comparison Query.

Parameters:
pQueryBuilder - a query builder with which to construct the query
pAttribute -
pView -
Returns:
Query instance
Throws:
atg.repository.RepositoryException - if an error occured while forming the query

generateTextSearchQuery

protected atg.repository.Query generateTextSearchQuery(SearchAttribute pAttribute,
                                                       atg.repository.QueryBuilder pQueryBuilder,
                                                       atg.repository.RepositoryView pView)
                                                throws atg.repository.RepositoryException
Return a query which represents a text search query. This method builds a sub-query for the attribute named in the input SearchAttribute.mName property. The search string format is configured with the searchStringFormat property.

Parameters:
pAttribute - the SearchAttribute object
pQueryBuilder - the builder that should be used to construct the query
pView -
Returns:
Query instance
Throws:
atg.repository.RepositoryException - if an error occured while forming the query

formatSearchString

protected java.lang.String formatSearchString(java.lang.String pSearchString,
                                              java.lang.String pFormatString)
Return a formatted text search string based on the input pSearchString and pFormatString.

Parameters:
pSearchString - the String object
pFormatString -
Returns:
formated text search string

generateAdvancedSearchQuery

protected atg.repository.Query generateAdvancedSearchQuery(SearchAttribute pAttribute,
                                                           atg.repository.QueryBuilder pQueryBuilder,
                                                           atg.repository.RepositoryView pView)
                                                    throws atg.repository.RepositoryException
Return a query which represents an advanced search based on selected property values. This method builds a sub-query for the property found in SearchAttribute.mName attribute.

Parameters:
pAttribute - SearchAttribute object
pQueryBuilder - the builder that should be used to construct the query
pView - the RepositoryView
Returns:
Query instance
Throws:
atg.repository.RepositoryException - if an error occured while forming the query

generateKeywordSearchQuery

protected atg.repository.Query generateKeywordSearchQuery(SearchAttribute pSearchAttribute,
                                                          atg.repository.QueryBuilder pQueryBuilder,
                                                          atg.repository.RepositoryView pView)
                                                   throws atg.repository.RepositoryException
Return a query which represents a keyword search. This method builds a sub-query for each attribute named in the SearchAttribute mName property. Each sub-query is OR'd together to form the total query. If the attribute named is of a Collection or array type, then an "includes any" query is formed. Single-value attributes use a EQUALS comparison query.

Parameters:
pSearchAttribute -
pQueryBuilder - the builder that should be used to construct the query
pView - the RepositoryView
Returns:
Query instance
Throws:
atg.repository.RepositoryException - if an error occurred while forming the query

generateSingleKeywordQuery

protected atg.repository.Query generateSingleKeywordQuery(atg.repository.QueryBuilder pQueryBuilder,
                                                          java.lang.String pPropertyName,
                                                          java.lang.String[] pKeywords,
                                                          atg.repository.RepositoryView pView,
                                                          boolean pIgnorecase)
                                                   throws atg.repository.RepositoryException
Return a query for the given property name against the set of supplied keywords. If the data type of the property is multi-value, then build an "includes any" query. Otherwise OR together a pattern match STARTS_WITH query, while ignoring case, for each keyword value and property combination.

Parameters:
pQueryBuilder - the builder that should be used to construct the query
pPropertyName -
pKeywords - the set of words that the user has entered as search criteria
pView - the RepositoryView.
pIgnorecase -
Returns:
Query instance
Throws:
atg.repository.RepositoryException - if an error occurred while forming the query

generateSubQuery

protected atg.repository.Query generateSubQuery(SearchAttribute pSearchAttribute,
                                                atg.repository.QueryBuilder pQueryBuilder,
                                                atg.repository.RepositoryView pView)
                                         throws atg.repository.RepositoryException
generate subquery using RQL

Parameters:
pSearchAttribute -
pQueryBuilder - the builder that should be used to construct the query
pView - the RepositoryView
Returns:
Query instance
Throws:
atg.repository.RepositoryException - if an error occurred while forming the query

generateSubtypeQuery

protected atg.repository.Query generateSubtypeQuery(SearchAttribute pSearchAttribute,
                                                    atg.repository.QueryBuilder pQueryBuilder,
                                                    atg.repository.RepositoryView pView,
                                                    atg.repository.Repository pRepository)
                                             throws atg.repository.RepositoryException
This method build query on subtype item properties.

Parameters:
pSearchAttribute -
pQueryBuilder - the builder that should be used to construct the query
pView -
pRepository -
Returns:
Query instance
Throws:
atg.repository.RepositoryException - if an error occured while forming the query