public class SearchFormHandler extends SearchFormHandler
This form handler is used to search the catalog repository for products and categories. The handler can be used to perform four types of searching: keywords, text, advanced, and hierarchical. All four types use a boolean to turn that searching feature on and propertyName to specify on which properties to search. This form handler examines each boolean and if true, appends that subquery to the full query string. The itemTypes property specify what items in the catalog repository definition to search. For the catalog, these will likely be 'product' or 'category' or both. Configuration files will be used to specify what searching to perform on which property values and item types.
Keyword
Keyword searching uses keyword property names and an input search string
to search product and/or category keywords. Values entered will be used
to build the subQuery for keyword matching.
keywordsPropertyNames
keywords
searchInput
searchInput
keywords
property
is not set, this string will be parsed using the deliminator
keywordInputSeparator
and the resulting array of strings will
be used instead. This property is shared by Text searches.
keywordInputSeparator
searchInput
. The default value is a single space.
toUpperCaseKeywords
toLowerCaseKeywords
Text
Text searching uses text property names and an input search string to
do a text pattern matching on properties. Values entered will be used
to build the subQuery for text searching.
textSearchPropertyNames
searchStringFormat
searchInput
simulateTextSearchQueries=true
), the SQL
LIKE operator will be used to determine whether the target value is a
substring of any of the text properties being searched. This property is
also used for Keyword searches if the keywords
property is
not set.
minScore
Advanced
Advanced searches provide possible search options for each property
specified in AdvancedSearchPropertyNames. For example, enumerated types
will be defined in the repository with a set number of values. Advanced
searching will retrieve these values from the definition to display
in a select box. The advanced query will be built from options selected
to further refine the catalog search.
Hierarchical
Hierarchical searches look in a subset of categories, starting from
a given category, including also that category's child categories, and
also those children's children, i.e., all descendant categories of the
original category. The given category is indicated by the repository
ID in the hierarchicalCategoryId property.
Price
Price searches take a pricePropertyName, which is the name of the property
of the product to search for the price on. This property can be a subreference
(i.e., childSKUs.listPrice). It also takes a priceRelation, which is a comparison
operator (i.e., ">", ">=", "=", etc.). Finally, it takes a price, which must
be a valid number. The search will return the products whose priceProperty contains
a value that has the proper relation with the price given.
Sku
This is an open-ended text search on the childSKUsPropertyName for the "sku" input.
All products that contain a sku with an id that contains the given "sku" substring
will be returned.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_VERSION
Class version string
|
static java.lang.String |
INVALID_PRICE
droplet exception code: invalid price
|
protected java.lang.String |
mLastCatalogKey
Member variable where prepareRepositories stores the last catalog key it saw.
|
static java.lang.String |
PRICE_PROPERTY_NOT_SET
droplet exception code: required property not set
|
ALL_SITES_SCOPE, ANY_SITE_SCOPE, CURRENT_SITE_SCOPE, EMPTY_SEARCH_INPUT_DISALLOW, EMPTY_SEARCH_VALUES_DISALLOW, GENERATE_VALUES_BY_TYPE_FAILED, INVALID_ITEM_TYPE, INVALID_KEYWORD_SEARCH_STRING, INVALID_PROP_COMBINATION, INVALID_SEARCH_PROPERTY_NAMES, mEndIndex, mPreviouslySubmitted, mPreviousQuery, mSearchResults, mSearchResultsByItemType, mStartIndex, MULTIPLE_ITEM_TYPES_DISALLOW, NO_PROPERTY_NAMES_FOR_ITEM, NONE_SITE_SCOPE, QUERY_FAILURE, UNMATCHED_QUOTES
PARAM_DEFER_FORWARD_OR_REDIRECT, PARAM_USE_FORWARDS
SERVICE_INFO_KEY
DEFAULT_LOG_TRACE_STATUS
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
Constructor and Description |
---|
SearchFormHandler()
Constructs an instanceof SearchFormHandler
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
areSearchValuesEmpty()
Extends the base behavior to check the sku and price search values.
|
void |
beforeGet(DynamoHttpServletRequest request,
DynamoHttpServletResponse response)
Called before getX methods on this form are called.
|
protected Query |
generatePriceQuery(Repository pRepository,
java.lang.String pItemType,
QueryBuilder pQueryBuilder)
generate subquery using RQL
|
protected Query |
generateSearchQuery(Repository pRepository,
java.lang.String pItemType,
QueryBuilder pQueryBuilder)
Return the query that should be executed on the Repository View.
|
protected java.util.Collection |
generateSearchValues(java.lang.String pSearchType)
generateSearchValues is used by the advanced searching feature.
|
protected Query |
generateSkuQuery(java.lang.String pItemType,
QueryBuilder pQueryBuilder,
java.lang.String pInput)
Generates a search for child skus of the product
|
java.lang.String[] |
getAdvancedSearchPropertyNames()
Returns property AdvancedSearchPropertyNames which is the set of property
names to search
|
java.lang.String |
getAncestorCategoriesPropertyName()
Returns property ancestorCategoriesPropertyName
|
java.lang.String |
getCatalogKey()
Returns property CatalogKey
|
CatalogTools |
getCatalogTools()
Returns property catalogTools.
|
java.lang.String |
getChildSKUsPropertyName()
Returns property ChildSKUsPropertyName which is the name of the childSKUs property in the product item descriptor
|
java.lang.String |
getHierarchicalCategoryId()
Returns property HierarchicalCategoryId
|
char |
getKeywordInputSeparator()
Returns property KeywordInputSeparator
|
java.lang.String[] |
getKeywords()
Returns property Keywords.
|
java.lang.String[] |
getKeywordsPropertyNames()
Returns property KeywordsPropertyNames which is the set of property names to search
|
java.lang.String |
getLoggingIdentifier()
Returns property LoggingIdentifier
|
protected java.lang.String |
getMessage(java.lang.String key,
java.lang.Object[] args) |
java.lang.String |
getPrice()
Returns property Price which is the price to search for
|
java.lang.String |
getPricePropertyName()
Returns property PricePropertyName
|
java.lang.String |
getPriceRelation()
Returns property PriceRelation
|
java.util.HashMap |
getPropertyValues()
Returns property PropertyValues
|
java.util.HashMap |
getPropertyValuesByType()
Returns property PropertyValuesByType.
|
java.lang.String |
getRepositoryKey(DynamoHttpServletRequest pRequest,
DynamoHttpServletResponse pResponse)
Retrieve the key to the catalog repository.
|
java.lang.String |
getRepositoryKeyParamName()
Returns property repositoryKeyParamName
|
RepositoryView |
getRepositoryView(Repository pRepository,
java.lang.String pViewName)
Returns the repository view for the repository
|
java.lang.String |
getSearchInput()
Returns property SearchInput
|
java.lang.String |
getSku()
Returns property Sku
|
java.lang.String[] |
getTextSearchPropertyNames()
Returns property TextSearchPropertyNames which is the set of property names for text search
|
boolean |
handleSearch(DynamoHttpServletRequest pRequest,
DynamoHttpServletResponse pResponse)
For each each item type in that repository, call generateSearchResultSet
to generate a subResultSet for that item type based on query parameters.
|
boolean |
isSkuExactMatch()
Gets the SkuExactMatch property value.
|
protected void |
prepare(DynamoHttpServletRequest request,
DynamoHttpServletResponse response)
Prepare search properties.
|
protected void |
prepareRepository(DynamoHttpServletRequest pRequest,
DynamoHttpServletResponse pResponse)
Set the catalog key and the repository to search based on the
repository key that has been stored in pRequest, but only if
the value of the key has changed since the last time
prepareRepository was called.
|
void |
setAdvancedSearchPropertyNames(java.lang.String[] pAdvancedSearchPropertyNames)
Sets property AdvancedSearchPropertyNames
|
void |
setAncestorCategoriesPropertyName(java.lang.String pAncestorCategoriesPropertyName)
Sets property ancestorCategoriesPropertyName
|
void |
setCatalogKey(java.lang.String pCatalogKey)
Sets property CatalogKey
|
void |
setCatalogTools(CatalogTools pCatalogTools)
Sets property catalogTools.
|
void |
setChildSKUsPropertyName(java.lang.String pChildSKUsPropertyName)
Sets property ChildSKUsPropertyName
|
void |
setHierarchicalCategoryId(java.lang.String pHierarchicalCategoryId)
Sets property HierarchicalCategoryId
|
void |
setKeywordInputSeparator(char pKeywordInputSeparator)
Sets property KeywordInputSeparator
|
void |
setKeywordsPropertyNames(java.lang.String[] pKeywordSearchPropertyNames)
Sets property KeywordSearchPropertyNames
|
void |
setLoggingIdentifier(java.lang.String pLoggingIdentifier)
Sets property LoggingIdentifier
|
void |
setPrice(java.lang.String pPrice)
Sets property Price
|
void |
setPricePropertyName(java.lang.String pPricePropertyName)
Sets property PricePropertyName
|
void |
setPriceRelation(java.lang.String pPriceRelation)
Sets property PriceRelation
|
void |
setPropertyValues(java.util.HashMap pPropertyValues)
Sets property PropertyValues
|
void |
setPropertyValuesByType()
init with all possible values of each property
|
void |
setRepositoryKeyParamName(java.lang.String pRepositoryKeyParamName)
Sets property repositoryKeyParamName
|
void |
setSearchInput(java.lang.String pSearchInput)
Sets property SearchInput
|
void |
setSku(java.lang.String pSku)
Sets property Sku
|
void |
setSkuExactMatch(boolean pSkuExactMatch)
Sets the SkuExactMatch property value.
|
void |
setTextSearchPropertyNames(java.lang.String[] pTextSearchPropertyNames)
Sets property TextSearchPropertyNames
|
beforeSet, filterSiteList, generateAdvancedSearchQuery, generateHierarchicalSearchQuery, generateKeywordSearchQuery, generateResultSet, generateSearchValues, generateSiteFilter, generateTextSearchQuery, getAdvancedSearchPropertyRanges, getAdvancedSearchPropertyValues, getAllowEmptySearch, getAllowRefine, getAllowWildcards, getAncestorId, getAncestorPropertyName, getClearQueryURL, getContextFilteringRulesForSites, getCurrentResultPageNum, getDisplayName, getEndCount, getEndIndex, getErrorURL, getItemTypes, getKeywordInput, getKeywordSearchPropertyNames, getMaxResultsPerPage, getMaxRowCount, getMinScore, getRepositories, getResultPageCount, getResultSetSize, getSearchResults, getSearchResultsByItemType, getSearchStringFormat, getSiteGroupManager, getSiteIds, getSiteManager, getSiteScope, getStartCount, getStartIndex, getSuccessURL, getTextInput, handleClearQuery, handleCurrentResultPageNum, isAdvancedSearchPropertyRangesEmpty, isAdvancedSearchPropertyValuesEmpty, isDoAdvancedSearch, isDoHierarchicalSearch, isDoKeywordSearch, isDoTextSearch, isEnableCountQuery, isIncludeDisabledSites, isIncludeInactiveSites, isPrepared, isPreviouslySubmitted, isToLowerCaseKeywords, isToUpperCaseKeywords, isUseIncludesForKeywordQueryOnMultiProperties, setAdvancedSearchPropertyRanges, setAdvancedSearchPropertyValues, setAllowEmptySearch, setAllowRefine, setAllowWildcards, setAncestorId, setAncestorPropertyName, setClearQueryURL, setCurrentResultPageNum, setDisplayName, setDoAdvancedSearch, setDoHierarchicalSearch, setDoKeywordSearch, setDoTextSearch, setEnableCountQuery, setEndIndex, setErrorURL, setIncludeDisabledSites, setIncludeInactiveSites, setItemTypes, setKeywordInput, setKeywords, setKeywordSearchPropertyNames, setMaxResultsPerPage, setMaxRowCount, setMinScore, setPrepared, setRepositories, setResultSetSize, setSearchStringFormat, setSiteGroupManager, setSiteIds, setSiteManager, setSiteScope, setStartIndex, setSuccessURL, setTextInput, setToLowerCaseKeywords, setToUpperCaseKeywords, setUseIncludesForKeywordQueryOnMultiProperties, splitPropertyNames, transformKeywords
addFormException, addUncheckedFormException, afterSet, checkFormRedirect, createFormSubmissionMessage, getCancelURL, getCheckForValidSession, getFormError, getFormExceptions, getFormName, getMessagePort, getMessageSource, getMessageType, getPropertyExceptions, getSendMessages, getUncheckedFormExceptions, handleCancel, handleFormException, handleUncheckedFormException, hasUncheckedFormExceptions, isDeferForwardsAndRedirects, isRestorableForm, isUseForwards, isValidSession, redirectOrForward, resetFormExceptions, setCancelURL, setCheckForValidSession, setDeferForwardsAndRedirects, setFormName, setMessagePort, setMessageSource, setMessageType, setRestorableForm, setSendMessages, setUseForwards
afterGet
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
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
public static final java.lang.String CLASS_VERSION
public static final java.lang.String INVALID_PRICE
public static final java.lang.String PRICE_PROPERTY_NOT_SET
protected java.lang.String mLastCatalogKey
public SearchFormHandler()
public void setKeywordsPropertyNames(java.lang.String[] pKeywordSearchPropertyNames)
pKeywordSearchPropertyNames
- The property to store the names of all the
keyword properties.public java.lang.String[] getKeywordsPropertyNames()
public void setAdvancedSearchPropertyNames(java.lang.String[] pAdvancedSearchPropertyNames)
setAdvancedSearchPropertyNames
in class SearchFormHandler
pAdvancedSearchPropertyNames
- the property to store advanced search
property names.public java.lang.String[] getAdvancedSearchPropertyNames()
getAdvancedSearchPropertyNames
in class SearchFormHandler
public void setTextSearchPropertyNames(java.lang.String[] pTextSearchPropertyNames)
setTextSearchPropertyNames
in class SearchFormHandler
pTextSearchPropertyNames
- the property to store text search property
names.public java.lang.String[] getTextSearchPropertyNames()
getTextSearchPropertyNames
in class SearchFormHandler
public void setLoggingIdentifier(java.lang.String pLoggingIdentifier)
pLoggingIdentifier
- the property which identifies this object as the Catalog Search.public java.lang.String getLoggingIdentifier()
public void setRepositoryKeyParamName(java.lang.String pRepositoryKeyParamName)
pRepositoryKeyParamName
- the property to store the name of the input parameter for the repository key value.public java.lang.String getRepositoryKeyParamName()
public void setCatalogKey(java.lang.String pCatalogKey)
pCatalogKey
- the property to store the catalog key used as an index to available catalogs (e.g. multiple languages).public java.lang.String getCatalogKey()
public void setCatalogTools(CatalogTools pCatalogTools)
pCatalogTools
- the property to store the global service catalog tools factory to obtain the catalog to search in.public CatalogTools getCatalogTools()
public void setSearchInput(java.lang.String pSearchInput)
pSearchInput
- the property to store the input search string. Text
search always uses this property and Keyword search will use this (after
parsing using a configurable deliminator) if keyword property is not set.public java.lang.String getSearchInput()
public java.lang.String[] getKeywords()
getKeywords
in class SearchFormHandler
public void setKeywordInputSeparator(char pKeywordInputSeparator)
pKeywordInputSeparator
- the property to store what characters to use
to separate keywords in the SearchInput string.public char getKeywordInputSeparator()
public void setHierarchicalCategoryId(java.lang.String pHierarchicalCategoryId)
pHierarchicalCategoryId
- the property to store the value of the hierarchical category id to search in.public java.lang.String getHierarchicalCategoryId()
public void setAncestorCategoriesPropertyName(java.lang.String pAncestorCategoriesPropertyName)
pAncestorCategoriesPropertyName
- the property to store the value of ancestor category property name.public java.lang.String getAncestorCategoriesPropertyName()
public java.util.HashMap getPropertyValues()
public void setPropertyValues(java.util.HashMap pPropertyValues)
pPropertyValues
- the property to store selected property values for
advanced searching.public java.util.HashMap getPropertyValuesByType()
advancedSearchPropertyValues
whose type is either enumerated
or RepositoryItem. The key is the name of the property and the value is a
Collection of the possible values.getPropertyValuesByType
in class SearchFormHandler
public void setPropertyValuesByType()
setPropertyValuesByType
in class SearchFormHandler
public void setChildSKUsPropertyName(java.lang.String pChildSKUsPropertyName)
pChildSKUsPropertyName
- the name of the childSKUs property in the product item descriptorpublic java.lang.String getChildSKUsPropertyName()
public void setPrice(java.lang.String pPrice)
pPrice
- the price to search forpublic java.lang.String getPrice()
public java.lang.String getPriceRelation()
public void setPriceRelation(java.lang.String pPriceRelation)
pPriceRelation
- the relation of prices to search forpublic java.lang.String getPricePropertyName()
public void setPricePropertyName(java.lang.String pPricePropertyName)
pPricePropertyName
- the name of the price property in the searchable
itempublic java.lang.String getSku()
public void setSku(java.lang.String pSku)
pSku
- the sku to search forpublic boolean isSkuExactMatch()
public void setSkuExactMatch(boolean pSkuExactMatch)
pSkuExactMatch
- The boolean value.public boolean handleSearch(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse) throws javax.servlet.ServletException, java.io.IOException
handleSearch
in class SearchFormHandler
pRequest
- the servlet's requestpResponse
- the servlet's responsejavax.servlet.ServletException
- if there was an error while executing the codejava.io.IOException
- if there was an error with servlet iopublic void beforeGet(DynamoHttpServletRequest request, DynamoHttpServletResponse response)
beforeGet
in interface DropletFormHandler
beforeGet
in class SearchFormHandler
protected void prepareRepository(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
protected void prepare(DynamoHttpServletRequest request, DynamoHttpServletResponse response)
prepare
in class SearchFormHandler
public java.lang.String getRepositoryKey(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse) throws javax.servlet.ServletException, java.io.IOException
pRequest
- the servlet's requestpResponse
- the servlet's responsejavax.servlet.ServletException
- if there was an error while executing the codejava.io.IOException
- if there was an error with servlet ioprotected java.util.Collection generateSearchValues(java.lang.String pSearchType)
pSearchType
- the search type. Typically corresponds to an
item descriptor name in the catalog repositoryprotected Query generateSearchQuery(Repository pRepository, java.lang.String pItemType, QueryBuilder pQueryBuilder) throws RepositoryException, DropletFormException
generateSearchQuery
in class SearchFormHandler
pRepository
- the repository to search inpItemType
- the type of item to search for.pQueryBuilder
- the builder that should be used to construct the queryRepositoryException
- if an error occured while forming the queryDropletFormException
public RepositoryView getRepositoryView(Repository pRepository, java.lang.String pViewName) throws RepositoryException
RepositoryException
protected Query generatePriceQuery(Repository pRepository, java.lang.String pItemType, QueryBuilder pQueryBuilder) throws RepositoryException, java.lang.NumberFormatException, atg.core.exception.PropertyNotSetException
pRepository
- pItemType
- pQueryBuilder
- the builder that should be used to construct the queryRepositoryException
- if an error occured while forming the queryjava.lang.NumberFormatException
- if the price cannot be formatted to a doubleatg.core.exception.PropertyNotSetException
- if the pricePropertyName property is not setprotected Query generateSkuQuery(java.lang.String pItemType, QueryBuilder pQueryBuilder, java.lang.String pInput) throws RepositoryException
pItemType
- the type of item to search for.pQueryBuilder
- the builder that should be used to construct the querypInput
- the search string to use for the full text searchRepositoryException
- if an error occured while forming the queryprotected boolean areSearchValuesEmpty()
areSearchValuesEmpty
in class SearchFormHandler
protected java.lang.String getMessage(java.lang.String key, java.lang.Object[] args)
getMessage
in class SearchFormHandler