atg.repository.servlet
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.repository.servlet.SearchFormHandler
All Implemented Interfaces:
DropletFormHandler, NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener
Direct Known Subclasses:
SearchFormHandler

public class SearchFormHandler
extends GenericFormHandler

This form handler can be used to search repositories with any combination of several search types: Keyword, Text, Hierarchical, Advanced. Each of these types are enabled with a boolean parameter. The handler examines each boolean and if true, appends that search's subquery to the full query string.

General Properties

Set one or more of the following properties to "true" to enable a search type:

doKeywordSearch
look in multiple text properties for one or more keywords
doTextSearch
perform a full-text search for a specified search string in one or more text properties
doHierarchicalSearch
find all decendents of a specified repository item
doAdvancedSearch
similar to a Keyword search, except that we test properties for an exact match rather than matching substrings within the property

Multiple repositories and item-types can be simultaneously searched. If multiple item-types are searched, each must exist in all repositories. Search results of the same item from multiple repositories are combined. Set the following properties to define the search source(s):

repositories
array of repository components to search
itemTypes
array of the names of the items to search

To control the size of the results, use:

maxRowCount
the maximum number of rows to return. Set to -1 to return all rows. The default value is -1.

To disallow an empty search from being run, use:

allowEmptySearch
If false, the handler will throw a DropletFormException if none of the search types have a non-null or non-blank (if string) value. The default value is "true"

Queries may also be refined and then rerun. When this option is enabled, subsequent searches effectively search the results of the previous query.

allowRefine
set to true to turn on query refining. The default value is "false"
previouslySubmitted
will be set to true if the handler has previously handled a query in the current session (handler must be session-scoped). Property is reset to "false" if the query is cleared.
 

Keyword Search Properties

Keyword searching takes a set of property names and a search string(s). Each property will be searched for these strings. You may also search *ALL* string properties (excluding enumerated and non-queriable properties) of an item by simply leaving the property keywordSearchPropertyNames empty.

keywordSearchPropertyNames
array of property names to search in the format "item-type-name.property-name". Leave empty to search all string properties.
keywords
array of keyword strings to search for. If not set, will use keywordInput property
keywordInput
alternative way to search keywords. Unlike keywords, this property allows logical operators (AND, OR, NOT, &, |, !) and supports parenthesis '(' and ')' to group logic. Quote keyword values with single or double quotes if they include spaces. Quote types may not be mixed. Logical operators are optional; 'OR' will be used by default
toUpperCaseKeywords
set this to "true" to force keywords to be converted to upper-case before the query is run
toLowerCaseKeywords
set this to "true" to force keywords to be converted to lower-case before the query is run
 

Text Search Properties

Text searching takes a list of text property names and an input search string to do text pattern matching. Values entered will be used to build the sub-query for text searching.

textSearchPropertyNames
list of property names to search in the format "item-type-name.property-name". If not specified, the default list of text properties configured in the repository will be used.
searchStringFormat
the format to use i.e. "ORACLE_CONTEXT", "SYBASE_SDS"
textInput
The string to search for. If a repository is configured to simulate full-text queries (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.
allowWildcards
If true, the wildcard character '*' can be used anywhere in the input string to represent any number of characters. True by default.
minScore
minimum required score that the results must meet or exceed in order to be returned by the full-text search engine. See vendor docs for more information on the meaning and use of the score value. [NOTE: Current repository implementations don't yet support this feature of full-text searches.]
 

Hierarchical Search Properties

Hierarchical searches look in a subset of items, starting from a given item, including also that items's child items, and also those children's children, i.e. all descendants of the original item. The given item is indicated by the repository ID in the ancestorId property.

ancestorPropertyName
the name of the property in which to search for ancestor repository items
ancestorId
the property that represents the repositoryId of the ancestor item to search in
 

Advanced Search Properties

Advanced searching takes a list of properties and values or ranges of values for those properties and looks for an exact match. Additionally, the Advanced Search can be used to provide all possible search values for properties specified in AdvancedSearchPropertyNames. For example, enumerated types will be defined in the repository with a set number of values. Advanced searching can retrieve these values to be displayed in a select box.

advancedSearchPropertyNames
list of property names to search. Format: type.property
advancedSearchPropertyValues
propery names mapped to search values. Fortat: type.property=value
advancedSearchPropertyRanges
For each property searched, you can specify a value "range" rather than a single value. Either a maximum or minimum value or both may be specified. Ranges are set by item type, then property name, and finally by "max" or "min". For example, "mySearchHandler.advancedSearchPropertyRanges.product.creationDate.max"
propertyValuesByType
dictionary containing one key/value pair for each property named in advancedSearchPropertyNames whose type is either enumerated, RepositoryItem or a collection of RepositoryItems. The key is the name of the property and the value is a Collection of the possible values. If the property type a collection of RepositoryItems, the value will be a collection of RepositoryItem. Alternatively, if the property type is RepositoryItem a property of each item is returned as described below.
displayName
when a property of an item being searched is another RepositoryItem, by default we search the child item's property named "displayName" if it exists. In the same way, values returned by the property propertyValuesByType will be values of the property "displayName" when the property is a RepositoryItem. Use this property to override the default name of "displayName"
 

Form Actions

In addition to the standard "cancel" action of all form handlers:

search
execute the search and store the results. The Keyword and Text queries are OR'ed together. The Advanced and Hierarchical queries are AND'ed together, and these combined queries are then OR'ed. That is: ( (Keyword OR Text) AND (Advanced AND Hierarchical).
clearQuery
this action is used in combination with the property allowRefine. It will force the previous query to be cleared so that the user may begin refining their query anew.
 

Retrieving Results

Once the query has been performed, the results are available both as a single collection and by item-type:

searchResults
a Collection of all items that satisfied the search criteria. If searching multiple item types, all items returned by the search appear in the list regardless of their type.
searchResultsByItemType
a map containing one key/value pair for each item type you searched for. The key is the item-type name and the value is a Collection of items of that type that satisfied the search criteria. This property should not be used in combination with page navigation.
 
Page Navigation

A set of properties and actions are provided to allow a JHTML developer to create controls which navigate between pages of results. Note that Page Navigation requires that no more than one item type be searched. Use the the following properties to create "Next", "Previous" or "Go to Page #" buttons.

enableCountQuery
turns the page navigation functionality on
maxResultsPerPage
this property represents the maximum number of search results to present on a page. If there are more than maxResultsPerPage that fit the search criteria, the next set of results can be displayed when the user hits a "Next" button. Default value is -1 which indicates no maximum.
currentResultPageNum
the page of the result set is currently being viewed. Be aware that this is a 1 based number so that it is displayable to the user. Set this property to update the set of results for the current page. The default value is 1.
resultSetSize
represents the total number of items matching the query
resultPageCount
the number of pages of results. This is calculated as the resultSetSize / maxResultsPerPage + 1 if any remainder exists
startIndex
the index (0-based, inclusive) of the first record in the full result set which is displayed on the current page. This property is read-only.
endIndex
the index (0-based, exclusive) of the last record in the full result set which is displayed on the current page. This property is read-only.
startCount
the index (1-based, inclusive) of the first record in the full result set which is displayed on the current page. This property this can be used to display the current range of results displayed, i.e. "1-10 out of 100". This property is read-only.
endCount
the index (1-based, inclusive) of the last record in the full result set which is displayed on the current page. This property this can be used to display the current range of results displayed, i.e. "1-10 out of 100". This property is read-only.
 

Redirection

Properties are available for setting a URL for conditional redirection. If a URL parameter is not set, the redirection will not take place.

successURL
used if the query is successful and no form errors are encountered
errorURL
used if query fails or a form error occurs
clearQueryURL
used if the clearQuery action is called


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
static java.lang.String EMPTY_SEARCH_VALUES_DISALLOW
          droplet exception code: cant combine these properties
static java.lang.String GENERATE_VALUES_BY_TYPE_FAILED
          droplet exception code: failed to generate possible values for a property
static java.lang.String INVALID_ITEM_TYPE
          droplet exception code: item specified doesn't exist in repository
static java.lang.String INVALID_KEYWORD_SEARCH_STRING
          droplet exception code: syntax problem in keyword search string
static java.lang.String INVALID_PROP_COMBINATION
          droplet exception code: cant combine these properties
static java.lang.String INVALID_SEARCH_PROPERTY_NAMES
          droplet exception code: searched property names don't exist in item
static java.lang.String MULTIPLE_ITEM_TYPES_DISALLOW
          droplet exception code: cant search multiple item types with navigation
static java.lang.String NO_PROPERTY_NAMES_FOR_ITEM
          droplet exception code: no property names specified for searched item
static java.lang.String QUERY_FAILURE
          droplet exception code: query failed during execution
static java.lang.String UNMATCHED_QUOTES
          logical operator search string parse failed because quotes didn't match
 
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()
           
 
Method Summary
protected  boolean areSearchValuesEmpty()
           
 void beforeGet(DynamoHttpServletRequest request, DynamoHttpServletResponse response)
          Called when a form is rendered that references this bean.
 boolean beforeSet(DynamoHttpServletRequest request, DynamoHttpServletResponse response)
          Called before any setX methods on this form are set when a form that modifies properties of this form handler is submitted.
protected  Query generateAdvancedSearchQuery(Repository pRepository, java.lang.String pItemType, QueryBuilder pQueryBuilder)
          Return a query which represents an advanced search based on selected property values.
protected  Query generateHierarchicalSearchQuery(java.lang.String pItemType, QueryBuilder pQueryBuilder)
          Build a query which represents a hierarchical search, that is, a constraint to look only in a designated item, its child items, and so on, in effect, to all descendants of the designated item.
protected  Query generateKeywordSearchQuery(Repository pRepository, java.lang.String pItemType, QueryBuilder pQueryBuilder)
          Return a query which represents a keyword search.
protected  java.util.Collection generateResultSet(java.lang.String pItemType)
          For the supplied item type return a collection of ==sub-result set that will combined into the total result set.
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 pItemType, java.lang.String pPropertyName)
          Used by the advanced searching feature.
protected  Query generateTextSearchQuery(java.lang.String pItemType, QueryBuilder pQueryBuilder, java.lang.String pInput)
          Return a query which represents a text search query.
 java.lang.String[] getAdvancedSearchPropertyNames()
          Returns property AdvancedSearchPropertyNames
 java.util.HashMap getAdvancedSearchPropertyRanges()
          Returns property AdvancedSearchPropertyRanges
 java.util.HashMap getAdvancedSearchPropertyValues()
          Returns property AdvancedSearchPropertyValues
 boolean getAllowEmptySearch()
          Returns property AllowEmptySearch
 boolean getAllowRefine()
          Returns property AllowRefine
 boolean getAllowWildcards()
          Returns property AllowWildcards
 java.lang.String getAncestorId()
          Returns property AncestorId
 java.lang.String getAncestorPropertyName()
          Returns property ancestorPropertyName
 java.lang.String getClearQueryURL()
          Returns property ClearQueryURL
 int getCurrentResultPageNum()
          Returns property CurrentResultPageNum
 java.lang.String getDisplayName()
          Returns property displayName
 int getEndCount()
          Returns the property EndCount.
 int getEndIndex()
          Returns the property EndIndex.
 java.lang.String getErrorURL()
          Returns property ErrorURL
 java.lang.String[] getItemTypes()
          Returns property ItemTypes
 java.lang.String getKeywordInput()
          Returns property KeywordInput
 java.lang.String[] getKeywords()
          Returns property Keywords
 java.lang.String[] getKeywordSearchPropertyNames()
          Returns property KeywordSearchPropertyNames which is the set of property names for text search
 int getMaxResultsPerPage()
          Returns property maxResultsPerPage
 int getMaxRowCount()
          Returns property maxRowCount
 java.lang.Integer getMinScore()
          Returns property MinScore
 java.util.HashMap getPropertyValuesByType()
          Returns property PropertyValuesByType.
 Repository[] getRepositories()
          Returns property Repositories
 int getResultPageCount()
          Returns the number of results pages which is calculated as the resultSetSize / maxResultsPerPage + 1 if any remainder exists.
 int getResultSetSize()
          Returns property ResultSetSize
 java.util.Collection getSearchResults()
          Returns property SearchResults
 java.util.HashMap getSearchResultsByItemType()
          Returns property SearchResultsByItemType
 java.lang.String getSearchStringFormat()
          Returns property SearchStringFormat
 int getStartCount()
          Returns the property startCount.
 int getStartIndex()
          Returns the property startIndex.
 java.lang.String getSuccessURL()
          Returns property SuccessURL
 java.lang.String getTextInput()
          Returns property TextInput
 java.lang.String[] getTextSearchPropertyNames()
          Returns property TextSearchPropertyNames which is the set of property names for text search
 boolean handleClearQuery(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Called if user requests stored query be cleared.
 boolean handleCurrentResultPageNum(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Called when user is iterating through pages of results.
 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.
protected  boolean isAdvancedSearchPropertyRangesEmpty()
          test if adv search property ranges null or empty
protected  boolean isAdvancedSearchPropertyValuesEmpty()
          test if adv search property values are null or empty
 boolean isDoAdvancedSearch()
          Returns property DoAdvancedSearch
 boolean isDoHierarchicalSearch()
          Returns property DoHierarchicalSearch
 boolean isDoKeywordSearch()
          Returns property DoKeywordSearch
 boolean isDoTextSearch()
          Returns property DoTextSearch
 boolean isEnableCountQuery()
          Returns property enableCountQuery
protected  boolean isPrepared()
          Returns property Prepared
 boolean isPreviouslySubmitted()
          Returns property previouslySubmitted.
 boolean isToLowerCaseKeywords()
          Returns property ToLowerCaseKeywords
 boolean isToUpperCaseKeywords()
          Returns property ToUpperCaseKeywords
 boolean isUseIncludesForKeywordQueryOnMultiProperties()
          Returns property useIncludesForKeywordQueryOnMultiProperties
protected  void prepare(DynamoHttpServletRequest request, DynamoHttpServletResponse response)
          Prepare search properties.
 void setAdvancedSearchPropertyNames(java.lang.String[] pAdvancedSearchPropertyNames)
          Sets property AdvancedSearchPropertyNames
 void setAdvancedSearchPropertyRanges(java.util.HashMap pRanges)
          Sets property AdvancedSearchPropertyRanges
 void setAdvancedSearchPropertyValues(java.util.HashMap pValues)
          Sets property AdvancedSearchPropertyValues
 void setAllowEmptySearch(boolean pAllowEmptySearch)
          Sets property AllowEmptySearch.
 void setAllowRefine(boolean pAllowRefine)
          Sets property AllowRefine.
 void setAllowWildcards(boolean pAllowWildcards)
          Sets property AllowWildcards.
 void setAncestorId(java.lang.String pAncestorId)
          Sets property AncestorId.
 void setAncestorPropertyName(java.lang.String pAncestorPropertyName)
          Sets property ancestorPropertyName
 void setClearQueryURL(java.lang.String pURL)
          Sets property ClearQueryURL.
 void setCurrentResultPageNum(int pCurrentResultPageNum)
          Sets the property currentResultPageNum.
 void setDisplayName(java.lang.String pDisplayName)
          Sets property displayName
 void setDoAdvancedSearch(boolean pDoAdvancedSearch)
          Sets property DoAdvancedSearch
 void setDoHierarchicalSearch(boolean pDoHierarchicalSearch)
          Sets property DoHierarchicalSearch
 void setDoKeywordSearch(boolean pDoKeywordSearch)
          Sets property DoKeywordSearch
 void setDoTextSearch(boolean pDoTextSearch)
          Sets property DoTextSearch
 void setEnableCountQuery(boolean pEnableCountQuery)
          Sets the property enableCountQuery.
 void setEndIndex(int pIndex)
          Set the endIndex to a particular value.
 void setErrorURL(java.lang.String pURL)
          Sets property ErrorURL.
 void setItemTypes(java.lang.String[] pItemTypes)
          Sets property ItemTypes
 void setKeywordInput(java.lang.String pKeywordInput)
          Sets property KeywordInput
 void setKeywords(java.lang.String[] pKeywords)
          Sets property Keywords
 void setKeywordSearchPropertyNames(java.lang.String[] pKeywordSearchPropertyNames)
          Sets property KeywordSearchPropertyNames
 void setMaxResultsPerPage(int pMaxResultsPerPage)
          Sets the property maxResultsPerPage.
 void setMaxRowCount(int pMaxRowCount)
          Sets the property maxRowCount.
 void setMinScore(java.lang.Integer pMinScore)
          Sets property MinScore.
protected  void setPrepared(boolean pPrepared)
          Sets property Prepared.
 void setPropertyValuesByType()
          Sets property PropertyValuesByType.
 void setRepositories(Repository[] pRepositories)
          Sets property: repositories
 void setResultSetSize(int pResultSetSize)
           
 void setSearchStringFormat(java.lang.String pSearchStringFormat)
          Sets property SearchStringFormat used by Text search.
 void setStartIndex(int pIndex)
          Set the startIndex to a particular value.
 void setSuccessURL(java.lang.String pURL)
          Sets property SuccessURL.
 void setTextInput(java.lang.String pTextInput)
          Sets property TextInput used for Text searches.
 void setTextSearchPropertyNames(java.lang.String[] pTextSearchPropertyNames)
          Sets property TextSearchPropertyNames
 void setToLowerCaseKeywords(boolean pToLowerCaseKeywords)
          Sets property ToLowerCaseKeywords
 void setToUpperCaseKeywords(boolean pToUpperCaseKeywords)
          Sets property ToUpperCaseKeywords
 void setUseIncludesForKeywordQueryOnMultiProperties(boolean pUseIncludesForKeywordQueryOnMultiProperties)
          Whether or not to perform an INCLUDES ANY query v/s a LIKE query for keyword search on multi properties
protected  void splitPropertyNames(java.lang.String[] pTypes, java.lang.String[] pSource, java.util.HashMap pDest, java.lang.String pSearchType)
          Split property names into type and name from type.name
protected  java.lang.String[] transformKeywords(java.lang.String[] pKeywords)
          With the supplied keywords perform any modifications that are required to allow it to be used within a keyword query.
 
Methods inherited from class atg.droplet.GenericFormHandler
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
 
Methods inherited from class atg.droplet.EmptyFormHandler
afterGet
 
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 java.lang.String CLASS_VERSION
Class version string


INVALID_SEARCH_PROPERTY_NAMES

public static final java.lang.String INVALID_SEARCH_PROPERTY_NAMES
droplet exception code: searched property names don't exist in item

See Also:
Constant Field Values

GENERATE_VALUES_BY_TYPE_FAILED

public static final java.lang.String GENERATE_VALUES_BY_TYPE_FAILED
droplet exception code: failed to generate possible values for a property

See Also:
Constant Field Values

NO_PROPERTY_NAMES_FOR_ITEM

public static final java.lang.String NO_PROPERTY_NAMES_FOR_ITEM
droplet exception code: no property names specified for searched item

See Also:
Constant Field Values

INVALID_ITEM_TYPE

public static final java.lang.String INVALID_ITEM_TYPE
droplet exception code: item specified doesn't exist in repository

See Also:
Constant Field Values

QUERY_FAILURE

public static final java.lang.String QUERY_FAILURE
droplet exception code: query failed during execution

See Also:
Constant Field Values

INVALID_KEYWORD_SEARCH_STRING

public static final java.lang.String INVALID_KEYWORD_SEARCH_STRING
droplet exception code: syntax problem in keyword search string

See Also:
Constant Field Values

MULTIPLE_ITEM_TYPES_DISALLOW

public static final java.lang.String MULTIPLE_ITEM_TYPES_DISALLOW
droplet exception code: cant search multiple item types with navigation

See Also:
Constant Field Values

INVALID_PROP_COMBINATION

public static final java.lang.String INVALID_PROP_COMBINATION
droplet exception code: cant combine these properties

See Also:
Constant Field Values

EMPTY_SEARCH_VALUES_DISALLOW

public static final java.lang.String EMPTY_SEARCH_VALUES_DISALLOW
droplet exception code: cant combine these properties

See Also:
Constant Field Values

UNMATCHED_QUOTES

public static final java.lang.String UNMATCHED_QUOTES
logical operator search string parse failed because quotes didn't match

See Also:
Constant Field Values
Constructor Detail

SearchFormHandler

public SearchFormHandler()
Method Detail

setPrepared

protected void setPrepared(boolean pPrepared)
Sets property Prepared.


isPrepared

protected boolean isPrepared()
Returns property Prepared


isPreviouslySubmitted

public boolean isPreviouslySubmitted()
Returns property previouslySubmitted.

Returns:
True if the handler has already handled a query.

setAllowEmptySearch

public void setAllowEmptySearch(boolean pAllowEmptySearch)
Sets property AllowEmptySearch. If "false", a droplet form exception will be thrown if none of the active search types are passed search values.

Parameters:
pAllowEmptySearch - a boolean property that determines if passing empty search values is legal.

getAllowEmptySearch

public boolean getAllowEmptySearch()
Returns property AllowEmptySearch

Returns:
The value of the property AllowEmptySearch.

setAllowRefine

public void setAllowRefine(boolean pAllowRefine)
Sets property AllowRefine. If "true", each query effectively searches the results of the previous query.

Parameters:
pAllowRefine - a boolean property that determines if queries can be refined.

getAllowRefine

public boolean getAllowRefine()
Returns property AllowRefine

Returns:
The value of the property AllowRefine.

setDoKeywordSearch

public void setDoKeywordSearch(boolean pDoKeywordSearch)
Sets property DoKeywordSearch

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

isDoKeywordSearch

public boolean isDoKeywordSearch()
Returns property DoKeywordSearch

Returns:
The value of the property DoKeywordSearch.

setUseIncludesForKeywordQueryOnMultiProperties

public void setUseIncludesForKeywordQueryOnMultiProperties(boolean pUseIncludesForKeywordQueryOnMultiProperties)
Whether or not to perform an INCLUDES ANY query v/s a LIKE query for keyword search on multi properties

Parameters:
mUseIncludesForKeywordQueryOnMultiProperties - the property to store the boolean value of whether or not to perform an INCLUDES ANY query v/s a LIKE query for keyword search on multi string properties.

isUseIncludesForKeywordQueryOnMultiProperties

public boolean isUseIncludesForKeywordQueryOnMultiProperties()
Returns property useIncludesForKeywordQueryOnMultiProperties

Returns:
The value of the property DoKeywordSearch.

setDoTextSearch

public void setDoTextSearch(boolean pDoTextSearch)
Sets property DoTextSearch

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

isDoTextSearch

public boolean isDoTextSearch()
Returns property DoTextSearch

Returns:
The value of the property DoTextSearch.

setDoHierarchicalSearch

public void setDoHierarchicalSearch(boolean pDoHierarchicalSearch)
Sets property DoHierarchicalSearch

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

isDoHierarchicalSearch

public boolean isDoHierarchicalSearch()
Returns property DoHierarchicalSearch

Returns:
The value of the property DoHierarchicalSearch

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

setRepositories

public void setRepositories(Repository[] pRepositories)
Sets property: repositories

Parameters:
String[] - the property to store the repositories to search.

getRepositories

public Repository[] getRepositories()
Returns property Repositories

Returns:
The value of the property Repositories

setItemTypes

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

Parameters:
pItemTypes - the property to store the item types to search.

getItemTypes

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

Returns:
The value of the property ItemTypes

setKeywordSearchPropertyNames

public void setKeywordSearchPropertyNames(java.lang.String[] pKeywordSearchPropertyNames)
Sets property KeywordSearchPropertyNames

Parameters:
pKeywordSearchPropertyNames - The property to store the names of all the keyword properties. Expects names to be qualified by item-type (i.e. "item-type.property-name".

getKeywordSearchPropertyNames

public java.lang.String[] getKeywordSearchPropertyNames()
Returns property KeywordSearchPropertyNames which is the set of property names for text search

Returns:
The value of the property KeywordSearchPropertyNames.

setTextSearchPropertyNames

public void setTextSearchPropertyNames(java.lang.String[] pTextSearchPropertyNames)
Sets property TextSearchPropertyNames

Parameters:
pTextSearchPropertyNames - the property to store text search property names.

getTextSearchPropertyNames

public java.lang.String[] getTextSearchPropertyNames()
Returns property TextSearchPropertyNames which is the set of property names for text search

Returns:
The value of the property TextSearchPropertyNames

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 which is the set of property names to search

setAdvancedSearchPropertyRanges

public void setAdvancedSearchPropertyRanges(java.util.HashMap pRanges)
Sets property AdvancedSearchPropertyRanges

Parameters:
Map - of range values (min & max) for Advanced Search property names

getAdvancedSearchPropertyRanges

public java.util.HashMap getAdvancedSearchPropertyRanges()
Returns property AdvancedSearchPropertyRanges

Returns:
map of the range values (min & max) for Advanced Search property names. Structure is map of item-type --> map of property names --> map of mix & max, i.e. product.creationDate.min = "1/1/1999"

isAdvancedSearchPropertyRangesEmpty

protected boolean isAdvancedSearchPropertyRangesEmpty()
test if adv search property ranges null or empty


getPropertyValuesByType

public java.util.HashMap getPropertyValuesByType()
Returns property PropertyValuesByType. Containing one key/value pair for each property named in advancedSearchPropertyNames 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.

Returns:
The value of the property PropertyValuesByType

setPropertyValuesByType

public void setPropertyValuesByType()
Sets property PropertyValuesByType. Contains a map of item-types to maps of property name/values.


getAdvancedSearchPropertyValues

public java.util.HashMap getAdvancedSearchPropertyValues()
Returns property AdvancedSearchPropertyValues

Returns:
The value of the property AdvancedSearchPropertyValues which is the key/value pairs for each property you want to search

setAdvancedSearchPropertyValues

public void setAdvancedSearchPropertyValues(java.util.HashMap pValues)
Sets property AdvancedSearchPropertyValues

Parameters:
pAdvancedSearchPropertyValues - the property to store selected property values for advanced searching. The key is the item type and the value is another map of property name to search values.

isAdvancedSearchPropertyValuesEmpty

protected boolean isAdvancedSearchPropertyValuesEmpty()
test if adv search property values are null or empty


getDisplayName

public java.lang.String getDisplayName()
Returns property displayName

Returns:
The value of the property displayName

setDisplayName

public void setDisplayName(java.lang.String pDisplayName)
Sets property displayName

Parameters:
pDisplayName - the property name to use when an advanced search queries a property that is another RepositoryItem.

setKeywords

public void setKeywords(java.lang.String[] pKeywords)
Sets property Keywords

Parameters:
pKeywords - the property to store keywords to search for in keyword property names. if not set, the property "keywordInput" will be used

getKeywords

public java.lang.String[] getKeywords()
Returns property Keywords

Returns:
The value of the property Keywords which is the target values to search

setKeywordInput

public void setKeywordInput(java.lang.String pKeywordInput)
Sets property KeywordInput

Parameters:
pKeywordInput - the property to store the input search string. Keyword search will use this if keyword property is not set.

getKeywordInput

public java.lang.String getKeywordInput()
Returns property KeywordInput

Returns:
The value of the property KeywordInput.

setAncestorPropertyName

public void setAncestorPropertyName(java.lang.String pAncestorPropertyName)
Sets property ancestorPropertyName

Parameters:
pAncestorPropertyName - the property to store the value of ancestor property name.

getAncestorPropertyName

public java.lang.String getAncestorPropertyName()
Returns property ancestorPropertyName

Returns:
The value of the property ancestorPropertyName

setAncestorId

public void setAncestorId(java.lang.String pAncestorId)
Sets property AncestorId.

Parameters:
pAncestorId - the property to store the repositoryId of the ancestor to search in for Hierarchical searches.

getAncestorId

public java.lang.String getAncestorId()
Returns property AncestorId

Returns:
The value of the property AncestorId

setTextInput

public void setTextInput(java.lang.String pTextInput)
Sets property TextInput used for Text searches.

Parameters:
pTextInput - the property to store the input search string.

getTextInput

public java.lang.String getTextInput()
Returns property TextInput

Returns:
The value of the property TextInput.

setSearchStringFormat

public void setSearchStringFormat(java.lang.String pSearchStringFormat)
Sets property SearchStringFormat used by Text search. If not set, will use the default format.

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.

setAllowWildcards

public void setAllowWildcards(boolean pAllowWildcards)
Sets property AllowWildcards. If "true", the character '*' can be used as a wildcard in the Text search.

Parameters:
pAllowWildcards - a boolean property that determines if Text searching should allow the character '*' to be used as a wildcard

getAllowWildcards

public boolean getAllowWildcards()
Returns property AllowWildcards

Returns:
The value of the property AllowWildcards.

setMinScore

public void setMinScore(java.lang.Integer pMinScore)
Sets property MinScore. Used by Text Searches. Scoring is not yet implemented.

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

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

setMaxRowCount

public void setMaxRowCount(int pMaxRowCount)
Sets the property maxRowCount. The maximum number of rows to return from all combined queries. Set to -1 to disable. Default is -1.

Parameters:
pMaxRowCount - the maximum # of rows to get

getMaxRowCount

public int getMaxRowCount()
Returns property maxRowCount

Returns:
The property MaxRowCount

setEnableCountQuery

public void setEnableCountQuery(boolean pEnableCountQuery)
Sets the property enableCountQuery. If enable CountQuery is true, then we will fill in properties that allow the jhtml programmer to provide next, previous buttons to iterate over the result set. Default is false.

Parameters:
pEnableCountQuery - the property to enable the jhtml programmer to provide next and prev buttons to iterate over a result set.

isEnableCountQuery

public boolean isEnableCountQuery()
Returns property enableCountQuery

Returns:
The property enableCountQuery

setMaxResultsPerPage

public void setMaxResultsPerPage(int pMaxResultsPerPage)
Sets the property maxResultsPerPage. This property represents the maximum number of search results to present on a page. If there are more than maxResultsPerPage that fit the search query, the next set of maxResultsPerPage can be displayed upon the user hitting the next button. Default value is -1 which indicates no maximum.

Parameters:
pMaxResultsPerPage - the property to store the maximum number of results to be displayed per page.

getMaxResultsPerPage

public int getMaxResultsPerPage()
Returns property maxResultsPerPage

Returns:
The maximum number of results to be displayed per page.

setCurrentResultPageNum

public void setCurrentResultPageNum(int pCurrentResultPageNum)
Sets the property currentResultPageNum. This property tells which page of the result set is currently being viewed. The default value is 1, so be aware that this is a 1 based number so it is easy to display to the end user.

Parameters:
pCurrentResultPageNum - the property to tell which page of the result set is currently being viewed.

getCurrentResultPageNum

public int getCurrentResultPageNum()
Returns property CurrentResultPageNum

Returns:
The current result page being viewed.

setResultSetSize

public void setResultSetSize(int pResultSetSize)
Parameters:
pResultSetSize - the property that represents the number of items that match the query.

getResultSetSize

public int getResultSetSize()
Returns property ResultSetSize

Returns:
The number of items that match the query.

getResultPageCount

public int getResultPageCount()
Returns the number of results pages which is calculated as the resultSetSize / maxResultsPerPage + 1 if any remainder exists.

Returns:
the number of results pages which is calculated as the resultSetSize/maxResultsPerPage + 1.

getStartIndex

public int getStartIndex()
Returns the property startIndex. This is the index (0-based) into the full result set which is displayed on the current page.

Returns:
the start index (0-based) into the full result set which is displayed on the current page.

setStartIndex

public void setStartIndex(int pIndex)
Set the startIndex to a particular value. In general you should not modify the start index without very good reason, e.g. you are implementing a subclass of SearchFormHandler that modifies the search results in some way and needs to make sure the indices represent your modified result set.


getEndIndex

public int getEndIndex()
Returns the property EndIndex. This is the index (0-based) into the full result set which is displayed on the current page.

Returns:
the end index (0-based) into the full result set which is displayed on the current page.

setEndIndex

public void setEndIndex(int pIndex)
Set the endIndex to a particular value. In general you should not modify the end index without very good reason, e.g. you are implementing a subclass of SearchFormHandler that modifies the search results in some way and needs to make sure the indices represent your modified result set.


getStartCount

public int getStartCount()
Returns the property startCount. This is the index (1-based) into the full result set which is displayed on the current page.

Returns:
the start index (1-based) into the full result set which is displayed on the current page.

getEndCount

public int getEndCount()
Returns the property EndCount. This is the index (1-based) into the full result set which is displayed on the current page.

Returns:
the end index (1-based) into the full result set which is displayed on the current page.

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

setSuccessURL

public void setSuccessURL(java.lang.String pURL)
Sets property SuccessURL. If search is successful, hander redirects client to this URL.

Parameters:
pURL - a String property that is the URL to redirect to.

getSuccessURL

public java.lang.String getSuccessURL()
Returns property SuccessURL

Returns:
The value of the property SuccessURL.

setErrorURL

public void setErrorURL(java.lang.String pURL)
Sets property ErrorURL. If search fails, hander redirects client to this URL. For example, RepositoryException thrown

Parameters:
pURL - a String property that is the URL to redirect to.

getErrorURL

public java.lang.String getErrorURL()
Returns property ErrorURL

Returns:
The value of the property ErrorURL.

setClearQueryURL

public void setClearQueryURL(java.lang.String pURL)
Sets property ClearQueryURL. If the Query is cleared, the form redirects to this URL.

Parameters:
pURL - a String property that is the URL to redirect to.

getClearQueryURL

public java.lang.String getClearQueryURL()
Returns property ClearQueryURL

Returns:
The value of the property ClearQueryURL.

handleSearch

public boolean handleSearch(DynamoHttpServletRequest pRequest,
                            DynamoHttpServletResponse pResponse)
                     throws javax.servlet.ServletException,
                            java.io.IOException
For each each item type in that repository, call generateSearchResultSet to generate a subResultSet for that item type based on query parameters. Each subResultSet will be both merged together in resultSet as well as stored in the property SearchResultsByItemType by item type.

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

handleCurrentResultPageNum

public boolean handleCurrentResultPageNum(DynamoHttpServletRequest pRequest,
                                          DynamoHttpServletResponse pResponse)
                                   throws javax.servlet.ServletException,
                                          java.io.IOException
Called when user is iterating through pages of results. Instead of requerying, we set pointers to start and end of page results.

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

handleClearQuery

public boolean handleClearQuery(DynamoHttpServletRequest pRequest,
                                DynamoHttpServletResponse pResponse)
                         throws javax.servlet.ServletException,
                                java.io.IOException
Called if user requests stored query be cleared. Will redirect to ClearQuery url if non-null and no errors have occured.

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

beforeGet

public void beforeGet(DynamoHttpServletRequest request,
                      DynamoHttpServletResponse response)
Called when a form is rendered that references this bean. This call is made before the service method of the page is invoked.

Specified by:
beforeGet in interface DropletFormHandler
Overrides:
beforeGet in class EmptyFormHandler

beforeSet

public boolean beforeSet(DynamoHttpServletRequest request,
                         DynamoHttpServletResponse response)
                  throws DropletFormException
Called before any setX methods on this form are set when a form that modifies properties of this form handler is submitted.

Specified by:
beforeSet in interface DropletFormHandler
Overrides:
beforeSet in class GenericFormHandler
Returns:
true if form processing should continue, false if it should be aborted
Throws:
DropletFormException

areSearchValuesEmpty

protected boolean areSearchValuesEmpty()

generateSearchQuery

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

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

generateKeywordSearchQuery

protected Query generateKeywordSearchQuery(Repository pRepository,
                                           java.lang.String pItemType,
                                           QueryBuilder pQueryBuilder)
                                    throws RepositoryException,
                                           DropletFormException
Return a query which represents a keyword search. If keywords property is set, this method builds a sub-query for each attribute named in the KeywordSearchPropertyNames 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 CONTAINS comparison query. If keywords is empty, keywordInput is used to build an RQL statement instead.

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

generateTextSearchQuery

protected Query generateTextSearchQuery(java.lang.String pItemType,
                                        QueryBuilder pQueryBuilder,
                                        java.lang.String pInput)
                                 throws RepositoryException
Return a query which represents a text search query. This method builds a sub-query for each attribute named in the textSearchPropertyNames 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.
pQueryBuilder - the builder that should be used to construct the query
pInput - the search string to use for the full text search
Throws:
RepositoryException - if an error occured while forming the query

generateAdvancedSearchQuery

protected Query generateAdvancedSearchQuery(Repository pRepository,
                                            java.lang.String pItemType,
                                            QueryBuilder pQueryBuilder)
                                     throws RepositoryException,
                                            DropletFormException
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:
pRepository - the repository to search
pItemType - the type of item to search for.
pQueryBuilder - the builder that should be used to construct the query
Throws:
RepositoryException - if an error occured while forming the query
DropletFormException

generateHierarchicalSearchQuery

protected Query generateHierarchicalSearchQuery(java.lang.String pItemType,
                                                QueryBuilder pQueryBuilder)
                                         throws RepositoryException
Build a query which represents a hierarchical search, that is, a constraint to look only in a designated item, its child items, and so on, in effect, to all descendants of the designated item. The designated item is indicated by repository ID in the ancestorId property. If that repository ID is null or null string, then this method generates a null query.

Note: this query assumes that the item type being searched for has a property (as indicated by the value of theancestorPropertyName property) whose value is a collection of all its ancestor groups. If the designated item is contained in this collection, then this query returns true.

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

generateSearchValues

protected java.util.Collection generateSearchValues(java.lang.String pItemType,
                                                    java.lang.String pPropertyName)
Used by the advanced searching feature. Returns a list of available search options for pPropertyName. 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 need a repository query to obtain those options. This collection of searchValues can then be displayed in a select box to further refine advanced searching.

Parameters:
pItemType - item of the property to search for possible values
pPropertyName - name of the property to get possible values for
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 collection of ==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.
Returns:
null if no items could be found

splitPropertyNames

protected void splitPropertyNames(java.lang.String[] pTypes,
                                  java.lang.String[] pSource,
                                  java.util.HashMap pDest,
                                  java.lang.String pSearchType)
Split property names into type and name from type.name


transformKeywords

protected java.lang.String[] transformKeywords(java.lang.String[] pKeywords)
With the supplied keywords perform any modifications that are required to allow it to be used within a keyword query. This implementation checks the toLowerCaseKeywords and toUpperCaseKeywords properties to determine if String.toLowerCase or String.toUpperCase should be invoked.

Parameters:
pKeywords - the words to transform for querying

prepare

protected void prepare(DynamoHttpServletRequest request,
                       DynamoHttpServletResponse response)
Prepare search properties.