com.endeca.portal.data
Class DefaultMDEXStateManager

java.lang.Object
  extended by com.endeca.portal.data.AbstractMDEXStateManager
      extended by com.endeca.portal.data.DefaultMDEXStateManager
All Implemented Interfaces:
MDEXStateManager, java.io.Serializable

public class DefaultMDEXStateManager
extends AbstractMDEXStateManager

This is an implementation of MDEXStateManager covering a very simple parent-child relationship of data sources. This model covers data sources with a single ancestor, and allows child data sources to add additional static functions to queries inherited from their ancestor. These static functions are whatever functions were configured in the data source's 'baseFunctions' property. "setting" a query on a data source with an ancestor results in actually setting the query on the ancestor, sans whatever static functions were initially configured on the child. This implementation can be useful for simplistic applications where either no relationships exist between MDEXStates or where they are only used to, for example, put RecordType filters (or some other static record filter) on different pages/tabs that otherwise share the same query state.

Author:
Endeca Technologies, Inc.
See Also:
Serialized Form

Field Summary
protected static org.apache.log4j.Logger logger
           
 
Constructor Summary
DefaultMDEXStateManager()
          default constructor
 
Method Summary
protected  UserSession fetchUserSession(javax.portlet.PortletRequest request)
          Method to fetch the current UserSession.
protected  java.util.List<QueryFunction> getSubtractedFilterList(QueryState baseState, QueryState stateToSubtract)
           
 QueryState handleStateInitial(javax.portlet.PortletRequest request, MDEXState mdexState)
          Returns a QueryState that is the union of all QueryFunctions on this MDEXState's initial definition and all of this MDEXState's parents' initial definitions
 QueryState handleStateMerge(javax.portlet.PortletRequest request, MDEXState mdexState)
          Returns a QueryState that is the union of all QueryFunctions on this MDEXState and all of this MDEXState's parents.
 void handleStateReset(javax.portlet.PortletRequest request, MDEXState mdexState)
          Resets all MDEXStates in this MDEXState's hierarchy, then fires events for all MDEXStates in that same hierarchy.
 void handleStateUpdate(javax.portlet.PortletRequest request, MDEXState mdexState, QueryState newQueryState)
          Sets the given QueryState onto this MDEXState's root parent, then fires events for all MDEXStates in this MDEXState's hierarchy.
protected  void publishEventTriggersForStateAndDescendants(javax.portlet.PortletRequest request, MDEXState mdexState, UserSession userSession)
          Publishes an event trigger for a data source change event on this state and all of its descendant states.
 
Methods inherited from class com.endeca.portal.data.AbstractMDEXStateManager
addEventTrigger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static org.apache.log4j.Logger logger
Constructor Detail

DefaultMDEXStateManager

public DefaultMDEXStateManager()
default constructor

Method Detail

handleStateMerge

public QueryState handleStateMerge(javax.portlet.PortletRequest request,
                                   MDEXState mdexState)
                            throws QueryStateException
Returns a QueryState that is the union of all QueryFunctions on this MDEXState and all of this MDEXState's parents. The returned QueryState is independent of the supplied MDEXState's QueryState - the source state is first deep-cloned.

Specified by:
handleStateMerge in interface MDEXStateManager
Specified by:
handleStateMerge in class AbstractMDEXStateManager
Parameters:
request - the current PortletRequest
mdexState - the MDEXState representing the current data source
Returns:
the portlet-visible QueryState as determined by the request and mdexState
Throws:
QueryStateException
See Also:
AbstractMDEXStateManager.handleStateMerge(javax.portlet.PortletRequest, com.endeca.portal.data.MDEXState)

handleStateUpdate

public void handleStateUpdate(javax.portlet.PortletRequest request,
                              MDEXState mdexState,
                              QueryState newQueryState)
                       throws QueryStateException
Sets the given QueryState onto this MDEXState's root parent, then fires events for all MDEXStates in this MDEXState's hierarchy.

Specified by:
handleStateUpdate in interface MDEXStateManager
Specified by:
handleStateUpdate in class AbstractMDEXStateManager
Parameters:
request - the current PortletRequest
mdexState - the MDEXState representing the current data source
newQueryState - the query state to be set onto the data source
Throws:
QueryStateException
See Also:
AbstractMDEXStateManager.handleStateUpdate(javax.portlet.PortletRequest, com.endeca.portal.data.MDEXState, com.endeca.portal.data.QueryState)

handleStateReset

public void handleStateReset(javax.portlet.PortletRequest request,
                             MDEXState mdexState)
                      throws QueryStateException
Resets all MDEXStates in this MDEXState's hierarchy, then fires events for all MDEXStates in that same hierarchy.

Specified by:
handleStateReset in interface MDEXStateManager
Specified by:
handleStateReset in class AbstractMDEXStateManager
Parameters:
request - the PortletRequest
mdexState - the current data source state
Throws:
QueryStateException - on error
See Also:
AbstractMDEXStateManager.handleStateReset(javax.portlet.PortletRequest, com.endeca.portal.data.MDEXState)

handleStateInitial

public QueryState handleStateInitial(javax.portlet.PortletRequest request,
                                     MDEXState mdexState)
                              throws QueryStateException
Returns a QueryState that is the union of all QueryFunctions on this MDEXState's initial definition and all of this MDEXState's parents' initial definitions

Specified by:
handleStateInitial in interface MDEXStateManager
Specified by:
handleStateInitial in class AbstractMDEXStateManager
Parameters:
request - the current PortletRequest
mdexState - the MDEXState representing the current data source
Returns:
the portlet-visible initial QueryState as determined by the request and mdexState
Throws:
QueryStateException
See Also:
AbstractMDEXStateManager.handleStateMerge(javax.portlet.PortletRequest, com.endeca.portal.data.MDEXState)

getSubtractedFilterList

protected java.util.List<QueryFunction> getSubtractedFilterList(QueryState baseState,
                                                                QueryState stateToSubtract)

publishEventTriggersForStateAndDescendants

protected void publishEventTriggersForStateAndDescendants(javax.portlet.PortletRequest request,
                                                          MDEXState mdexState,
                                                          UserSession userSession)
Publishes an event trigger for a data source change event on this state and all of its descendant states.

Parameters:
request - current request
mdexState - mdexState undergoing state change
userSession - current user session

fetchUserSession

protected UserSession fetchUserSession(javax.portlet.PortletRequest request)
                                throws UserSessionException
Method to fetch the current UserSession. The separate method facilitates testing.

Parameters:
request - the current request
Returns:
the UserSession associated with the current request
Throws:
UserSessionException