atg.commerce.gifts
Class SearchFormHandler

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.droplet.EmptyFormHandler
              extended by atg.droplet.GenericFormHandler
                  extended by atg.commerce.gifts.SearchFormHandler
All Implemented Interfaces:
DropletFormHandler, NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener

public class SearchFormHandler
extends GenericFormHandler

This search form handler is used to support giftlist searches. Giftlist searching will search the giftlist repository for published giftlists that match the search criteria. This formhandler is configurable to search giftlist most giftlist properties. At a minimum, doNameSearch and doAdvancedSearch are boolean properties that specify what type of searches to perform. HandleSearch looks at these values to build the search query and excutes on the Repository view.

Name
Name searching uses name properties and an input search string to do a text pattern matching. Values entered will be used to build the subQuery for name searching of giftlist owners. The name search query will be constructed using an OR clause of both first name and last names.

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.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
protected  java.lang.String mSearchErrorURL
           
protected  java.lang.String mSearchSuccessURL
           
 
Fields inherited from class atg.droplet.GenericFormHandler
PARAM_DEFER_FORWARD_OR_REDIRECT, PARAM_USE_FORWARDS
 
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
SearchFormHandler()
          Constructs an instanceof SearchFormHandler
 
Method Summary
 java.util.Collection doSearch(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Performs the search operation and generates the result set.
protected  Query generateAdvancedSearchQuery(java.lang.String pItemType, QueryBuilder pQueryBuilder)
          Return a query which represents an advanced search based on selected property values.
protected  Query generateNameSearchQuery(java.lang.String pItemType, QueryBuilder pQueryBuilder, java.lang.String pInput)
          Return a query which represents a name search query.
protected  Query generatePublishedSearchQuery(java.lang.String pItemType, QueryBuilder pQueryBuilder)
          Generates a published search query to verify that lists are both public and published.
protected  java.util.Collection generateResultSet(java.lang.String pItemType)
          For the supplied item type return a sub-result set that will combined into the total result set.
protected  Query generateSearchQuery(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.
 java.lang.String[] getAdvancedSearchPropertyNames()
          Returns property AdvancedSearchPropertyNames
 Repository getGiftlistRepository()
          Returns property GiftlistRepository
 java.lang.String[] getItemTypes()
          Returns property ItemTypes
 java.lang.String getLoggingIdentifier()
          Returns property LoggingIdentifier
 java.lang.String[] getNameSearchPropertyNames()
          Returns property NameSearchPropertyNames
 java.util.Hashtable getPropertyValues()
          Returns property PropertyValues
 java.util.HashMap getPropertyValuesByType()
          Returns property PropertyValuesByType
 java.lang.String[] getPublishedSearchPropertyNames()
          Returns property PublishedSearchPropertyNames
 QueryOptions getQueryOptions()
          Returns property QueryOptions
 java.lang.String getSearchErrorURL()
           
 java.lang.String getSearchInput()
          Returns property SearchInput
 java.util.Collection getSearchResults()
          Returns property SearchResults
 java.util.HashMap getSearchResultsByItemType()
          Returns property SearchResultsByItemType
 java.lang.String getSearchStringFormat()
          Returns property SearchStringFormat
 java.lang.String getSearchSuccessURL()
           
 java.lang.String getStatePropertyName()
          Returns property statePropertyName
 boolean handleSearch(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          For each item type specified in itemTypes, call generateSearchResultSet to generate a subResultSet for that item type based on query parameters.
 boolean isDoAdvancedSearch()
          Returns property DoAdvancedSearch
 boolean isDoNameSearch()
          Returns property DoNameSearch
 boolean isDoPublishedSearch()
          Returns property DoPublishedSearch
 boolean isToLowerCaseKeywords()
          Returns property ToLowerCaseKeywords
 boolean isToUpperCaseKeywords()
          Returns property ToUpperCaseKeywords
 void postSearch(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Called after a search.
 void preSearch(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Called prior to the search taking place.
 void setAdvancedSearchPropertyNames(java.lang.String[] pAdvancedSearchPropertyNames)
          Sets property AdvancedSearchPropertyNames
 void setDoAdvancedSearch(boolean pDoAdvancedSearch)
          Sets property DoAdvancedSearch
 void setDoNameSearch(boolean pDoNameSearch)
          Sets property DoNameSearch
 void setDoPublishedSearch(boolean pDoPublishedSearch)
          Sets property DoPublishedSearch
 void setGiftlistRepository(Repository pGiftlistRepository)
          Sets property giftlistRepository
 void setItemTypes(java.lang.String[] pItemTypes)
          Sets property ItemTypes
 void setLoggingIdentifier(java.lang.String pLoggingIdentifier)
          Sets property LoggingIdentifier
 void setNameSearchPropertyNames(java.lang.String[] pNameSearchPropertyNames)
          Sets property NameSearchPropertyNames
 void setPropertyValues(java.util.Hashtable pPropertyValues)
          Sets property PropertyValues
 void setPublishedSearchPropertyNames(java.lang.String[] pPublishedSearchPropertyNames)
          Sets property PublishedSearchPropertyNames
 void setQueryOptions(QueryOptions pQueryOptions)
          Sets property QueryOptions
 void setSearchErrorURL(java.lang.String pSearchErrorURL)
           
 void setSearchInput(java.lang.String pSearchInput)
          Sets property SearchInput
 void setSearchStringFormat(java.lang.String pSearchStringFormat)
          Sets property SearchStringFormat
 void setSearchSuccessURL(java.lang.String pSearchSuccessURL)
           
 void setStatePropertyName(java.lang.String pStatePropertyName)
          Sets property statePropertyName
 void setToLowerCaseKeywords(boolean pToLowerCaseKeywords)
          Sets property ToLowerCaseKeywords
 void setToUpperCaseKeywords(boolean pToUpperCaseKeywords)
          Sets property ToUpperCaseKeywords
 
Methods inherited from class atg.droplet.GenericFormHandler
addFormException, addUncheckedFormException, afterSet, beforeSet, 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
 
Methods inherited from class atg.droplet.EmptyFormHandler
afterGet, beforeGet
 
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, 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 final java.lang.String CLASS_VERSION
Class version string

See Also:
Constant Field Values

mSearchSuccessURL

protected java.lang.String mSearchSuccessURL

mSearchErrorURL

protected java.lang.String mSearchErrorURL
Constructor Detail

SearchFormHandler

public SearchFormHandler()
Constructs an instanceof SearchFormHandler

Method Detail

getSearchSuccessURL

public java.lang.String getSearchSuccessURL()
Returns:
Returns the searchSuccessURL.

setSearchSuccessURL

public void setSearchSuccessURL(java.lang.String pSearchSuccessURL)
Parameters:
pSearchSuccessURL - The searchSuccessURL to set.

getSearchErrorURL

public java.lang.String getSearchErrorURL()
Returns:
Returns the searchErrorURL.

setSearchErrorURL

public void setSearchErrorURL(java.lang.String pSearchErrorURL)
Parameters:
pSearchErrorURL - The searchErrorURL to set.

setLoggingIdentifier

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

Parameters:
pLoggingIdentifier - the property which identifies this object as the Catalog Search.

getLoggingIdentifier

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

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.

setStatePropertyName

public void setStatePropertyName(java.lang.String pStatePropertyName)
Sets property statePropertyName

Parameters:
pStatePropertyName - the property to store the owner state property.

getStatePropertyName

public java.lang.String getStatePropertyName()
Returns property statePropertyName

Returns:
The value of the property statePropertyName.

setNameSearchPropertyNames

public void setNameSearchPropertyNames(java.lang.String[] pNameSearchPropertyNames)
Sets property NameSearchPropertyNames

Parameters:
pNameSearchPropertyNames - the property to store name search property names.

getNameSearchPropertyNames

public java.lang.String[] getNameSearchPropertyNames()
Returns property NameSearchPropertyNames

Returns:
The value of the property NameSearchPropertyNames.

setDoNameSearch

public void setDoNameSearch(boolean pDoNameSearch)
Sets property DoNameSearch

Parameters:
pDoNameSearch - the property to store the boolean value of whether or not to perform a name search.

isDoNameSearch

public boolean isDoNameSearch()
Returns property DoNameSearch

Returns:
The value of the property DoNameSearch.

setSearchInput

public void setSearchInput(java.lang.String pSearchInput)
Sets property SearchInput

Parameters:
pStringInput - the property to store the input search string to parse and search.

getSearchInput

public java.lang.String getSearchInput()
Returns property SearchInput

Returns:
The value of the property SearchInput trimming any extra space.

setToUpperCaseKeywords

public void setToUpperCaseKeywords(boolean pToUpperCaseKeywords)
Sets property ToUpperCaseKeywords

Parameters:
pToUpperCaseKeywords - the property to store the boolean value of whether or not to convert input string to upper case.

isToUpperCaseKeywords

public boolean isToUpperCaseKeywords()
Returns property ToUpperCaseKeywords

Returns:
The value of the property ToUpperCaseKeywords

setToLowerCaseKeywords

public void setToLowerCaseKeywords(boolean pToLowerCaseKeywords)
Sets property ToLowerCaseKeywords

Parameters:
pToLowerCaseKeywords - the property to store the boolean value of whether or not to convert input string to lower case.

isToLowerCaseKeywords

public boolean isToLowerCaseKeywords()
Returns property ToLowerCaseKeywords

Returns:
The value of the property ToLowerCaseKeywords

setGiftlistRepository

public void setGiftlistRepository(Repository pGiftlistRepository)
Sets property giftlistRepository

Parameters:
pGiftlistRepository - the property to store the name of the giftlist repository.

getGiftlistRepository

public Repository getGiftlistRepository()
Returns property GiftlistRepository

Returns:
The value of the property GiftlistRepository

setItemTypes

public void setItemTypes(java.lang.String[] pItemTypes)
Sets property ItemTypes

Parameters:
pItemTypes - the property to store the item types to search in the repository (e.g. gift-list).

getItemTypes

public java.lang.String[] getItemTypes()
Returns property ItemTypes

Returns:
The value of the property itemTypes

setQueryOptions

public void setQueryOptions(QueryOptions pQueryOptions)
Sets property QueryOptions

Parameters:
pQueryOptions - the property to store specific query options to used when generating the search string.

getQueryOptions

public QueryOptions getQueryOptions()
Returns property QueryOptions

Returns:
The value of the property queryOptions

getSearchResults

public java.util.Collection getSearchResults()
Returns property SearchResults

Returns:
The value of the property SearchResults

getSearchResultsByItemType

public java.util.HashMap getSearchResultsByItemType()
Returns property SearchResultsByItemType

Returns:
The value of the property SearchResultsByItemType

setDoAdvancedSearch

public void setDoAdvancedSearch(boolean pDoAdvancedSearch)
Sets property DoAdvancedSearch

Parameters:
pDoAdvancedSearch - the property to store the boolean value of whether or not to perform a advanced search.

isDoAdvancedSearch

public boolean isDoAdvancedSearch()
Returns property DoAdvancedSearch

Returns:
The value of the property DoAdvancedSearch

setAdvancedSearchPropertyNames

public void setAdvancedSearchPropertyNames(java.lang.String[] pAdvancedSearchPropertyNames)
Sets property AdvancedSearchPropertyNames

Parameters:
pAdvancedSearchPropertyNames - the property to store advanced search property names.

getAdvancedSearchPropertyNames

public java.lang.String[] getAdvancedSearchPropertyNames()
Returns property AdvancedSearchPropertyNames

Returns:
The value of the property AdvancedSearchPropertyNames

setDoPublishedSearch

public void setDoPublishedSearch(boolean pDoPublishedSearch)
Sets property DoPublishedSearch

Parameters:
pDoPublishedSearch - the property to store the boolean value of whether or not to perform a published search.

isDoPublishedSearch

public boolean isDoPublishedSearch()
Returns property DoPublishedSearch

Returns:
The value of the property DoPublishedSearch

setPublishedSearchPropertyNames

public void setPublishedSearchPropertyNames(java.lang.String[] pPublishedSearchPropertyNames)
Sets property PublishedSearchPropertyNames

Parameters:
pPublishedSearchPropertyNames - the property to store published search property names.

getPublishedSearchPropertyNames

public java.lang.String[] getPublishedSearchPropertyNames()
Returns property PublishedSearchPropertyNames

Returns:
The value of the property PublishedSearchPropertyNames

getPropertyValuesByType

public java.util.HashMap getPropertyValuesByType()
Returns property PropertyValuesByType

Returns:
The value of the property PropertyValuesByType

setPropertyValues

public void setPropertyValues(java.util.Hashtable pPropertyValues)
Sets property PropertyValues

Parameters:
pPropertyValues - the property to store selected property values for advanced searching.

getPropertyValues

public java.util.Hashtable getPropertyValues()
Returns property PropertyValues

Returns:
The value of the property PropertyValues

preSearch

public void preSearch(DynamoHttpServletRequest pRequest,
                      DynamoHttpServletResponse pResponse)
               throws javax.servlet.ServletException,
                      java.io.IOException
Called prior to the search taking place.

Parameters:
pRequest -
pResponse -
Throws:
javax.servlet.ServletException
java.io.IOException

handleSearch

public boolean handleSearch(DynamoHttpServletRequest pRequest,
                            DynamoHttpServletResponse pResponse)
                     throws javax.servlet.ServletException,
                            java.io.IOException
For each item type specified in itemTypes, call generateSearchResultSet to generate a subResultSet for that item type based on query parameters.

Parameters:
pRequest - the servlet's request
pResponse - the servlet's response
Throws:
javax.servlet.ServletException - if there was an error while executing the code
java.io.IOException - if there was an error with servlet io

doSearch

public java.util.Collection doSearch(DynamoHttpServletRequest pRequest,
                                     DynamoHttpServletResponse pResponse)
                              throws javax.servlet.ServletException,
                                     java.io.IOException
Performs the search operation and generates the result set.

Parameters:
pRequest -
pResponse -
Throws:
javax.servlet.ServletException
java.io.IOException

postSearch

public void postSearch(DynamoHttpServletRequest pRequest,
                       DynamoHttpServletResponse pResponse)
                throws javax.servlet.ServletException,
                       java.io.IOException
Called after a search.

Parameters:
pRequest -
pResponse -
Throws:
javax.servlet.ServletException
java.io.IOException

generateSearchValues

protected java.util.Collection generateSearchValues(java.lang.String pSearchType)
generateSearchValues is used by the advanced searching feature. For each property supplied in the property pSearchType, this method will return a list of available search options for that property. Will search through all itemTypes and collect all values for properties. For example, an enumerated property will be defined in the repository item descriptor with a set of values. This method will get possible values from the property descriptor. Other properties may simply be a string type which will require a simple text query

Parameters:
pSearchType - the search type. Typically corresponds to an item descriptor name in the giftlist repository
Returns:
options or null if no values could be found

generateResultSet

protected java.util.Collection generateResultSet(java.lang.String pItemType)
For the supplied item type return a sub-result set that will combined into the total result set. generateResultSet calls generateSearchQuery to build the query string based on options. The resulting query is executed on the Repository View and resultset returned.

Parameters:
pItemType - the type of item to search for. Typically corresponds to an item descriptor name in the catalog repository
Returns:
null if no items could be found

generateSearchQuery

protected Query generateSearchQuery(java.lang.String pItemType,
                                    QueryBuilder pQueryBuilder)
                             throws RepositoryException
Return the query that should be executed on the Repository View. This method attempts to build its query from name and advanced search subqueries. It calls each sub method to build the sub query. The method attempts to build an AND query between text and advanced search queries.

Parameters:
pItemType - the type of item to search for. Typically corresponds to an item descriptor name in the giftlist repository
pQueryBuilder - the builder that should be used to construct the query
Throws:
RepositoryException - if an error occured while forming the query

generateNameSearchQuery

protected Query generateNameSearchQuery(java.lang.String pItemType,
                                        QueryBuilder pQueryBuilder,
                                        java.lang.String pInput)
                                 throws RepositoryException
Return a query which represents a name search query. This method builds a sub-query for each attribute named in the nameSearchPropertyNames property. Each sub-query is OR'd together to form the total query. The search string format is configured with the searchStringFormat property.

Parameters:
pItemType - the type of item to search for. Typically corresponds to an item descriptor name in the catalog repository
pQueryBuilder - the builder that should be used to construct the query
pInput - the search string to use for the full name search
Throws:
RepositoryException - if an error occured while forming the query

generatePublishedSearchQuery

protected Query generatePublishedSearchQuery(java.lang.String pItemType,
                                             QueryBuilder pQueryBuilder)
                                      throws RepositoryException
Generates a published search query to verify that lists are both public and published.

Parameters:
pItemType - the type of item to search for. Typically corresponds to an item descriptor name in the catalog repository
pQueryBuilder - the builder that should be used to construct the query
Throws:
RepositoryException - if an error occured while forming the query

generateAdvancedSearchQuery

protected Query generateAdvancedSearchQuery(java.lang.String pItemType,
                                            QueryBuilder pQueryBuilder)
                                     throws RepositoryException
Return a query which represents an advanced search based on selected property values. This method builds a sub-query for each property found in mAdvancedSearchPropertyNames. If the property type is another repository item, we need to search below this level for the property value. To do this, we append .displayName to the property before searching. All advanced property sub-queries are AND'd together to form the final complete query string.

Parameters:
pItemType - the type of item to search for. Typically corresponds to an item descriptor name in the catalog repository
pQueryBuilder - the builder that should be used to construct the query
Throws:
RepositoryException - if an error occured while forming the query