atg.service.collections.filter
Class ChainedFilter

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.service.collections.filter.CachedCollectionFilter
              extended by atg.service.collections.filter.ChainedFilter
All Implemented Interfaces:
NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener

public class ChainedFilter
extends CachedCollectionFilter

This filter chains together two or more CachedCollectionFilters. Each filter in the chain is executed in succession, where the output from one filter becomes input into the next.

See Also:
isCacheEnabled(), generateContextKey(java.util.Collection, java.lang.String, atg.repository.RepositoryItem, java.util.Map), generateFilteredCollection(java.util.Collection, java.lang.String, atg.repository.RepositoryItem, java.util.Map), CachedCollectionFilter

Field Summary
static java.lang.String CLASS_VERSION
           
protected  CachedCollectionFilter[] mFilters
          Sets the array of filters that will be executed in succession to produce the final filtered results.
 
Fields inherited from class atg.service.collections.filter.CachedCollectionFilter
FILTER_CACHE_COMPONENT, mCache, mCacheEnabled
 
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
ChainedFilter()
           
 
Method Summary
 java.lang.Object generateContextKey(java.util.Collection pUnfilteredCollection, java.lang.String pCollectionIdentifierKey, RepositoryItem pProfile, java.util.Map pExtraParameters)
          Generates a context key for the chained filter execution.
protected  java.util.Collection generateFilteredCollection(java.util.Collection pUnfilteredCollection, java.lang.String pCollectionIdentifierKey, RepositoryItem pProfile, java.util.Map pExtraParameters)
          Called by the filterCollection method to generate the filtered collection.
 CachedCollectionFilter[] getFilters()
          Returns the array of filters that will be executed in succession to produce the final filtered results.
 boolean isCacheEnabled()
          Returns if caching is enabled.
 void setFilters(CachedCollectionFilter[] pFilters)
           
 boolean shouldApplyFilter(java.util.Collection pUnfilteredCollection, java.lang.String pCollectionIdentifierKey, RepositoryItem pProfile, java.util.Map pExtraParameters)
          This method is called by filterCollection prior to looking up the filtered collection in the cache or generating a new filtered collection.
 
Methods inherited from class atg.service.collections.filter.CachedCollectionFilter
dumpCache, filterCollection, filterCollection, filterCollection, filterCollection, flushCache, generateCacheKey, generateCacheKey, generateContextKey, generateFilteredCollection, generateNewCollectionObject, getCache, getDefaultProfile, setCache, setCacheEnabled, shouldApplyFilter, stringIt
 
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, reResolveThis, 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
See Also:
Constant Field Values

mFilters

protected CachedCollectionFilter[] mFilters
Sets the array of filters that will be executed in succession to produce the final filtered results.

Constructor Detail

ChainedFilter

public ChainedFilter()
Method Detail

setFilters

public void setFilters(CachedCollectionFilter[] pFilters)

getFilters

public CachedCollectionFilter[] getFilters()
Returns the array of filters that will be executed in succession to produce the final filtered results.


isCacheEnabled

public boolean isCacheEnabled()
Description copied from class: CachedCollectionFilter
Returns if caching is enabled.

This method will return false if the filter does not have a cache component configured.

Overrides:
isCacheEnabled in class CachedCollectionFilter
Returns:
false if configured false. If configured true, checks if cache is enabled on all the filters in the chain. If any of them have their cache disabled, this method will return false.

generateContextKey

public java.lang.Object generateContextKey(java.util.Collection pUnfilteredCollection,
                                           java.lang.String pCollectionIdentifierKey,
                                           RepositoryItem pProfile,
                                           java.util.Map pExtraParameters)
Generates a context key for the chained filter execution. The context key is a list of context objects. There's one context object for each filter in the chain.

Overrides:
generateContextKey in class CachedCollectionFilter
Parameters:
pUnfilteredCollection - the unfiltered collection
pCollectionIdentifierKey - the key that was passed to the filterCollection method.
pProfile - the user profile
pExtraParameters - map containing key-value pairs with extra parameters
Returns:
a list of context keys.

shouldApplyFilter

public boolean shouldApplyFilter(java.util.Collection pUnfilteredCollection,
                                 java.lang.String pCollectionIdentifierKey,
                                 RepositoryItem pProfile,
                                 java.util.Map pExtraParameters)
Description copied from class: CachedCollectionFilter
This method is called by filterCollection prior to looking up the filtered collection in the cache or generating a new filtered collection. Implementations should use this method to bypass the filter when it doesn't apply to the current execution context. (e.g. a profile attribute has the wrong value etc.)

Overrides:
shouldApplyFilter in class CachedCollectionFilter
Parameters:
pUnfilteredCollection - the unfiltered collection
pCollectionIdentifierKey - the key param as passed to filterCollection
pProfile - the user profile
pExtraParameters - key-value pairs with extra parameters
Returns:
true if any one of the filters in the chain returns true from the same method.
See Also:
atg.serivce.collections.filter.CachedCollectionFilter#shouldApplyFilter

generateFilteredCollection

protected java.util.Collection generateFilteredCollection(java.util.Collection pUnfilteredCollection,
                                                          java.lang.String pCollectionIdentifierKey,
                                                          RepositoryItem pProfile,
                                                          java.util.Map pExtraParameters)
                                                   throws FilterException
Called by the filterCollection method to generate the filtered collection. Each filter in the chain is executed in succession, where the output from one filter becomes input into the next.

Each filter in the chain is executed by calling its filterCollection method.

The first filter in the chain is called with consultCache and updateCache as true. All other filters in the chain are called with consultCache and updateCache as false.

This behavior is the same regardless of how the consultCache and updateCache flags are set when the chained filter's filterCollection method is called.

If the pCollectionIdentifierKey is null or empty, all the filters in the chain are executed with the consultCache and updateCache flags as false.

Overrides:
generateFilteredCollection in class CachedCollectionFilter
Parameters:
pUnfilteredCollection - the unfiltered collection
pCollectionIdentifierKey - the key the uniquely identifies the unfiltered collection.
pProfile - user profile
pExtraParameters - extra parameters
Returns:
the filtered collection
Throws:
FilterException