com.ibm.commerce.marketing.commands.marketingspot

Class FilterContentTaskCmdImpl

  • All Implemented Interfaces:
    FilterContentTaskCmd, 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 FilterContentTaskCmdImpl
    extends MarketingSpotCommandBaseTaskCmdImpl
    implements FilterContentTaskCmd, com.ibm.websphere.cache.Sizeable
    This command loads the specified marketing content by calling the RetrieveContentTaskCmd command. Then this command checks if the specified marketing content 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 promotion matches the content url requirements) are evaluated in the performExecute method. Filters that cannot be cached (such as check if promotion is active) are evaluated in the postFilter method. If a custom filter is added, and the evaluation can be cached, then extend the methods removeContent and removeContentPromotion. 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 marketing content filter:
    1. Extend FilterContentTaskCmdImpl, 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 removeContent(MarketingSpotActivityMarketingContentDataType content). 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 marketing content should not be displayed to the customer. Otherwise return false, and the marketing content will get displayed in the eMarketing Spot.
    4. Extend the method removeContentPromotion(MarketingSpotActivityMarketingContentDataType content, Promotion promotion). This method is used when the filter check is associated with a promotion. 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 marketing content should not be displayed to the customer. Otherwise return false, and the marketing content will get displayed in the eMarketing Spot.
    5. Extend the method boolean postFilter(MarketingSpotActivityMarketingContentDataType content); 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 marketing content should not be displayed to the customer. Otherwise return false, and the marketing content 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

      • FilterContentTaskCmdImpl

        public FilterContentTaskCmdImpl()
        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.
      • setRemoveIfPromotionNotAvailable

        public void setRemoveIfPromotionNotAvailable(java.lang.String setting)
        This method sets if promotions should not be displayed if they do not fall within their active date/time.
        Parameters:
        setting - Set "1" if promotions should not be displayed if they are not active at this date/time, otherwise set "0".
      • getRemoveIfPromotionNotAvailable

        public java.lang.String getRemoveIfPromotionNotAvailable()
        This method gets if promotions should not be displayed if they do not fall within their active date/time.
        Returns:
        Returns "1" if promotions should not be displayed if they are not active at this date/time, otherwise set "0".
      • setRemoveIfPromotionBeforeStartDate

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

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

        public void setRemoveIfMemberNotInPromotionSegment(java.lang.String setting)
        This method sets if promotions should not be displayed if the member does not belong to the same segment of the promotion.
        Parameters:
        setting - Set "1" if promotions should not be displayed if the member does not belong to the same segment of the promotion, otherwise set "0".
      • getRemoveIfMemberNotInPromotionSegment

        public java.lang.String getRemoveIfMemberNotInPromotionSegment()
        This method gets if promotions should not be displayed if the member does not belong to the same segment of the promotion.
        Returns:
        Returns "1" if promotions should not be displayed if the member does not belong to the same segment of the promotion, otherwise returns "0".
      • setRemoveIfPromotionNotEntitledCatalogEntryOrCategory

        public void setRemoveIfPromotionNotEntitledCatalogEntryOrCategory(java.lang.String setting)
        This method sets if promotions should not be displayed if the member is not entitled to the catalog entry or category being promoted.
        Parameters:
        setting - Set "1" if promotions should not be displayed if the member is not entitled to the catalog entry or category being promoted, otherwise set "0".
      • getRemoveIfPromotionNotEntitledCatalogEntryOrCategory

        public java.lang.String getRemoveIfPromotionNotEntitledCatalogEntryOrCategory()
        This method gets if promotions should not be displayed if the member is not entitled to the catalog entry or category being promoted.
        Returns:
        Returns "1" if promotions should not be displayed if the member is not entitled to the catalog entry or category being promoted, otherwise returns "0".
      • getMarketingContent

        public java.util.ArrayList getMarketingContent()
        This method returns an array of filtered marketing content data objects that will be displayed in the e-Marketing Spot.
        Specified by:
        getMarketingContent in interface FilterContentTaskCmd
        Returns:
        An array of filtered marketing content 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 FilterContentTaskCmd
        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 marketing content 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:
        • removeContent
        • removeContentPromotion
        • removeIfPromotionIsWrongType
        Specified by:
        performExecute in interface com.ibm.websphere.command.TargetableCommand
        Overrides:
        performExecute in class MarketingSpotCommandBaseTaskCmdImpl
        Throws:
        java.lang.Exception
        See Also:
        TargetableCommand.performExecute()
      • postFilter

        public boolean postFilter(MarketingSpotActivityMarketingContentDataType content)
        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:
        • removeIfPromotionInactive
        • removeIfPromotionNotAvailable
        • removeIfPromotionBeforeStartDate
        • removeIfMemberNotInPromotionSegment
        • removeIfPromotionNotEntitledCatalogEntryOrCategory
        Specified by:
        postFilter in interface FilterContentTaskCmd
        Parameters:
        content - The content to check.
        Returns:
        This method returns true if the content should be removed because one of the remove filters has matched its criteria.
      • 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 FilterContentTaskCmd
        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.
      • getTradingAgreementAccessBeans

        public TradingAgreementAccessBean[] getTradingAgreementAccessBeans()
        Gets the list of trading agreement objects that are used to check product and category entitlement.
        Returns:
        The list of trading agreement objects that are used to check product and category entitlement.
      • checkCatalogEntryEntitlement

        public boolean checkCatalogEntryEntitlement(java.lang.Long catalogEntryId)
        Checks whether the given catalog entry is entitled to the contracts for which the current user is eligible.
        Parameters:
        catalogEntryId - ID of the catalog entry to be evaluated.
        Returns:
        True if the given catalog entry is entitled to the contracts for which the current user is eligible; false otherwise.
      • checkCatalogGroupEntitlement

        public boolean checkCatalogGroupEntitlement(java.lang.Long catalogGroupId)
        Checks whether the given catalog group is entitled to the contracts for which the current user is eligible.
        Parameters:
        catalogGroupId - ID of the catalog group to be evaluated.
        Returns:
        True if the given catalog group is entitled to the contracts for which the current user is eligible; false otherwise.
      • checkPromotionContentEntitlement

        public boolean checkPromotionContentEntitlement(java.lang.String calCodeId,
                                                        java.lang.String pStoreId)
        Checks whether the promotion content that is assigned to the given collateral is entitled to the contracts for which the current user is eligible.
        Parameters:
        calCodeId - The calculation code Id.
        pStoreId - The promotion store Id.
        Returns:
        True if the promotion content that is assigned to the given collateral is entitled to the contracts for which the current user is eligible; false otherwise.
      • setMarketingSpotIdAndContentType

        public void setMarketingSpotIdAndContentType(java.lang.Integer newEmsId,
                                                     boolean newTitleContent)
        This method sets the e-Marketing Spot ID and content type associated with the content being loaded.
        Specified by:
        setMarketingSpotIdAndContentType in interface FilterContentTaskCmd
        Parameters:
        newEmsId - The e-Marketing Spot ID associated with the content being loaded.
        newTitleContent - True if the content is associated with an e-Marketing Spot title.