com.ibm.commerce.marketing.commands.marketingspot

Class FilterCatalogEntryTaskCmdImpl

  • All Implemented Interfaces:
    FilterCatalogEntryTaskCmd, MarketingSpotCommandBaseTaskCmd, com.ibm.websphere.cache.Sizeable, com.ibm.websphere.command.CacheableCommand, com.ibm.websphere.command.Command, com.ibm.websphere.command.CommandCaller, com.ibm.websphere.command.TargetableCommand, java.io.Serializable


    public class FilterCatalogEntryTaskCmdImpl
    extends MarketingSpotCommandBaseTaskCmdImpl
    implements FilterCatalogEntryTaskCmd, com.ibm.websphere.cache.Sizeable
    This command loads the specified catalog entry by calling the RetrieveCatalogEntryTaskCmd command. Then this command checks if the specified catalog entry qualifies for the defined filtering criteria or not. To enable or disable a filter, register the appropriate CMDREG table entry, and set the filter settings in the PROPERTIES column. See the file samples/samples/dynacache/marketing/cachespec.xml for details about caching this command. Filters that can be cached (such as check if in the current catalog) are evaluated in the performExecute method. Filters that cannot be cached (such as check if in current shopping cart) are evaluated in the postFilter method. If a custom filter is added, and the evaluation can be cached, then extend the method removeCatalogEntry. If a custom filter is added, and the evaluation cannot be cached, then extend the method postFilter. The following is the process to add a new catalog entry filter:
    1. Extend FilterCatalogEntryTaskCmdImpl, and register a new CMDREG entry for your store.
    2. For the new filter added in the CMDREG properties, (for example: myFilter=true), add the following methods:
      • public void setMyFilterString setting);
      • public String getMyFilter();
      These methods will be called automatically by the Commerce framework so that you can get the setting of the filter.
    3. Extend the method boolean removeCatalogEntry(MarketingSpotActivityCatalogEntryDataType catalogEntry); In this method, do the checking for the new filter (use getMyFilter to get the value of the setting). This method should return true if the filter checking determines that the catalog entry should not be displayed to the customer. Otherwise return false, and the catalog entry will get displayed in the eMarketing Spot.
    4. Extend the method boolean postFilter(MarketingSpotActivityCatalogEntryDataType catalogEntry); In this method, do the checking for the new filter (use getMyFilter to get the value of the setting). This method should return true if the filter checking determines that the catalog entry should not be displayed to the customer. Otherwise return false, and the catalog entry will get displayed in the eMarketing Spot.
    See Also:
    Serialized Form
    • Field Detail

      • COPYRIGHT

        public static final java.lang.String COPYRIGHT
        IBM copyright notice field.
        See Also:
        Constant Field Values
      • CLASSNAME

        public static final java.lang.String CLASSNAME
        The name of this class.
        See Also:
        Constant Field Values
    • Constructor Detail

      • FilterCatalogEntryTaskCmdImpl

        public FilterCatalogEntryTaskCmdImpl()
        Default constructor for this command.
    • Method Detail

      • getObjectSize

        public long getObjectSize()
        Returns the estimated footprint size in bytes of this object and the objects it contains.
        Specified by:
        getObjectSize in interface com.ibm.websphere.cache.Sizeable
        Overrides:
        getObjectSize in class MarketingSpotCommandBaseTaskCmdImpl
        Returns:
        the estimated footprint size in bytes or -1 if a size cannot be determined.
      • setRemoveIfNoInventory

        public void setRemoveIfNoInventory(java.lang.String setting)
        This method sets if catalog entries should not be displayed if their inventory level is below the specified value.
        Parameters:
        setting - Set "0" if the inventory level should not be checked, otherwise set the inventory level which needs to be met in order for the catalog entry to be displayed to the customer.
      • getRemoveIfNoInventory

        public java.lang.String getRemoveIfNoInventory()
        This method gets if catalog entries should not be displayed if their inventory level is below the specified value.
        Returns:
        Returns "0" if the inventory level should not be checked, otherwise it returns the inventory level which needs to be met in order for the catalog entry to be displayed to the customer.
      • setRemoveIfExistInShopcart

        public void setRemoveIfExistInShopcart(java.lang.String setting)
        This method sets if catalog entries should not be displayed if they are currently in the shopper's shopping cart.
        Parameters:
        setting - Set "1" if catalog entries should not be displayed if they are currently in the shopper's shopping cart, otherwise set "0".
      • getRemoveIfExistInShopcart

        public java.lang.String getRemoveIfExistInShopcart()
        This method returns if catalog entries should not be displayed if they are currently in the shopper's shopping cart.
        Returns:
        Returns "1" if catalog entries should not be displayed if they are currently in the shopper's shopping cart, otherwise returns "0".
      • setRemoveIfExistInPurchaseHistory

        public void setRemoveIfExistInPurchaseHistory(java.lang.String setting)
        This method sets if catalog entries should not be displayed if they are currently in the shopper's purchase history.
        Parameters:
        setting - Set "1" if catalog entries should not be displayed if they are currently in the shopper's purchase history, otherwise set "0".
      • getRemoveIfExistInPurchaseHistory

        public java.lang.String getRemoveIfExistInPurchaseHistory()
        This method returns if catalog entries should not be displayed if they are currently in the shopper's purchase history.
        Returns:
        Returns "1" if catalog entries should not be displayed if they are currently in the shopper's purchase history, otherwise returns "0".
      • setRemoveIfPastEndDate

        public void setRemoveIfPastEndDate(java.lang.String setting)
        This method sets if catalog entries should not be displayed if their end date is before the current date.
        Parameters:
        setting - Set "1" if catalog entries should not be displayed if the end date has passed, otherwise set "0".
      • getRemoveIfPastEndDate

        public java.lang.String getRemoveIfPastEndDate()
        This method gets if catalog entries should not be displayed if their end date is before the current date.
        Returns:
        Returns "1" if catalog entries should not be displayed if the end date has passed, otherwise returns "0".
      • setRemoveIfNotInCurrentCatalog

        public void setRemoveIfNotInCurrentCatalog(java.lang.String setting)
        This method sets if catalog entries should not be displayed if they are not in the catalog currently being viewed by the customer.
        Parameters:
        setting - Set "1" if catalog entries should not be displayed if they are not in the catalog currently being viewed by the customer, otherwise set "0".
      • getRemoveIfNotInCurrentCatalog

        public java.lang.String getRemoveIfNotInCurrentCatalog()
        This method gets if catalog entries should not be displayed if they are not in the catalog currently being viewed by the customer.
        Returns:
        Returns "1" if catalog entries should not be displayed if they are not in the catalog currently being viewed by the customer, otherwise returns "0".
      • setRemoveIfNotEntitled

        public void setRemoveIfNotEntitled(java.lang.String setting)
        This method sets if catalog entries should not be displayed if they are not entitled to being viewed by the customer.
        Parameters:
        setting - Set "1" if catalog entries should not be displayed if they are not entitled to being viewed by the customer, otherwise set "0".
      • getRemoveIfNotEntitled

        public java.lang.String getRemoveIfNotEntitled()
        This method gets if catalog entries should not be displayed if they are not entitled to being viewed by the customer.
        Returns:
        Returns "1" if catalog entries should not be displayed if they are not entitled to being viewed by the customer, otherwise returns "0".
      • getCatalogEntries

        public java.util.ArrayList getCatalogEntries()
        This method returns an array of filtered catalog entry data objects that will be displayed in the e-Marketing Spot.
        Specified by:
        getCatalogEntries in interface FilterCatalogEntryTaskCmd
        Returns:
        An array of filtered catalog entry data objects.
      • isReadyToCallExecute

        public boolean isReadyToCallExecute()
        This method checks if this command is ready to be executed or not.
        Specified by:
        isReadyToCallExecute in interface com.ibm.websphere.command.Command
        Overrides:
        isReadyToCallExecute in class MarketingSpotCommandBaseTaskCmdImpl
        Returns:
        True if this command is ready to be executed; false otherwise.
      • reset

        public void reset()
        Re-initializes the command for re-execution. Call this method before preparing it for re-execution (for example, by setting its properties).
        Specified by:
        reset in interface com.ibm.websphere.command.Command
        Overrides:
        reset in class MarketingSpotCommandBaseTaskCmdImpl
        See Also:
        Command.reset()
      • postFilter

        public boolean postFilter(MarketingSpotActivityCatalogEntryDataType catentry)
        This method checks the filters that need to be evaluated every time and cannot be cached when this command is cached. The following methods are called:
        • removeIfExistInOrder - shopping cart
        • removeIfExistInOrder - purchase history
        Specified by:
        postFilter in interface FilterCatalogEntryTaskCmd
        Parameters:
        catentry - The catalog entry to check.
        Returns:
        This method returns true if the catalog entry should be removed because one of the remove filters has matched its criteria.
      • performExecute

        public void performExecute()
                            throws java.lang.Exception
        This method performs all the logic that needs to be executed in this command. It first populates all the data objects based on the IDs of catalog entry in the result data bean, then it invokes all the filtering methods implemented in this command. If a filter is disabled in configuration, the invocation of the corresponding method will be skipped. The following methods are called:
        • removeIfNotInCurrentCatalog
        • removeIfPastEndDate
        • removeIfNoInventory
        • removeCatalogEntry
        Specified by:
        performExecute in interface com.ibm.websphere.command.TargetableCommand
        Overrides:
        performExecute in class MarketingSpotCommandBaseTaskCmdImpl
        Throws:
        java.lang.Exception
        See Also:
        TargetableCommand.performExecute()
      • postExecute

        public void postExecute()

        This method is called by the Dynamic Cache when the execute method is called, and a cache miss occurs, after the performExecute method is called.

        Specified by:
        postExecute in interface com.ibm.websphere.command.CacheableCommand
        Overrides:
        postExecute in class MarketingSpotCommandBaseTaskCmdImpl
        See Also:
        CacheableCommand.postExecute()
      • setOutputProperties

        public void setOutputProperties(com.ibm.websphere.command.TargetableCommand fromCommand)

        Sets the output properties by copying them from another instance of this command.

        This method is intended to be called by the cacheable command framework. Do not call this method directly.

        Specified by:
        setOutputProperties in interface com.ibm.websphere.command.TargetableCommand
        Overrides:
        setOutputProperties in class MarketingSpotCommandBaseTaskCmdImpl
        See Also:
        TargetableCommand.setOutputProperties(com.ibm.websphere.command.TargetableCommand)
      • setResultDataBeans

        public void setResultDataBeans(EMarketingSpotDataBean[] resultDataBeans)
        This method sets the data beans containing the results that the e-Marketing Spot displays. Although this method takes an array, only one EMarketingSpotDataBean can be set. This is to allow for the appropriate command caching.
        Specified by:
        setResultDataBeans in interface FilterCatalogEntryTaskCmd
        Parameters:
        resultDataBeans - The data beans containing the results that the e-Marketing Spot displays.
      • getCacheKey

        public java.lang.String[] getCacheKey()
        This method generates a key to enable command caching.
        Returns:
        This method returns a key to enable command caching.