atg.commerce.search.refinement
Class CommerceFacetSearchTools

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

public class CommerceFacetSearchTools
extends FacetSearchTools


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
protected static java.lang.String SEARCH_TESTING_RC_NAME_PREFIX
           
 
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
CommerceFacetSearchTools()
          Constructs an instanceof CommerceFacetSearchTools
 
Method Summary
protected  void addCategoryConstraint(java.lang.String pCategoryId, QueryRequest pRequest)
          Adds a category id constraint to the query.
protected  FacetValue convertRefineValue(RefinementFacet pRefineFacet, RefinementValue pRefineValue, boolean pIsLastValue)
          Converts a RefinementValue object to a FacetValue object
 java.lang.String determineCommerceRefineConfigName(FacetTrail pTrail, QueryRequest pRequest)
          determine the refine config name
 java.lang.String determineDocSetPath(FacetTrail pTrail, QueryRequest pRequest)
          Determines the docset path constraint for the ES request.
 RepositoryItem findCategory(java.lang.String pCategoryId)
          find the category by id
 RefinementConfiguration getCatalogRefineConfig(FacetTrail pTrail, QueryRequest pRequest)
          get the catalog refine config
 CatalogTools getCatalogTools()
           
 java.lang.String getCategoryId()
           
 java.lang.String getCategoryIdPropertyName()
           
protected  CommerceRefinementConfiguration getCommerceRefinementConfiguration(RepositoryItem pItem)
          Creates a CommerceRefinementConfiguration bean from the given refineConfig repository item
 CommerceRefinementConfigurationPropertyManager getCommerceRefinementConfigurationPropertyManager()
          Gets the commerceRefinementConfigurationPropertyManager.
protected  java.util.List getDerivedRefineElements(RepositoryItem pCategory)
          Method to get the total set of refine elements (facets) for the given category.
 java.lang.String getDocSetPathFormat()
           
 atg.commerce.search.refinement.CommerceFacetSourceGenerator getFacetSourceGenerator()
           
 RefinementConfiguration getGlobalRefineConfig()
          Gets the global refine config
 java.lang.String getGlobalRefineConfigName()
           
protected  java.lang.String getIdForDocSetPath(FacetTrail pTrail)
           
protected  java.lang.String getIdPropertyNameForDocSetPath()
           
protected  FacetValue getLastCategoryFacetValueInTrail(FacetTrail pfacetTrail)
          Gets the last catalog structure facet value (facet that represents a category) in the facet trail.
 RefinementConfiguration getLastCategoryRefineConfig(FacetTrail pFacetTrail)
          Gets the refine config of the last category in the facet trail.
 RefinementConfiguration getRefineConfig(RepositoryItem pCategoryItem)
          Gets the refine config for the given category.
protected  java.lang.String getSearchTestingRefineConfigName(RepositoryItem pSourceItem, java.lang.String pPrefix)
          Generate refine-config name for search query executed from Search Testing UI.
protected  RepositoryItem getSourceItem(RepositoryItem pCategory)
          Gets the source repository item for this refine config.
protected  boolean isCategoryFacet(FacetValue pValue)
          test to see if a facet value is an instanceof CategoryFacetValue
protected  boolean isEligibleFacetValue(FacetTrail pFacetTrail, FacetValue pFacetValue)
          determines whether the given facet value is eligible for inclusion in the list of facet values
 boolean isEnableUnverifiedCategoryLookup()
          get EnableUnverifiedCategoryLookup
 boolean isSkipAncestorsToCategoriesInTrail()
           
 SearchRequest processSearchRequest(SearchRequest pSearchRequest, DynamoHttpServletRequest pDynamoRequest, java.lang.Object pCallback)
          process search request
protected  void removeAncestorCategoriesFromFacetValues(java.util.List<FacetValue> pFacetValuesList)
          Remove all but the most specific CategoryFacetValue from the pFacetValuesList.
 java.util.List<java.lang.String> reorderCategories(java.util.List<java.lang.String> pCategoryIds)
           
 void setCatalogTools(CatalogTools pCatalogTools)
           
 void setCategoryId(java.lang.String pCategoryId)
           
 void setCategoryIdPropertyName(java.lang.String pCategoryIdPropertyName)
           
 void setCommerceRefinementConfigurationPropertyManager(CommerceRefinementConfigurationPropertyManager pCRCPropertyManager)
          Sets the commerceRefinementConfigurationPropertyManager.
 void setDocSetPathFormat(java.lang.String pDocSetPathFormat)
           
 void setEnableUnverifiedCategoryLookup(boolean pEnableUnverifiedCategoryLookup)
          set EnableUnverifiedCategoryLookup.
 void setFacetSourceGenerator(atg.commerce.search.refinement.CommerceFacetSourceGenerator pFacetSourceGenerator)
           
 void setGlobalRefineConfigName(java.lang.String pGlobalRefineConfigName)
           
 void setSkipAncestorsToCategoriesInTrail(boolean pSkipAncestorsToCategoriesInTrail)
           
 
Methods inherited from class atg.repository.search.refinement.FacetSearchTools
containsConstraint, createConstraint, createConstraints, createDocSetConstraint, createFacetDocSetConstraint, createFacetDocSetConstraint, createFacetTrail, createFacetTrail, createFacetTrail, createQueryRequest, createSession, determineQuestionText, determineRefineConfigMap, determineRefineConfigName, escapeAsterisk, getAdditionalConstraints, getAllFacets, getCurrentFacetTrail, getDefaultFacetPriority, getFacetManager, getFacets, getFacetTrail, getFacetTrailTools, getMinMatchingDocsCount, getQueryRequest, getRedirect, getRefineConfig, getRefineConfigXMLGenerator, getSearchClient, getSearchRequest, getTestingMode, handleAutoRedirect, isIncludeOverflowAndUnderflowRangeValues, isSkipValuesAlreadyInTrail, mergeConstraints, processFacetTrail, processFacetTrail, processSearchResponse, search, search, search, setAllFacets, setDefaultFacetPriority, setFacetManager, setFacets, setFacetTrail, setFacetTrailTools, setIncludeOverflowAndUnderflowRangeValues, setMinMatchingDocsCount, setQueryRequest, setRefineConfig, setRefineConfigXMLGenerator, setSearchClient, setSearchRequest, setSkipValuesAlreadyInTrail, setTestingMode
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, 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, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, 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


SEARCH_TESTING_RC_NAME_PREFIX

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

CommerceFacetSearchTools

public CommerceFacetSearchTools()
Constructs an instanceof CommerceFacetSearchTools

Method Detail

setDocSetPathFormat

public void setDocSetPathFormat(java.lang.String pDocSetPathFormat)

getDocSetPathFormat

public java.lang.String getDocSetPathFormat()

setCatalogTools

public void setCatalogTools(CatalogTools pCatalogTools)

getCatalogTools

public CatalogTools getCatalogTools()

setGlobalRefineConfigName

public void setGlobalRefineConfigName(java.lang.String pGlobalRefineConfigName)

getGlobalRefineConfigName

public java.lang.String getGlobalRefineConfigName()

setCategoryId

public void setCategoryId(java.lang.String pCategoryId)

getCategoryId

public java.lang.String getCategoryId()

setCommerceRefinementConfigurationPropertyManager

public void setCommerceRefinementConfigurationPropertyManager(CommerceRefinementConfigurationPropertyManager pCRCPropertyManager)
Sets the commerceRefinementConfigurationPropertyManager.


getCommerceRefinementConfigurationPropertyManager

public CommerceRefinementConfigurationPropertyManager getCommerceRefinementConfigurationPropertyManager()
Gets the commerceRefinementConfigurationPropertyManager.


setFacetSourceGenerator

public void setFacetSourceGenerator(atg.commerce.search.refinement.CommerceFacetSourceGenerator pFacetSourceGenerator)

getFacetSourceGenerator

public atg.commerce.search.refinement.CommerceFacetSourceGenerator getFacetSourceGenerator()

setCategoryIdPropertyName

public void setCategoryIdPropertyName(java.lang.String pCategoryIdPropertyName)

getCategoryIdPropertyName

public java.lang.String getCategoryIdPropertyName()

isSkipAncestorsToCategoriesInTrail

public boolean isSkipAncestorsToCategoriesInTrail()

setSkipAncestorsToCategoriesInTrail

public void setSkipAncestorsToCategoriesInTrail(boolean pSkipAncestorsToCategoriesInTrail)

setEnableUnverifiedCategoryLookup

public void setEnableUnverifiedCategoryLookup(boolean pEnableUnverifiedCategoryLookup)
set EnableUnverifiedCategoryLookup. if true then we won't restrict category lookups by catalog. this is useful in the case where the current search isn't executed in the context of a catalog, like in search testing.

Parameters:
pEnableUnverifiedCategoryLookup - the EnableUnverifiedCategoryLookup

isEnableUnverifiedCategoryLookup

public boolean isEnableUnverifiedCategoryLookup()
get EnableUnverifiedCategoryLookup

Returns:
the EnableUnverifiedCategoryLookup

determineCommerceRefineConfigName

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

Overrides:
determineCommerceRefineConfigName in class FacetSearchTools

findCategory

public RepositoryItem findCategory(java.lang.String pCategoryId)
                            throws RepositoryException
find the category by id

Throws:
RepositoryException

getCatalogRefineConfig

public RefinementConfiguration getCatalogRefineConfig(FacetTrail pTrail,
                                                      QueryRequest pRequest)
get the catalog refine config


getGlobalRefineConfig

public RefinementConfiguration getGlobalRefineConfig()
Gets the global refine config

Returns:
the global refine config if defined, otherwise null.

getLastCategoryRefineConfig

public RefinementConfiguration getLastCategoryRefineConfig(FacetTrail pFacetTrail)
Gets the refine config of the last category in the facet trail.

Parameters:
pFacetTrail - The facet trail
Returns:
The refine config if found, otherwise null

getLastCategoryFacetValueInTrail

protected FacetValue getLastCategoryFacetValueInTrail(FacetTrail pfacetTrail)
Gets the last catalog structure facet value (facet that represents a category) in the facet trail.

Parameters:
pfacetTrail - The facet trail
Returns:
If there are one or more facet valuess in the facet trail that represent categories, the most recently added instance will be returned. Otherwise, null will be returned

getRefineConfig

public RefinementConfiguration getRefineConfig(RepositoryItem pCategoryItem)
Gets the refine config for the given category.

Parameters:
pCategoryItem - The category item to retrieve the refine config for.
Returns:
The refine config for the category, if defined, otherwise null is returned.

getCommerceRefinementConfiguration

protected CommerceRefinementConfiguration getCommerceRefinementConfiguration(RepositoryItem pItem)
                                                                      throws FacetException
Creates a CommerceRefinementConfiguration bean from the given refineConfig repository item

Parameters:
pItem - The refine config repository item used to populate the created bean
Returns:
A new CommerceRefinementConfiguration instance
Throws:
FacetException

determineDocSetPath

public java.lang.String determineDocSetPath(FacetTrail pTrail,
                                            QueryRequest pRequest)
Determines the docset path constraint for the ES request. If there is a category in the facet trail, the doc set path will be set to /Meta/ancestorCategory/ where is the ID of the last category in the trail. If there is no category in the trail, then a default doc set path will be set.

Overrides:
determineDocSetPath in class FacetSearchTools
Parameters:
pFacetSearchRequest - The facet search request
Returns:
The docset path to use in the ES request

getIdPropertyNameForDocSetPath

protected java.lang.String getIdPropertyNameForDocSetPath()
Returns:

getIdForDocSetPath

protected java.lang.String getIdForDocSetPath(FacetTrail pTrail)
Parameters:
pTrail -
Returns:

reorderCategories

public java.util.List<java.lang.String> reorderCategories(java.util.List<java.lang.String> pCategoryIds)

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
Overrides:
processSearchRequest in class FacetSearchTools
Parameters:
pSearchRequest - the search request object
pDynamoRequest - the dynamo request
pCallback - the form handler component that called this method
Throws:
atg.search.client.SearchClientException

getSourceItem

protected RepositoryItem getSourceItem(RepositoryItem pCategory)
Gets the source repository item for this refine config. Without custom catalogs this will always be the passed in category.

Parameters:
pCategory - RepositoryItem category
Returns:
RepositoryItem source

getSearchTestingRefineConfigName

protected java.lang.String getSearchTestingRefineConfigName(RepositoryItem pSourceItem,
                                                            java.lang.String pPrefix)
Generate refine-config name for search query executed from Search Testing UI. Should be of the form:- testing-category[categoryId] or testing-catalog[catalogId]_category[categoryId] where Custom Catalogs used

Parameters:
pSourceItem, - selected category
pPrefix, - everything before category[categoryId]
Returns:

addCategoryConstraint

protected void addCategoryConstraint(java.lang.String pCategoryId,
                                     QueryRequest pRequest)
Adds a category id constraint to the query. This is used if both search text and a category id are set since startCategory can only be used if there is no search text.

Parameters:
pCategoryId - String category id
pRequest - QueryRequest

getDerivedRefineElements

protected java.util.List getDerivedRefineElements(RepositoryItem pCategory)
Method to get the total set of refine elements (facets) for the given category.

Parameters:
pCategory - RepositoryItem category to use
Returns:
Collection of refine elements

isEligibleFacetValue

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

Overrides:
isEligibleFacetValue in class FacetSearchTools
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.

convertRefineValue

protected FacetValue convertRefineValue(RefinementFacet pRefineFacet,
                                        RefinementValue pRefineValue,
                                        boolean pIsLastValue)
Description copied from class: FacetSearchTools
Converts a RefinementValue object to a FacetValue object

Overrides:
convertRefineValue in class FacetSearchTools
Parameters:
pRefineFacet - The RefinementFacet definition associated with the refinement value
pRefineValue - The refinement value to be converted
pIsLastValue - Indicates whether this is the last value in the list of values for this refinement.
Returns:
A newly created FacetValue object.
See Also:
Converts the RefinementValue object returned by the Search API to a FacetValue object

isCategoryFacet

protected boolean isCategoryFacet(FacetValue pValue)
test to see if a facet value is an instanceof CategoryFacetValue

Overrides:
isCategoryFacet in class FacetSearchTools

removeAncestorCategoriesFromFacetValues

protected void removeAncestorCategoriesFromFacetValues(java.util.List<FacetValue> pFacetValuesList)
                                                throws FacetException
Remove all but the most specific CategoryFacetValue from the pFacetValuesList.

Overrides:
removeAncestorCategoriesFromFacetValues in class FacetSearchTools
Parameters:
pFacetValuesList - - this is the list of FacetValues derived from the facet trail.
Throws:
FacetException