atg.repository.search.refinement
Class FacetSearchTools

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.repository.search.refinement.FacetSearchTools
All Implemented Interfaces:
atg.naming.AbsoluteNameable, NameContextBindingListener, NameContextElement, atg.naming.NameContextParentable, NameResolver, AdminableService, atg.nucleus.Configured, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, SearchRedirectProcessor, SearchRequestProcessor, SearchResponseProcessor, java.util.EventListener
Direct Known Subclasses:
CommerceFacetSearchTools

public class FacetSearchTools
extends GenericService
implements SearchRequestProcessor, SearchResponseProcessor, SearchRedirectProcessor

Processor for search requests to handle refinements. This component will amend the search request to add refinement properties and constraints.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
protected static java.lang.String DOLLAR_MAP
           
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
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
FacetSearchTools()
          Constructs an instanceof FacetSearchTools
 
Method Summary
protected  boolean containsConstraint(DocumentSetConstraint pConstraint, ConstraintsGroup pGroup)
          test to see if a given constraint exists in a constraint group
protected  FacetValue convertRefineValue(atg.repository.search.refinement.RefinementFacet pRefineFacet, RefinementValue pRefineValue, boolean pIsLastValue)
          Converts a RefinementValue object to a FacetValue object
protected  DocumentSetConstraint createConstraint(java.lang.String pCatalogId, java.lang.String pFormat)
           
protected  DocumentSetConstraint createConstraints(java.lang.String[] pCatalogIds, java.lang.String pFormat, BooleanExpressionType pBooleanExpressionType)
           
 DocumentSetConstraint createDocSetConstraint(java.lang.String pDocSetPath, QueryRequest pRequest)
          create the docset constraint from the facet trail
 DocumentSetConstraint createFacetDocSetConstraint(FacetTrail pTrail)
          create the docset constrain using the facet trail and any additional constraints
 DocumentSetConstraint createFacetDocSetConstraint(FacetTrail pTrail, boolean pIsCatNav)
          create the docset constrain using the facet trail and any additional constraints
 FacetTrail createFacetTrail(java.lang.String pTrailString)
          create a facet trail with no refine config
 FacetTrail createFacetTrail(java.lang.String pTrailString, RefinementConfiguration pRefineConfig)
          turn a facet trail string into a facet trail object
 FacetTrail createFacetTrail(java.lang.String pTrailString, RepositoryItem pRefineConfig)
          create a facet trail with a refinement configuration object
 QueryRequest createQueryRequest()
          create a new query request with default values set
 atg.search.client.SearchSession createSession()
          create a session
 java.lang.String determineCommerceRefineConfigName(FacetTrail pTrail, QueryRequest pRequest)
          determineCommerceRefineConfigName
 java.lang.String determineDocSetPath(FacetTrail pTrail, QueryRequest pRequest)
          get the docset path to use for a category navigation query
 java.lang.String determineQuestionText(FacetTrail pTrail, QueryRequest pRequest)
          get the question text for the query request
 java.lang.String determineRefineConfigMap(FacetTrail pTrail, QueryRequest pRequest)
          get the refine config map property name
 java.lang.String determineRefineConfigName(FacetTrail pTrail, QueryRequest pRequest)
          determine the refine config name
protected  java.lang.String escapeAsterisk(java.lang.String pString)
          remove asterisks from range values
 java.lang.String[] getAdditionalConstraints()
          get any additional constraints
 java.lang.String[] getAdditionalConstraints(QueryRequest pRequest)
          get any additional constraints
 FacetHolder[] getAllFacets()
          This method gets the array of all facets INCLUDING ineligible ones returned by the search engine.
protected  FacetTrail getCurrentFacetTrail(DynamoHttpServletRequest pDynamoRequest, java.lang.Object pCallback)
          get the current facet trail
 int getDefaultFacetPriority()
           
 FacetManager getFacetManager()
           
 FacetHolder[] getFacets()
          This method gets the array of eligible facets ordered by facet priority.
 java.lang.String getFacetTrail()
           
 FacetTrailTools getFacetTrailTools()
           
 long getMinMatchingDocsCount()
          get MinMatchingDocsCount
 QueryRequest getQueryRequest()
           
 java.lang.String getRedirect(SearchResponse pSearchResponse)
          if a redirect is required, get the url to redirect to
 java.lang.String getRefineConfig()
           
 RefineConfigXMLGenerator getRefineConfigXMLGenerator()
           
 SearchClient getSearchClient()
           
 SearchRequest getSearchRequest()
           
 boolean getTestingMode()
           
 boolean handleAutoRedirect(SearchResponse pSearchResponse, DynamoHttpServletRequest pDynamoRequest, java.lang.Object pCallback)
          process redirect
protected  boolean isCategoryFacet(FacetValue pValue)
          test to see if a given facet value is actually a category facet value.
protected  boolean isEligibleFacetValue(FacetTrail pFacetTrail, FacetValue pFacetValue)
          Determines whether the given facet value is eligible for inclusion in the list of facet values.
 boolean isIncludeOverflowAndUnderflowRangeValues()
           
 boolean isSkipValuesAlreadyInTrail()
           
 ConstraintsGroup mergeConstraints(ConstraintsGroup pNewConstraints, DocumentSetConstraint pOldConstraints)
          merge old and new constraints
 QueryRequest processFacetTrail(FacetTrail pTrail, QueryRequest pRequest)
          process a facet trail into the query request
 QueryRequest processFacetTrail(FacetTrail pTrail, QueryRequest pRequest, boolean pIsCategoryNavigation)
          process a facet trail into the query request
 SearchRequest processSearchRequest(SearchRequest pSearchRequest, DynamoHttpServletRequest pDynamoRequest, java.lang.Object pCallback)
          process search request
 SearchResponse processSearchResponse(SearchResponse pSearchResponse, DynamoHttpServletRequest pDynamoRequest, java.lang.Object pCallback)
          process search response
protected  void removeAncestorCategoriesFromFacetValues(java.util.List<FacetValue> facetValuesList)
           
 QueryRequest.Response search(FacetTrail pTrail)
          perform a search and all the steps involved with setting up the search
 QueryRequest.Response search(QueryRequest pRequest, atg.search.client.SearchSession pSession)
          perform just a search, assumes a prepared QueryRequest with all the facet work already done
 QueryRequest.Response search(java.lang.String pTrailString)
          perform a search with a facet trial string
 void setAllFacets(FacetHolder[] pAllFacets)
           
 void setDefaultFacetPriority(int pDefaultFacetPriority)
           
 void setFacetManager(FacetManager pFacetManager)
           
 void setFacets(FacetHolder[] pFacets)
           
 void setFacetTrail(java.lang.String pFacetTrail)
           
 void setFacetTrailTools(FacetTrailTools pFacetTrailTools)
           
 void setIncludeOverflowAndUnderflowRangeValues(boolean pIncludeOverflowAndUnderflowRangeValues)
           
 void setMinMatchingDocsCount(long pMinMatchingDocsCount)
          set MinMatchingDocsCount
 void setQueryRequest(QueryRequest pQueryRequest)
           
 void setRefineConfig(java.lang.String pRefineConfig)
           
 void setRefineConfigXMLGenerator(RefineConfigXMLGenerator pRefineConfigXMLGenerator)
           
 void setSearchClient(SearchClient pSearchClient)
           
 void setSearchRequest(SearchRequest pSearchRequest)
           
 void setSkipValuesAlreadyInTrail(boolean pSkipValuesAlreadyInTrail)
           
 void setTestingMode(boolean pTestingMode)
           
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
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 java.lang.String CLASS_VERSION
Class version string


DOLLAR_MAP

protected static final java.lang.String DOLLAR_MAP
See Also:
Constant Field Values
Constructor Detail

FacetSearchTools

public FacetSearchTools()
Constructs an instanceof FacetSearchTools

Method Detail

setFacetManager

public void setFacetManager(FacetManager pFacetManager)

getFacetManager

public FacetManager getFacetManager()

setSearchClient

public void setSearchClient(SearchClient pSearchClient)

getSearchClient

public SearchClient getSearchClient()

setFacetTrailTools

public void setFacetTrailTools(FacetTrailTools pFacetTrailTools)

getFacetTrailTools

public FacetTrailTools getFacetTrailTools()

setQueryRequest

public void setQueryRequest(QueryRequest pQueryRequest)

getQueryRequest

public QueryRequest getQueryRequest()

setSearchRequest

public void setSearchRequest(SearchRequest pSearchRequest)

getSearchRequest

public SearchRequest getSearchRequest()

setFacets

public void setFacets(FacetHolder[] pFacets)

getFacets

public FacetHolder[] getFacets()
This method gets the array of eligible facets ordered by facet priority. It is this method that a site should use to display facets returned by search.

Returns:
array of FacetHolder

setAllFacets

public void setAllFacets(FacetHolder[] pAllFacets)

getAllFacets

public FacetHolder[] getAllFacets()
This method gets the array of all facets INCLUDING ineligible ones returned by the search engine. The array is in the same order as returned by search, i.e. it is NOT order in facet priority.

Returns:
array of FacetHolder

setSkipValuesAlreadyInTrail

public void setSkipValuesAlreadyInTrail(boolean pSkipValuesAlreadyInTrail)

isSkipValuesAlreadyInTrail

public boolean isSkipValuesAlreadyInTrail()

setDefaultFacetPriority

public void setDefaultFacetPriority(int pDefaultFacetPriority)

getDefaultFacetPriority

public int getDefaultFacetPriority()

setFacetTrail

public void setFacetTrail(java.lang.String pFacetTrail)

getFacetTrail

public java.lang.String getFacetTrail()

setRefineConfig

public void setRefineConfig(java.lang.String pRefineConfig)

getRefineConfig

public java.lang.String getRefineConfig()

setTestingMode

public void setTestingMode(boolean pTestingMode)

getTestingMode

public boolean getTestingMode()

setRefineConfigXMLGenerator

public void setRefineConfigXMLGenerator(RefineConfigXMLGenerator pRefineConfigXMLGenerator)

getRefineConfigXMLGenerator

public RefineConfigXMLGenerator getRefineConfigXMLGenerator()

setIncludeOverflowAndUnderflowRangeValues

public void setIncludeOverflowAndUnderflowRangeValues(boolean pIncludeOverflowAndUnderflowRangeValues)

isIncludeOverflowAndUnderflowRangeValues

public boolean isIncludeOverflowAndUnderflowRangeValues()

setMinMatchingDocsCount

public void setMinMatchingDocsCount(long pMinMatchingDocsCount)
set MinMatchingDocsCount

Parameters:
pMinMatchingDocsCount - the MinMatchingDocsCount

getMinMatchingDocsCount

public long getMinMatchingDocsCount()
get MinMatchingDocsCount

Returns:
the MinMatchingDocsCount

createSession

public atg.search.client.SearchSession createSession()
                                              throws atg.repository.search.refinement.FacetException
create a session

Throws:
atg.repository.search.refinement.FacetException

createFacetTrail

public FacetTrail createFacetTrail(java.lang.String pTrailString)
                            throws atg.repository.search.refinement.FacetException
create a facet trail with no refine config

Throws:
atg.repository.search.refinement.FacetException

createFacetTrail

public FacetTrail createFacetTrail(java.lang.String pTrailString,
                                   RepositoryItem pRefineConfig)
                            throws atg.repository.search.refinement.FacetException
create a facet trail with a refinement configuration object

Throws:
atg.repository.search.refinement.FacetException

createFacetTrail

public FacetTrail createFacetTrail(java.lang.String pTrailString,
                                   RefinementConfiguration pRefineConfig)
                            throws atg.repository.search.refinement.FacetException
turn a facet trail string into a facet trail object

Throws:
atg.repository.search.refinement.FacetException

processFacetTrail

public QueryRequest processFacetTrail(FacetTrail pTrail,
                                      QueryRequest pRequest)
process a facet trail into the query request


processFacetTrail

public QueryRequest processFacetTrail(FacetTrail pTrail,
                                      QueryRequest pRequest,
                                      boolean pIsCategoryNavigation)
process a facet trail into the query request


createQueryRequest

public QueryRequest createQueryRequest()
create a new query request with default values set


determineRefineConfigName

public java.lang.String determineRefineConfigName(FacetTrail pTrail,
                                                  QueryRequest pRequest)
determine the refine config name


determineCommerceRefineConfigName

public java.lang.String determineCommerceRefineConfigName(FacetTrail pTrail,
                                                          QueryRequest pRequest)
determineCommerceRefineConfigName


determineRefineConfigMap

public java.lang.String determineRefineConfigMap(FacetTrail pTrail,
                                                 QueryRequest pRequest)
get the refine config map property name


determineQuestionText

public java.lang.String determineQuestionText(FacetTrail pTrail,
                                              QueryRequest pRequest)
get the question text for the query request


determineDocSetPath

public java.lang.String determineDocSetPath(FacetTrail pTrail,
                                            QueryRequest pRequest)
get the docset path to use for a category navigation query


createDocSetConstraint

public DocumentSetConstraint createDocSetConstraint(java.lang.String pDocSetPath,
                                                    QueryRequest pRequest)
create the docset constraint from the facet trail


mergeConstraints

public ConstraintsGroup mergeConstraints(ConstraintsGroup pNewConstraints,
                                         DocumentSetConstraint pOldConstraints)
merge old and new constraints


containsConstraint

protected boolean containsConstraint(DocumentSetConstraint pConstraint,
                                     ConstraintsGroup pGroup)
test to see if a given constraint exists in a constraint group


createFacetDocSetConstraint

public DocumentSetConstraint createFacetDocSetConstraint(FacetTrail pTrail)
create the docset constrain using the facet trail and any additional constraints


createFacetDocSetConstraint

public DocumentSetConstraint createFacetDocSetConstraint(FacetTrail pTrail,
                                                         boolean pIsCatNav)
create the docset constrain using the facet trail and any additional constraints


removeAncestorCategoriesFromFacetValues

protected void removeAncestorCategoriesFromFacetValues(java.util.List<FacetValue> facetValuesList)
                                                throws atg.repository.search.refinement.FacetException
Parameters:
facetValuesList -
Throws:
FacetException

createConstraint

protected DocumentSetConstraint createConstraint(java.lang.String pCatalogId,
                                                 java.lang.String pFormat)
Parameters:
pCatalogId -
pFormat -
Returns:

createConstraints

protected DocumentSetConstraint createConstraints(java.lang.String[] pCatalogIds,
                                                  java.lang.String pFormat,
                                                  BooleanExpressionType pBooleanExpressionType)
Parameters:
pCatalogIds -
pFormat -
pBooleanExpressionType -
Returns:

isCategoryFacet

protected boolean isCategoryFacet(FacetValue pValue)
test to see if a given facet value is actually a category facet value. We can't do a simple instanceof check since the CategoryFacetValue class is in DCS, and we're not. instead. A subclass of this class in DCS should override this method with the instanceof check


getAdditionalConstraints

public java.lang.String[] getAdditionalConstraints()
get any additional constraints


getAdditionalConstraints

public java.lang.String[] getAdditionalConstraints(QueryRequest pRequest)
get any additional constraints


search

public QueryRequest.Response search(FacetTrail pTrail)
                             throws atg.repository.search.refinement.FacetException
perform a search and all the steps involved with setting up the search

Throws:
atg.repository.search.refinement.FacetException

search

public QueryRequest.Response search(java.lang.String pTrailString)
                             throws atg.repository.search.refinement.FacetException
perform a search with a facet trial string

Throws:
atg.repository.search.refinement.FacetException

search

public QueryRequest.Response search(QueryRequest pRequest,
                                    atg.search.client.SearchSession pSession)
                             throws atg.search.client.SearchClientException
perform just a search, assumes a prepared QueryRequest with all the facet work already done

Throws:
atg.search.client.SearchClientException

escapeAsterisk

protected java.lang.String escapeAsterisk(java.lang.String pString)
remove asterisks from range values


getCurrentFacetTrail

protected FacetTrail getCurrentFacetTrail(DynamoHttpServletRequest pDynamoRequest,
                                          java.lang.Object pCallback)
                                   throws atg.repository.search.refinement.FacetException
get the current facet trail

Throws:
atg.repository.search.refinement.FacetException

processSearchRequest

public SearchRequest processSearchRequest(SearchRequest pSearchRequest,
                                          DynamoHttpServletRequest pDynamoRequest,
                                          java.lang.Object pCallback)
                                   throws atg.search.client.SearchClientException
process search request

Specified by:
processSearchRequest in interface SearchRequestProcessor
Parameters:
pSearchRequest - the search request object
pDynamoRequest - the dynamo request
pCallback - the form handler component that called this method
Throws:
atg.search.client.SearchClientException

processSearchResponse

public SearchResponse processSearchResponse(SearchResponse pSearchResponse,
                                            DynamoHttpServletRequest pDynamoRequest,
                                            java.lang.Object pCallback)
                                     throws atg.search.client.SearchClientException
process search response

Specified by:
processSearchResponse in interface SearchResponseProcessor
Parameters:
pSearchResponse - the search response object
pDynamoRequest - the dynamo request
pCallback - the form handler component that called this method
Returns:
the search response
Throws:
atg.search.client.SearchClientException

handleAutoRedirect

public boolean handleAutoRedirect(SearchResponse pSearchResponse,
                                  DynamoHttpServletRequest pDynamoRequest,
                                  java.lang.Object pCallback)
                           throws atg.search.client.SearchClientException
process redirect

Specified by:
handleAutoRedirect in interface SearchRedirectProcessor
Parameters:
pSearchResponse - the search response object
pDynamoRequest - the dynamo request
pCallback - the form handler component that called this method
Returns:
false to allow form handling to continue since we aren't redirecting
Throws:
atg.search.client.SearchClientException

getRedirect

public java.lang.String getRedirect(SearchResponse pSearchResponse)
Description copied from interface: SearchRedirectProcessor
if a redirect is required, get the url to redirect to

Specified by:
getRedirect in interface SearchRedirectProcessor
Parameters:
pSearchResponse -
Returns:
the url that would be redirected to

convertRefineValue

protected FacetValue convertRefineValue(atg.repository.search.refinement.RefinementFacet pRefineFacet,
                                        RefinementValue pRefineValue,
                                        boolean pIsLastValue)
Converts a RefinementValue object to a FacetValue object

Parameters:
pRefineFacet - The RefinementFacet associated with the refinement value
pRefineValue - The RefinementValue object to be converted
pIsLastValue - Indicates whether the refinement value is the last in the list
Returns:
A newly created FacetValue instance

isEligibleFacetValue

protected boolean isEligibleFacetValue(FacetTrail pFacetTrail,
                                       FacetValue pFacetValue)
Determines whether the given facet value is eligible for inclusion in the list of facet values.

Parameters:
pFacetTrail - The facet trail to compare the facet value against
pFacetValue - The facet value to check
Returns:
true if the facet value is eligible, false otherwise.