com.ibm.commerce.marketing.commands.marketingspot

Class FilterCategoryTaskCmdImpl

  • All Implemented Interfaces:
    FilterCategoryTaskCmd, 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 FilterCategoryTaskCmdImpl
    extends MarketingSpotCommandBaseTaskCmdImpl
    implements FilterCategoryTaskCmd, com.ibm.websphere.cache.Sizeable
    This command loads the specified category by calling the RetrieveCategoryTaskCmd command. Then this command checks if the specified category 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 removeCategory. 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 category filter:
    1. Extend FilterCategoryTaskCmdImpl, 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 removeCategory(MarketingSpotActivityCategoryDataType category); 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 category should not be displayed to the customer. Otherwise return false, and the category will get displayed in the eMarketing Spot.
    4. Extend the method boolean postFilter(MarketingSpotActivityCategoryDataType category); 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 category should not be displayed to the customer. Otherwise return false, and the category 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

      • FilterCategoryTaskCmdImpl

        public FilterCategoryTaskCmdImpl()
        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.
      • setRemoveIfNotInCurrentCatalog

        public void setRemoveIfNotInCurrentCatalog(java.lang.String setting)
        This method sets if catalog groups should not be displayed if they are not in the catalog currently being viewed by the customer.
        Parameters:
        setting - Set "1" if catalog groups 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 groups should not be displayed if they are not in the catalog currently being viewed by the customer.
        Returns:
        Returns "1" if catalog groups 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".
      • getCategories

        public java.util.ArrayList getCategories()
        This method returns an array of filtered category data objects that will be displayed in the e-Marketing Spot.
        Specified by:
        getCategories in interface FilterCategoryTaskCmd
        Returns:
        An array of filtered category data objects.
      • getResultDataBeans

        public EMarketingSpotDataBean[] getResultDataBeans()
        This method sets the data beans containing the results that the e-Marketing Spot displays.
        Specified by:
        getResultDataBeans in interface FilterCategoryTaskCmd
        Returns:
        The data beans containing the results that the e-Marketing Spot displays.
      • 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()
      • 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 category 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
        • removeCategory
        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()
      • postFilter

        public boolean postFilter(MarketingSpotActivityCatalogGroupDataType category)
        This method checks the filters that need to be evaluated every time and cannot be cached when this command is cached. This method currently performs no checks.
        Specified by:
        postFilter in interface FilterCategoryTaskCmd
        Parameters:
        category - The category to check.
        Returns:
        This method returns true if the content should be removed because one of the remove filters has matched its criteria.
      • 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 FilterCategoryTaskCmd
        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.