com.endeca.portal.data.functions
Class QueryFunction

java.lang.Object
  extended by com.endeca.portal.data.functions.QueryFunction
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
QueryConfig, QueryFilter

public abstract class QueryFunction
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

The base class of all QueryFunctions. Wraps functionality for serializing and deserializing, cloning, and comparing. Refer to subclasses for specific types of functions.

Subclassing

For Semantic reasons, you should usually consider subclassing either QueryFilter or QueryConfig, not this class directly. Other than that, simply pay attention to the abstract methods in this class and your toString() implementation.

See Also:
QueryFilter, QueryConfig, Serialized Form

Field Summary
static java.lang.String CLASS_PROPERTY
           
static java.lang.String VIEWKEY_PROPERTY
           
 
Constructor Summary
protected QueryFunction()
           
 
Method Summary
abstract  void applyToDiscoveryServiceQuery(com.endeca.mdex.conversation.Request query, java.lang.String stateName)
          Apply this function to a Request.
 void beforeQueryStateAdd(QueryState state)
          Function to check for any additional conditions when adding to the query state.
 void beforeQueryStateRemove(QueryState state)
           
 QueryFunction clone()
           
 boolean equals(java.lang.Object other)
           
 boolean equals(QueryFunction other)
          Compares two QueryFunction instances by checking class types and using the object's toString() method
 java.lang.String getCompareString()
          Return the compare string of QueryFunctions instance the default value get from toString method.
 java.lang.String getName()
          Retrieve the name.
 int getVersion()
          Retrieve the version.
 java.lang.String getViewKey()
          Indicates the view against which this function applies.
 int hashCode()
           
 void initializeFromJSON(MDEXState mdexState)
          This method is called when constructing a MDEXState's initialQueryState from a json object.
 boolean passesSelectiveFilter(java.util.List<java.lang.String> selectiveRefinements)
          Override this method for each query filter that can be restricted by the selective refinements state manager feature.
 void setName(java.lang.String name)
          Set the name.
 void setVersion(int version)
          Set the version.
 void setViewKey(java.lang.String viewKey)
          Sets the view against which this function applies.
 void substituteAttributeKeys(AttributeKeyConverter attributeKeyConverter, java.util.Locale currentLocale)
          Substitute the attribute keys in the QueryFunction with new values specified in attributeKeyMap
abstract  java.lang.String toString()
          This class' toString is abstract: all concrete subclasses are expected to provide an implementation. toString is used in comparing QueryFunction instances for equality, so if you implement a QueryFunction subclass it is important that your toString implementation be consistent and deterministic.
 QueryFunction upgrade()
          Upgrade the query function in the case of an upgrade.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASS_PROPERTY

public static final java.lang.String CLASS_PROPERTY
See Also:
Constant Field Values

VIEWKEY_PROPERTY

public static final java.lang.String VIEWKEY_PROPERTY
See Also:
Constant Field Values
Constructor Detail

QueryFunction

protected QueryFunction()
Method Detail

getName

public java.lang.String getName()
Retrieve the name.

Returns:
the name

setName

public void setName(java.lang.String name)
Set the name.

Parameters:
name - the name to set

getViewKey

public java.lang.String getViewKey()
Indicates the view against which this function applies.

Returns:
the view key
Since:
Collections 3.1 epic

setViewKey

public void setViewKey(java.lang.String viewKey)
Sets the view against which this function applies.

Parameters:
the - view key
Since:
Collections 3.1 epic

getVersion

public int getVersion()
Retrieve the version.

Returns:
the version

setVersion

public void setVersion(int version)
Set the version.

Parameters:
version - the version to set

upgrade

public QueryFunction upgrade()
Upgrade the query function in the case of an upgrade.


applyToDiscoveryServiceQuery

public abstract void applyToDiscoveryServiceQuery(com.endeca.mdex.conversation.Request query,
                                                  java.lang.String stateName)
                                           throws QueryFunctionUnsupportedException
Apply this function to a Request. Must be implemented by subclass.

Parameters:
query - the CS Request to which this function should be applied
stateName - stateName to use for filters or content element configs
Throws:
QueryFunctionUnsupportedException

substituteAttributeKeys

public void substituteAttributeKeys(AttributeKeyConverter attributeKeyConverter,
                                    java.util.Locale currentLocale)
Substitute the attribute keys in the QueryFunction with new values specified in attributeKeyMap

Parameters:
attributeKeyMap -

toString

public abstract java.lang.String toString()
This class' toString is abstract: all concrete subclasses are expected to provide an implementation. toString is used in comparing QueryFunction instances for equality, so if you implement a QueryFunction subclass it is important that your toString implementation be consistent and deterministic.

Overrides:
toString in class java.lang.Object

getCompareString

public java.lang.String getCompareString()
Return the compare string of QueryFunctions instance the default value get from toString method.

Returns:
String

clone

public QueryFunction clone()
Overrides:
clone in class java.lang.Object

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

equals

public boolean equals(QueryFunction other)
Compares two QueryFunction instances by checking class types and using the object's toString() method

Parameters:
other -
Returns:
true if this QueryFunction equals the other

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

beforeQueryStateAdd

public void beforeQueryStateAdd(QueryState state)
Function to check for any additional conditions when adding to the query state. The base function won't do anything, but can be overridden as necessary.


beforeQueryStateRemove

public void beforeQueryStateRemove(QueryState state)

initializeFromJSON

public void initializeFromJSON(MDEXState mdexState)
                        throws QueryFunctionInitializationException
This method is called when constructing a MDEXState's initialQueryState from a json object. Subclasses should override and implement this method if they desire to execute code upon initialization from json. The ArbitraryLQLASTFilter classes use this technique to allow different params/member vars for initialization from json vs. initialization programmatically from within Java.

Parameters:
mdexState - the MDEXState object on which this QueryFunction exists
Throws:
QueryFunctionInitializationException

passesSelectiveFilter

public boolean passesSelectiveFilter(java.util.List<java.lang.String> selectiveRefinements)
Override this method for each query filter that can be restricted by the selective refinements state manager feature. Determines whether or not the filter is valid for the current data source, given a list of valid attributes.

Parameters:
selectiveRefinements - List of selective refinement attributes that are valid for the current data source.
Returns:
true if the filter is valid for the current data source