atg.commerce.collections.filter
Class ExcludeItemsInCartFilter

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

public class ExcludeItemsInCartFilter
extends atg.service.collections.filter.CachedCollectionFilter

This filter generates filtered results based on the products in the current order. All products in the unfiltered collection that are in the current order are excluded from the filtered results.

This filter is useful for filtering upsell products or related products etc. to prevent promoting a product that is already in the cart.

It is strongly recommended that cache not be enabled for this filter because the contents on the shopping cart can change frequently. To enable cache would require that the cache contents, for a given order, be cleared each time a product is either added or removed.


Field Summary
static java.lang.String CLASS_VERSION
           
protected  CatalogTools mCatalogTools
           
protected  java.lang.String mShoppingCartPath
           
 
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
ExcludeItemsInCartFilter()
           
 
Method Summary
protected  java.util.Collection createProductIdCollection(Order pOrder)
          This method creates a collection of product ids.
protected  java.lang.String findCommerceItemProductId(CommerceItem pCommerceItem)
          This method returns the product id associated with a commerce item.
 Order findOrder()
          Finds the current order using the nucleus specified by the shoppginCartPath property.
 java.lang.Object generateContextKey(java.util.Collection pUnfilteredCollection, java.lang.String pCollectionIdentifierKey, RepositoryItem pProfile)
          Generates a context key for this filter.
protected  java.util.Collection generateFilteredCollection(java.util.Collection pUnfilteredCollection, java.lang.String pCollectionIdentifierKey, RepositoryItem pProfile)
          Generates a filtered collection based on the products in the current order.
 CatalogTools getCatalogTools()
          Returns the CatalogTools
 java.lang.String getShoppingCartPath()
          Returns property ShoppingCartPath
 void setCatalogTools(CatalogTools pCatalogTools)
          Sets the CatalogTools
 void setShoppingCartPath(java.lang.String pShoppingCartPath)
          Sets property ShoppingCartPath
 boolean shouldApplyFilter(java.util.Collection pUnfilteredCollection, java.lang.String pKey, RepositoryItem pProfile)
           
 
Methods inherited from class atg.service.collections.filter.CachedCollectionFilter
dumpCache, filterCollection, filterCollection, flushCache, generateCacheKey, generateNewCollectionObject, getCache, getDefaultProfile, isCacheEnabled, setCache, setCacheEnabled, 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, 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

mShoppingCartPath

protected java.lang.String mShoppingCartPath

mCatalogTools

protected CatalogTools mCatalogTools
Constructor Detail

ExcludeItemsInCartFilter

public ExcludeItemsInCartFilter()
Method Detail

setShoppingCartPath

public void setShoppingCartPath(java.lang.String pShoppingCartPath)
Sets property ShoppingCartPath


getShoppingCartPath

public java.lang.String getShoppingCartPath()
Returns property ShoppingCartPath


setCatalogTools

public void setCatalogTools(CatalogTools pCatalogTools)
Sets the CatalogTools


getCatalogTools

public CatalogTools getCatalogTools()
Returns the CatalogTools


findOrder

public Order findOrder()
Finds the current order using the nucleus specified by the shoppginCartPath property.

Returns:
the order

generateContextKey

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

Specified by:
generateContextKey in class atg.service.collections.filter.CachedCollectionFilter
Parameters:
pUnfilteredCollection - the collection to be filtered
pCollectionIdentifierKey - the key that uniquely identifies the unfiltered collection.
Returns:
the order's id.

shouldApplyFilter

public boolean shouldApplyFilter(java.util.Collection pUnfilteredCollection,
                                 java.lang.String pKey,
                                 RepositoryItem pProfile)
Specified by:
shouldApplyFilter in class atg.service.collections.filter.CachedCollectionFilter
Returns:
false if the order does not have commerce items in it.
See Also:
CachedCollectionFilter.shouldApplyFilter(java.util.Collection, java.lang.String, atg.repository.RepositoryItem)

findCommerceItemProductId

protected java.lang.String findCommerceItemProductId(CommerceItem pCommerceItem)
This method returns the product id associated with a commerce item.

Returns:
the product id. Null is returned if the commerce item does not reference a product id in the auxiliary data.

createProductIdCollection

protected java.util.Collection createProductIdCollection(Order pOrder)
This method creates a collection of product ids. A product id is included for each product commerce item in the order.

Parameters:
pOrder - the order
Returns:
a collection of product ids.

generateFilteredCollection

protected java.util.Collection generateFilteredCollection(java.util.Collection pUnfilteredCollection,
                                                          java.lang.String pCollectionIdentifierKey,
                                                          RepositoryItem pProfile)
                                                   throws atg.service.collections.filter.FilterException
Generates a filtered collection based on the products in the current order.

Products in the unfiltered collection that are in the current order are excluded from the filtered results.

If the new filtered collection is the same size as the unfiltered collection, the filtered collection is disgarded and the unfiltered collection is returned.

Specified by:
generateFilteredCollection in class atg.service.collections.filter.CachedCollectionFilter
Parameters:
pUnfilteredCollection - the unfiltered collection
pCollectionIdentifierKey - the key the uniquely identifies the unfiltered collection.
Returns:
the filtered collection
Throws:
atg.service.collections.filter.FilterException