atg.service.collections.filter
Class StartEndDateFilter

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.StartEndDateFilter
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 StartEndDateFilter
extends CachedCollectionFilter

This filter will filter objects in the collection by the startDate and endDate properties. If the current date falls between the startDate and endDate values then the object is included in the filtered collection.


Field Summary
static java.lang.String CLASS_VERSION
           
protected  java.lang.String mEndDatePropertyName
           
protected  java.lang.String mStartDatePropertyName
           
 
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
StartEndDateFilter()
           
 
Method Summary
 java.lang.Object generateContextKey(java.util.Collection pUnfilteredCollection, java.lang.String pCollectionIdentifierKey, RepositoryItem pProfile)
          Generates a context key.
protected  java.util.Collection generateFilteredCollection(java.util.Collection pUnfilteredCollection, java.lang.String pCollectionIdentifierKey, RepositoryItem pProfile)
          Generates a filtered collection based on the start and end date properties.
protected  java.util.Date getDatePropertyFromObject(java.lang.Object pObject, java.lang.String pDatePropertyName)
          This method is called by generateFilteredCollection to extract the value from a date property using DynamicBeans.getPropertyValue(pObject,pDatePropertyName)
 java.lang.String getEndDatePropertyName()
          Returns the property name used to get the end date
 java.lang.String getStartDatePropertyName()
          Returns the property name used to get the start date
 void setEndDatePropertyName(java.lang.String pEndDatePropertyName)
          Sets the property name used to get the end date
 void setStartDatePropertyName(java.lang.String pStartDatePropertyName)
          Sets the property name used to get the start date
 boolean shouldApplyFilter(java.util.Collection pUnfilteredCollection, java.lang.String pKey, RepositoryItem pProfile)
          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, isCacheEnabled, 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

mStartDatePropertyName

protected java.lang.String mStartDatePropertyName

mEndDatePropertyName

protected java.lang.String mEndDatePropertyName
Constructor Detail

StartEndDateFilter

public StartEndDateFilter()
Method Detail

setStartDatePropertyName

public void setStartDatePropertyName(java.lang.String pStartDatePropertyName)
Sets the property name used to get the start date


getStartDatePropertyName

public java.lang.String getStartDatePropertyName()
Returns the property name used to get the start date


setEndDatePropertyName

public void setEndDatePropertyName(java.lang.String pEndDatePropertyName)
Sets the property name used to get the end date


getEndDatePropertyName

public java.lang.String getEndDatePropertyName()
Returns the property name used to get the end date


shouldApplyFilter

public boolean shouldApplyFilter(java.util.Collection pUnfilteredCollection,
                                 java.lang.String pKey,
                                 RepositoryItem pProfile)
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
pKey - the key param as passed to filterCollection
pProfile - the user profile
Returns:
true by default
See Also:
CachedCollectionFilter.shouldApplyFilter(java.util.Collection, java.lang.String, atg.repository.RepositoryItem)

generateContextKey

public java.lang.Object generateContextKey(java.util.Collection pUnfilteredCollection,
                                           java.lang.String pCollectionIdentifierKey,
                                           RepositoryItem pProfile)
Generates a context key.

Overrides:
generateContextKey in class CachedCollectionFilter
Returns:
the current date as a string(yyyyMMdd).

getDatePropertyFromObject

protected java.util.Date getDatePropertyFromObject(java.lang.Object pObject,
                                                   java.lang.String pDatePropertyName)
This method is called by generateFilteredCollection to extract the value from a date property using DynamicBeans.getPropertyValue(pObject,pDatePropertyName)

If the date property does not exist or it is not a type of Date, then null is returned.

Extend this method if the date property is not of type java.util.Date, such as a string, and convert the property value to an appropriate Date object.

Returns:
Date the date property value

generateFilteredCollection

protected java.util.Collection generateFilteredCollection(java.util.Collection pUnfilteredCollection,
                                                          java.lang.String pCollectionIdentifierKey,
                                                          RepositoryItem pProfile)
                                                   throws FilterException
Generates a filtered collection based on the start and end date properties.

All objects in the collection are expected to have a start and end date property.

Objects that have a startDate less than or equal to the current date, and an endDate greater than or equal to the current date are added to the filter collection.

A null startDate or missing startDate property is considered to be always started
A null endDate or missing endDate property is considered to be never ending.

A startDate and/or endDate property that is not of type java.util.Date is considered to be always started or never ending respectively. This behavior can be changed by overriding getDatePropertyFromObject If the new filtered collection is the same size as the unfiltered collection, the filtered collection is disgarded and the unfiltered collection is returned.

Overrides:
generateFilteredCollection in class CachedCollectionFilter
Parameters:
pUnfilteredCollection - the unfiltered collection
pCollectionIdentifierKey - the key the uniquely identifies the unfiltered collection.
pProfile - Repository item
Returns:
the filtered collection
Throws:
FilterException
See Also:
getDatePropertyFromObject(java.lang.Object, java.lang.String)