com.ibm.commerce.marketing.runtime.engine

Class MarketingEngineCache

  • java.lang.Object
    • com.ibm.commerce.marketing.runtime.engine.MarketingEngineCache


  • public class MarketingEngineCache
    extends java.lang.Object
    This class implements caching for the Marketing Services using WAS's Distributed Map.
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.Integer ACTIVITY_FOR_DEFAULT_CONTENT
      A constant for the ID of the activity when the default content is displayed in an eMarketing Spot.
      static java.lang.String COPYRIGHT
      IBM copyright notice field.
      static java.lang.String PROCESS_ON_COMMAND_EVENT_NAME
      The event name used for marketing events for the Command Execution Trigger Registry
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      static java.lang.String[] buildBehaviorRuleKey(java.lang.Integer elementTypeId, java.lang.String command, java.lang.Integer storeId)
      This method constructs a key to find UserBehaviorRule objects in the cache.
      static void checkBehaviorRulesLoaded(boolean fromSensor)
      The method checks if the behavior rules have been loaded into the cache.
      void clearAll()
      This method removes all the data from all the caches.
      void clearEMarketingSpotFromRegistry(java.lang.String name, java.lang.String usage, java.lang.Integer storeId, java.lang.Integer emsId)
      This method clears entries associated with an e-Marketing Spot from the cache.
      void clearMarketingCache()
      This method removes all the data from the marketing cache.
      void clearUserBehaviorCache()
      This method removes all the data from the user behavior cache.
      boolean filterCommandBasedOnWebpath(java.lang.String commandName, java.lang.String webpath)
      This method checks if a the successful exit of a command should be ignored because it was called from a webapp for which we do not want to process events.
      void flushRankingStatisticsCache()
      This method will persist all the ranking statistics that are in the ranking statistic cache to the database with a batch insert SQL.
      void flushUserBehaviorBatchUpdateCache()
      This method will persist all the user behavior entries that are in the user behavior batch update cache to the database.
      Activity getActivity(java.lang.Integer activityId)
      This method returns an Activity object based on an activityId.
      Activity getActivityFromElementId(java.lang.Integer elementId)
      This method gets the Activity business object associated with an element.
      java.util.Map getBehaviorRules()
      This method returns the behavior rule cache.
      java.util.List getBehaviorRules(java.lang.String key)
      This method looks in the cache for behavior rules that match the given key.
      java.util.List getBehaviorRules(java.lang.String command, java.lang.Integer storeId, java.util.Map urlString, java.lang.String referralURL, java.lang.Integer elementTypeId)
      This method looks in the cache for behavior rules that match the command, store and urlString (NVPs) passed in.
      java.util.List getBehaviorRules(java.lang.String command, java.lang.Integer storeId, java.lang.String urlString, java.lang.String referralURL, java.lang.Integer elementTypeId)
      This method looks in the cache for behavior rules that match the command, store and urlString (NVPs) passed in.
      static java.lang.String getCacheStringFromFlowElement(FlowElement element)
      This method returns a string representation of a flow element.
      static boolean getCurrentCmcVersionIsFEP6orHigher()
      This method returns if the CMC feature is currently at FEP6 or higher.
      static boolean getCurrentFoundationVersionIsFEP6()
      This method returns if the foundation feature is currently at FEP6.
      static java.lang.String getElementUniqueIdFromElementName(java.lang.String elementName, java.lang.Integer activityId)
      This method gets the unique ID of a campaign element based on the name of the element.
      static java.lang.String getElementUniqueIdFromElementName(java.lang.String elementName, java.lang.String activityName)
      This method gets the unique ID of a campaign element based on the name of the element.
      CampaignInitiativeCache.CachedEMarketingSpot getEmarketingSpot(java.lang.String name, java.lang.String usage, java.lang.Integer storeId)
      This method gets the definition of an e-Marketing Spot.
      java.util.List getEMarketingSpotActivities(java.lang.String emsId, java.lang.Integer storeId)
      This method finds the set of activities that are scheduled on an e-Marketing Spot.
      java.util.Map getEmarketingSpotRelatedInfo(java.lang.Integer emsId, java.lang.Integer storeId)
      This method gets the information related to an e-Marketing Spot in a specific store.
      static java.lang.Integer getExistingElementUniqueIdFromElementName(java.lang.String elementName, java.lang.Integer activityId)
      This method gets the unique ID of a campaign element based on the name of the element.
      FlowElement getFlowElement(java.lang.String elementId)
      This method returns a FlowElement object based on the elementId found in the flow XML definition associated with an activity.
      java.util.List getMarketingSpotDefaultContent(java.lang.Integer storeId, java.lang.Integer emsId)
      This method gets the cached default content associated with an e-Marketing spot in a specific store.
      java.util.List getMarketingSpotDefaultContentForSingleStore(java.lang.Integer storeId, java.lang.Integer emsId)
      This method gets the default content entry associated with the e-Marketing spot in the specified store.
      java.util.List getMarketingSpotDefaultTitleContent(java.lang.Integer storeId, java.lang.Integer emsId)
      This method gets the cached default title content associated with an e-Marketing spot in a specific store.
      java.util.List getMarketingSpotDefaultTitleContentForSingleStore(java.lang.Integer storeId, java.lang.Integer emsId)
      This method gets the default title content entry associated with the e-Marketing spot in the specified store.
      java.lang.String getMarketingSpotOrderingInterface(java.lang.Integer storeId, java.lang.Integer emsId, java.lang.String contentType)
      This method gets the cached interface name for the command to order content in an eMarketing spot in a specific store.
      java.lang.String getPromotionIdFromName(java.lang.String promoName)
      This method returns the promotion ID based on an promotion name.
      java.util.Map getSearchEMarketingSpots(java.lang.Integer storeId)
      This method returns the search e-Marketing Spots that are currently defined for the specified store and the stores on the campaigns store path.
      java.util.List getTriggerListeners(java.lang.String triggerType, java.lang.Integer storeId, java.util.Map nvps)
      This method looks up cached TriggerListen objects that correspond to activities that are listening for the trigger indicated by the method's parameters.
      com.ibm.commerce.marketing.internal.runtime.objects.UserBehavior getUserBehavior(java.lang.String personalizationId, java.lang.Integer storeId)
      This method returns an UserBehavior object based on the personalizationId for a customer.
      static java.lang.String getXmlStringFromActivityCache(com.ibm.commerce.marketing.internal.runtime.objects.ActivityRootElement activityRootElement)
      This method returns a string representation of the cached object representing the activity flow XML.
      static java.lang.StringBuffer getXmlStringFromElement(com.ibm.commerce.marketing.internal.runtime.objects.ActivityFlowElement[] children)
      This method returns a string representation of the cached objects representing the flow elements in the activity XML.
      void initialize()
      This method initializes the marketing engine cache.
      static void invalidateBehaviorRulesLoadedIndicator()
      This method should be called when the behavior rules need to be updated in the marketing cache.
      void invalidateEMarketingSpotActivities(java.lang.String emsId, java.lang.Integer storeId)
      This method removes a trigger listener object from the cache.
      static boolean isInitialized()
      This method returns if the singleton MarketingEngineCache object has been initialized.
      static void loadBehaviorRulesByServiceCall()
      This method calls a service to load the existing behavior rules.
      java.util.List loadEMarketingSpotActivitiesFromDatabase(java.lang.String emsId, java.lang.Integer storeId)
      This method goes to the database and finds the set of activities that are scheduled on an e-Marketing Spot.
      static void loadExistingBehaviorRulesAndTriggerListeners(Activity activity, com.ibm.commerce.marketing.internal.runtime.objects.ActivityElementData activityElementData, com.ibm.commerce.marketing.internal.runtime.objects.TriggerListen[] triggerListeners)
      This method will set up the cache so that is has the latest information about behavior rules and trigger listeners for an activity.
      static void loadExistingBehaviorRulesAndTriggerListeners(java.lang.Integer activityId)
      This method will set up the cache so that is has the latest information about behavior rules and trigger listeners for an activity.
      void putBehaviorRule(java.lang.Integer storeId, UserBehaviorRule ub, java.lang.Integer elementTypeId)
      This method adds a UserBehaviorRule to the cache.
      void putRankingStatistic(java.lang.Long objectId, java.lang.String groupId, java.lang.Short objectType, java.lang.Integer storeId, java.lang.Integer elementId, java.lang.Double amount)
      This method sets up a ranking statistic entry to be persisted to the database.
      void putTriggerListeners(java.lang.String triggerType, java.lang.Integer storeId, java.util.Map nvps, com.ibm.commerce.marketing.internal.runtime.objects.TriggerListen triggerListen)
      This method caches a given TriggerListen object.
      void removeActivity(java.lang.Integer activityId)
      This method removes an activity from the cache.
      void removeElement(java.lang.Integer elementId)
      This method removes a flow element from the cache.
      void removeMarketingSpotDefaultContent(java.lang.Integer storeId, java.lang.Integer emsId)
      This method removes the default content entry associated with the e-Marketing spot in the specified store.
      void removeMarketingSpotTitle(java.lang.Integer storeId, java.lang.Integer emsId)
      This method removes the title entry associated with the e-Marketing spot in the specified store.
      Activity replaceActivity(java.lang.Integer activityId)
      This method removes the existing Activity object from the cache and reloads the object into the cache from the definition in the database.
      FlowElement replaceFlowElement(java.lang.Integer elementId)
      This method removes the existing FlowElement object from the cache and reloads the object into the cache from the definition in the database.
      void setActivity(com.ibm.commerce.marketing.internal.runtime.objects.ActivityElementData activityElementData, Activity entry, com.ibm.commerce.marketing.internal.runtime.objects.TriggerListen[] triggerListeners)
      This method returns an Activity object based on an activityId.
      void setFlowElement(FlowElement entry, Activity activity, com.ibm.commerce.marketing.internal.runtime.objects.ActivityElementData activityElementData)
      This method updates the cache with the provided FlowElement object.
      void setUserBehavior(java.lang.String personalizationId, com.ibm.commerce.marketing.internal.runtime.objects.UserBehavior ub, boolean existing, boolean persistChanges)
      This method updates a UserBehavior object based on the personalizationId for a customer in the cache and in the database.
      static void shutdown()
      Call this method when the WC application is being shut down.
      static MarketingEngineCache singleton()
      This method returns a singleton MarketingEngineCache object.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • COPYRIGHT

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

        public static final java.lang.String PROCESS_ON_COMMAND_EVENT_NAME
        The event name used for marketing events for the Command Execution Trigger Registry
        See Also:
        Constant Field Values
      • ACTIVITY_FOR_DEFAULT_CONTENT

        public static final java.lang.Integer ACTIVITY_FOR_DEFAULT_CONTENT
        A constant for the ID of the activity when the default content is displayed in an eMarketing Spot.
    • Method Detail

      • getActivityFromElementId

        public Activity getActivityFromElementId(java.lang.Integer elementId)
        This method gets the Activity business object associated with an element.
        Parameters:
        elementId - The ID of the element.
        Returns:
        An Activity business object.
      • replaceActivity

        public Activity replaceActivity(java.lang.Integer activityId)
        This method removes the existing Activity object from the cache and reloads the object into the cache from the definition in the database.
        Parameters:
        activityId - The activity ID for which to update the cache.
        Returns:
        The Activity object associated with an activity.
      • replaceFlowElement

        public FlowElement replaceFlowElement(java.lang.Integer elementId)
        This method removes the existing FlowElement object from the cache and reloads the object into the cache from the definition in the database. THIS METHOD IS NO LONGER USED.
        Parameters:
        elementId - The element ID for which to update the cache.
        Returns:
        The FlowElement object associated with an activity.
      • getActivity

        public Activity getActivity(java.lang.Integer activityId)
        This method returns an Activity object based on an activityId. If the activity cannot be found in the cache, it is loaded from the database and placed in the cache. It parses the flow elements, and stores the ActivityFlowElementobjects in the Activity object.
        Parameters:
        activityId - The activity ID for which to retrieve the activity.
        Returns:
        The Activity object associated with an activity.
      • getFlowElement

        public FlowElement getFlowElement(java.lang.String elementId)
        This method returns a FlowElement object based on the elementId found in the flow XML definition associated with an activity. If the flow element cannot be found in the cache, it is loaded from the database and placed in the cache. It parses the flow element XML. For triggers, the type and name value pairs are stored in the FlowElement object. For targets and actions, the invocation parameters are stored in the FlowElement object. THIS METHOD IS NO LONGER USED.
        Parameters:
        elementId - The element ID for which to retrieve the element.
        Returns:
        The FlowElement object associated with an activity.
      • getXmlStringFromActivityCache

        public static java.lang.String getXmlStringFromActivityCache(com.ibm.commerce.marketing.internal.runtime.objects.ActivityRootElement activityRootElement)
        This method returns a string representation of the cached object representing the activity flow XML. This method is only used when trace is enabled to display the contents in the marketing cache. It is also used from the Display Cache JSP page.
        Parameters:
        activityRootElement - An object from the marketing cache that represents the activity flow XML.
        Returns:
        This method returns a string representation of the cached object representing the activity flow XML.
      • getXmlStringFromElement

        public static java.lang.StringBuffer getXmlStringFromElement(com.ibm.commerce.marketing.internal.runtime.objects.ActivityFlowElement[] children)
        This method returns a string representation of the cached objects representing the flow elements in the activity XML. This method is only used when trace is enabled to display the contents in the marketing cache. It is also used from the Display Cache JSP page.
        Parameters:
        children - An array of object from the marketing cache that represents the flow elements in the activity XML.
        Returns:
        This method returns a string representation of the cached objects representing the flow elements in the activity XML.
      • getCacheStringFromFlowElement

        public static java.lang.String getCacheStringFromFlowElement(FlowElement element)
        This method returns a string representation of a flow element. This method is only used when trace is enabled to display the contents in the marketing cache. It is also used from the Display Cache JSP page.
        Parameters:
        element - An flow element object.
        Returns:
        This method returns a string representation of a flow element.
      • invalidateEMarketingSpotActivities

        public void invalidateEMarketingSpotActivities(java.lang.String emsId,
                                                       java.lang.Integer storeId)
        This method removes a trigger listener object from the cache.
        Parameters:
        emsId - The ID of the e-Marketing Spot for which to remove the trigger listener cache entry.
        storeId - The ID of the store in which to remove the trigger listener cache entry.
      • loadEMarketingSpotActivitiesFromDatabase

        public java.util.List loadEMarketingSpotActivitiesFromDatabase(java.lang.String emsId,
                                                                       java.lang.Integer storeId)
                                                                throws java.lang.Exception
        This method goes to the database and finds the set of activities that are scheduled on an e-Marketing Spot.
        Parameters:
        emsId - The ID of the e-Marketing Spot for which to find the scheduled activities.
        storeId - The ID of the store in which to find the scheduled activities.
        Returns:
        This method returns a list of TriggerListen business objects that represent the activities that are scheduled on the e-Marketing Spot.
        Throws:
        java.lang.Exception
      • getEMarketingSpotActivities

        public java.util.List getEMarketingSpotActivities(java.lang.String emsId,
                                                          java.lang.Integer storeId)
                                                   throws java.lang.Exception
        This method finds the set of activities that are scheduled on an e-Marketing Spot.
        Parameters:
        emsId - The ID of the e-Marketing Spot for which to find the scheduled activities.
        storeId - The ID of the store in which to find the scheduled activities.
        Returns:
        This method returns a List of TriggerListen objects.
        Throws:
        java.lang.Exception
      • putTriggerListeners

        public void putTriggerListeners(java.lang.String triggerType,
                                        java.lang.Integer storeId,
                                        java.util.Map nvps,
                                        com.ibm.commerce.marketing.internal.runtime.objects.TriggerListen triggerListen)
        This method caches a given TriggerListen object. The method assumes that this particular TriggerListen object is not already cached. The key into the TriggerListen cache is composed of the triggerType, the storeId and the name/value pairs (NVPs) of parameters that must exist on a request for that request to be picked up by the trigger listener. For each unique key, the cache stores a List which contains all TriggerListen objects for that combination of values. There can be multiple TriggerListen objects for a single key. THIS METHOD IS NO LONGER USED.
        Parameters:
        triggerType - The type of the trigger that the TriggerListen wants to detect.
        storeId - The ID of the store this TriggerListen is for.
        nvps - The Name/Value pairs that must be part of the request to qualify that it should be detected by this TriggerListen.
        triggerListen - The TriggerListen object.
      • getTriggerListeners

        public java.util.List getTriggerListeners(java.lang.String triggerType,
                                                  java.lang.Integer storeId,
                                                  java.util.Map nvps)
        This method looks up cached TriggerListen objects that correspond to activities that are listening for the trigger indicated by the method's parameters. THIS METHOD IS NO LONGER USED.
        Parameters:
        triggerType - The type of the trigger to look for.
        storeId - The ID of the store whose triggers to look through for matches.
        nvps - This hashtable stores name-value pairs whose values must be same as the cached TriggerListen object to qualify it as a match.
        Returns:
        This method returns a List of TriggerListen objects.
        See Also:
        putTriggerListeners
      • initialize

        public void initialize()
                        throws java.lang.Exception
        This method initializes the marketing engine cache.
        Throws:
        java.lang.Exception
      • removeActivity

        public void removeActivity(java.lang.Integer activityId)
        This method removes an activity from the cache.
        Parameters:
        activityId - The activity to remove from the cache.
      • removeElement

        public void removeElement(java.lang.Integer elementId)
                           throws java.lang.Exception
        This method removes a flow element from the cache. THIS METHOD IS NO LONGER USED.
        Parameters:
        elementId - The flow element to remove from the cache.
        Throws:
        java.lang.Exception
      • clearAll

        public void clearAll()
        This method removes all the data from all the caches.
      • clearMarketingCache

        public void clearMarketingCache()
        This method removes all the data from the marketing cache.
      • clearUserBehaviorCache

        public void clearUserBehaviorCache()
        This method removes all the data from the user behavior cache.
      • buildBehaviorRuleKey

        public static java.lang.String[] buildBehaviorRuleKey(java.lang.Integer elementTypeId,
                                                              java.lang.String command,
                                                              java.lang.Integer storeId)
        This method constructs a key to find UserBehaviorRule objects in the cache.
        Parameters:
        elementTypeId - The ID of the type of the campaign element template.
        command - The current request command name.
        storeId - The ID of the store.
        Returns:
        This method returns the key constructed from the parameters passed in to the method.
      • putBehaviorRule

        public void putBehaviorRule(java.lang.Integer storeId,
                                    UserBehaviorRule ub,
                                    java.lang.Integer elementTypeId)
        This method adds a UserBehaviorRule to the cache. The key for the UserBehaviorRule consists of three things:
        1. The store ID for which we want to detect the user's behavior.
        2. The command name whose occurrence needs to be detected for the user.
        3. The type of element this UserBehaviorRule detects behavior for. The valid options are either TYPE_TRIGGER or TYPE_TARGET.
        For each unique key, a List of UserBehaviorRule objects is stored. There can be multiple UserBehaviorRule objects for a single key.
        Parameters:
        storeId - The store the behavior rule applies to.
        ub - A UserBehaviorRule object that represents the user behavior XML.
        elementTypeId - The type of the element for which the user's behavior is being detected. The valid options are either TYPE_TRIGGER or TYPE_TARGET.
      • filterCommandBasedOnWebpath

        public boolean filterCommandBasedOnWebpath(java.lang.String commandName,
                                                   java.lang.String webpath)
        This method checks if a the successful exit of a command should be ignored because it was called from a webapp for which we do not want to process events. For example, if there is a Logon trigger, we only want to process logon events from the storefront, and not from the administration tools. The webpaths to ignore for each command are specified in the wc-admin-component.xml file.
        Parameters:
        commandName - The name of the command.
        webpath - The webpath from which the command is being called.
        Returns:
        This method returns true if the command should be ignored as it is happening on a webapp that has been configured to be filtered. If the command should be processed, then this method returns false.
      • getBehaviorRules

        public java.util.List getBehaviorRules(java.lang.String command,
                                               java.lang.Integer storeId,
                                               java.lang.String urlString,
                                               java.lang.String referralURL,
                                               java.lang.Integer elementTypeId)
        This method looks in the cache for behavior rules that match the command, store and urlString (NVPs) passed in. This method is not usually called. It is called in the scenario where the external system is sending all events to the marketing runtime (TriggerOccurredForProcessing), and the marketing runtime has to determine if the event matches any of the current behavior rules. The current marketing runtime is using the scenario where the external system (SensorEventListener) has a copy of the rules, and it only sends the triggers that match the current behavior rules. Similar code to this method can be found in the SensorEventListener class. THIS METHOD IS NO LONGER USED. The method getBehaviorRules that has a Map for the urlString is now called. This method calls that method.
        Parameters:
        command - The command to look if there are matching behavior rules for.
        storeId - The store to look for behavior rules for.
        urlString - A URL string containing the parameters.
        referralURL - The referral URL for the current request.
        elementTypeId - The type of the element.
        Returns:
        A List which contains two Lists is returned. The two Lists contain:
        • At index INDEX_UBRS is a List of UserBehaviorRule objects that are waiting to record this command.
        • At index INDEX_NVPS is a List of Hashtables where each hashtable contains the Name/Value pairs that need to be detected for the UserBehaviorRule.
        The name-value pairs to record for the UserBehaviorRule at matches.get(INDEX_UBRS).get(i) are found at matches.get(INDEX_NVPS).get(i).
      • getBehaviorRules

        public java.util.List getBehaviorRules(java.lang.String command,
                                               java.lang.Integer storeId,
                                               java.util.Map urlString,
                                               java.lang.String referralURL,
                                               java.lang.Integer elementTypeId)
        This method looks in the cache for behavior rules that match the command, store and urlString (NVPs) passed in. This method is not usually called. It is called in the scenario where the external system is sending all events to the marketing runtime (TriggerOccurredForProcessing), and the marketing runtime has to determine if the event matches any of the current behavior rules. The current marketing runtime is using the scenario where the external system (SensorEventListener) has a copy of the rules, and it only sends the triggers that match the current behavior rules. Similar code to this method can be found in the SensorEventListener class.
        Parameters:
        command - The command to look if there are matching behavior rules for.
        storeId - The store to look for behavior rules for.
        urlString - A map containing the parameters.
        referralURL - The referral URL for the current request.
        elementTypeId - The type of the element.
        Returns:
        A List which contains two Lists is returned. The two Lists contain:
        • At index INDEX_UBRS is a List of UserBehaviorRule objects that are waiting to record this command.
        • At index INDEX_NVPS is a List of Hashtables where each hashtable contains the Name/Value pairs that need to be detected for the UserBehaviorRule.
        The name-value pairs to record for the UserBehaviorRule at matches.get(INDEX_UBRS).get(i) are found at matches.get(INDEX_NVPS).get(i).
      • getBehaviorRules

        public java.util.List getBehaviorRules(java.lang.String key)
        This method looks in the cache for behavior rules that match the given key.
        Parameters:
        key - The key into the behavior rule cache.
        Returns:
        A List of UserBehaviorRule objects.
      • getBehaviorRules

        public java.util.Map getBehaviorRules()
        This method returns the behavior rule cache.
        Returns:
        A Map of rule keys and UserBehaviorRule objects.
      • singleton

        public static MarketingEngineCache singleton()
        This method returns a singleton MarketingEngineCache object.
        Returns:
        The MarketingEngineCache object to reuse.
      • shutdown

        public static void shutdown()
        Call this method when the WC application is being shut down.
      • loadExistingBehaviorRulesAndTriggerListeners

        public static void loadExistingBehaviorRulesAndTriggerListeners(java.lang.Integer activityId)
                                                                 throws DataMediatorException
        This method will set up the cache so that is has the latest information about behavior rules and trigger listeners for an activity. If the activity has any associated behavior rules, then the behavior rules indicator (DM_BHVRLOAD) will be invalidated. This will result in removing all the behavior rules from the cache. Each time the behavior rules need to be checked, the code checks for the existence of the behavior rule indicator in the cache. If the behavior rule indicator does not exist, then the behavior rules will be loaded and cached. If the activity has any associated e-Marketing Spot trigger listeners, then the entries will be invalidated and removed from the cache. The next time an e-Marketing Spot is viewed and a trigger listener does not exist in the cache, then the trigger listeners will loaded and cached. THIS METHOD IS NO LONGER USED.
        Parameters:
        activityId - The specific activity for which to load the behavior rules and trigger listeners into the cache.
        Throws:
        DataMediatorException
      • getUserBehavior

        public com.ibm.commerce.marketing.internal.runtime.objects.UserBehavior getUserBehavior(java.lang.String personalizationId,
                                                                                                java.lang.Integer storeId)
        This method returns an UserBehavior object based on the personalizationId for a customer. If no record is found in the database, then an empty entry is placed into the cache to indicate that it has checked the database for the user behavior entry. However, this method will return null when the empty entry is found in the cache.
        Parameters:
        personalizationId - The unique ID representing the customer.
        storeId - The ID of the store.
        Returns:
        The UserBehavior object associated with a customer.
      • setUserBehavior

        public void setUserBehavior(java.lang.String personalizationId,
                                    com.ibm.commerce.marketing.internal.runtime.objects.UserBehavior ub,
                                    boolean existing,
                                    boolean persistChanges)
        This method updates a UserBehavior object based on the personalizationId for a customer in the cache and in the database.
        Parameters:
        personalizationId - The unique ID representing the customer.
        ub - The UserBehavior object associated with a customer.
        existing - This is true if there is already a user behavior entry in the database, otherwise it is false.
        persistChanges - This is true if changes need to be persisted in the database. If it is false, then the changes are only stored in the cache.
      • flushUserBehaviorBatchUpdateCache

        public void flushUserBehaviorBatchUpdateCache()
        This method will persist all the user behavior entries that are in the user behavior batch update cache to the database.
      • putRankingStatistic

        public void putRankingStatistic(java.lang.Long objectId,
                                        java.lang.String groupId,
                                        java.lang.Short objectType,
                                        java.lang.Integer storeId,
                                        java.lang.Integer elementId,
                                        java.lang.Double amount)
        This method sets up a ranking statistic entry to be persisted to the database. The entry is placed in a queue, and is persisted when the Process MarketingTrigger SaveStatistics command is called, or when the queue size reaches the size specified in the userBehaviorBatchUpdateCacheSize parameter in the wc-admin-component.xml configuration file.
        Parameters:
        objectId - The unique ID representing the object. For most browsed or most purchased, this is the catalog entry ID.
        groupId - The group ID associated with the object. For most browsed or most purchased, this is the category ID.
        objectType - The type of the statistic. A value of 0 means purchased, a value of 1 means browsed.
        storeId - The store ID.
        elementId - The ID of the ranking campaign element.
        amount - The amount associated with the statistic.
      • flushRankingStatisticsCache

        public void flushRankingStatisticsCache()
        This method will persist all the ranking statistics that are in the ranking statistic cache to the database with a batch insert SQL.
      • getMarketingSpotOrderingInterface

        public java.lang.String getMarketingSpotOrderingInterface(java.lang.Integer storeId,
                                                                  java.lang.Integer emsId,
                                                                  java.lang.String contentType)
        This method gets the cached interface name for the command to order content in an eMarketing spot in a specific store. First a setting is checked for the eMarketing spot. If none is found, then a setting is checked for the store.
        Parameters:
        storeId - The ID of the store.
        emsId - The ID of the eMarketing spot.
        contentType - The type of content to be ordered.
        Returns:
        The name of the interface to the ordering command.
      • removeMarketingSpotDefaultContent

        public void removeMarketingSpotDefaultContent(java.lang.Integer storeId,
                                                      java.lang.Integer emsId)
        This method removes the default content entry associated with the e-Marketing spot in the specified store.
        Parameters:
        storeId - The unique identifier of the store.
        emsId - The unique identifier of the e-Marketing Spot.
      • removeMarketingSpotTitle

        public void removeMarketingSpotTitle(java.lang.Integer storeId,
                                             java.lang.Integer emsId)
        This method removes the title entry associated with the e-Marketing spot in the specified store.
        Parameters:
        storeId - The unique identifier of the store.
        emsId - The unique identifier of the e-Marketing Spot.
      • getMarketingSpotDefaultContentForSingleStore

        public java.util.List getMarketingSpotDefaultContentForSingleStore(java.lang.Integer storeId,
                                                                           java.lang.Integer emsId)
        This method gets the default content entry associated with the e-Marketing spot in the specified store. Only the specified store is checked. The data is first loaded from the cache. If no data is found, then the data is loaded from the database, and put into the cache.
        Parameters:
        storeId - The unique identifier of the store.
        emsId - The unique identifier of the e-Marketing Spot.
        Returns:
        The list of EMarketingSpotDataBean objects of the default data to display in the e-Marketing Spot.
      • getMarketingSpotDefaultTitleContentForSingleStore

        public java.util.List getMarketingSpotDefaultTitleContentForSingleStore(java.lang.Integer storeId,
                                                                                java.lang.Integer emsId)
        This method gets the default title content entry associated with the e-Marketing spot in the specified store. Only the specified store is checked. The data is first loaded from the cache. If no data is found, then the data is loaded from the database, and put into the cache.
        Parameters:
        storeId - The unique identifier of the store.
        emsId - The unique identifier of the e-Marketing Spot.
        Returns:
        The list of EMarketingSpotDataBean objects of the default title data to display in the e-Marketing Spot.
      • getMarketingSpotDefaultContent

        public java.util.List getMarketingSpotDefaultContent(java.lang.Integer storeId,
                                                             java.lang.Integer emsId)
        This method gets the cached default content associated with an e-Marketing spot in a specific store. First a setting is checked for the the current store. If none is found, then it checks along stores on the campaigns store path.
        Parameters:
        storeId - The ID of the store.
        emsId - The ID of the eMarketing spot.
        Returns:
        The list of EMarketingSpotDataBean objects of the default data to display in the e-Marketing Spot.
      • getMarketingSpotDefaultTitleContent

        public java.util.List getMarketingSpotDefaultTitleContent(java.lang.Integer storeId,
                                                                  java.lang.Integer emsId)
        This method gets the cached default title content associated with an e-Marketing spot in a specific store. First a setting is checked for the the current store. If none is found, then it checks along stores on the campaigns store path.
        Parameters:
        storeId - The ID of the store.
        emsId - The ID of the eMarketing spot.
        Returns:
        The list of EMarketingSpotDataBean objects of the default title data to display in the e-Marketing Spot.
      • getSearchEMarketingSpots

        public java.util.Map getSearchEMarketingSpots(java.lang.Integer storeId)
        This method returns the search e-Marketing Spots that are currently defined for the specified store and the stores on the campaigns store path.
        Parameters:
        storeId - The ID of the store.
        Returns:
        This method returns a map where the key is the e-Marketing Spot name, and the value is the associated e-Marketing Spot unique ID.
      • getEmarketingSpot

        public CampaignInitiativeCache.CachedEMarketingSpot getEmarketingSpot(java.lang.String name,
                                                                              java.lang.String usage,
                                                                              java.lang.Integer storeId)
        This method gets the definition of an e-Marketing Spot. First the definition is looked for in the cache. If it is not in the cache, then the definition is loaded from the database.
        Parameters:
        name - The name of the e-Marketing Spot.
        usage - The usage type of the e-Marketing Spot.
        storeId - The ID of the store in which to find the e-Marketing Spot.
        Returns:
        The business object definition of the e-Marketing Spot.
      • clearEMarketingSpotFromRegistry

        public void clearEMarketingSpotFromRegistry(java.lang.String name,
                                                    java.lang.String usage,
                                                    java.lang.Integer storeId,
                                                    java.lang.Integer emsId)
        This method clears entries associated with an e-Marketing Spot from the cache. The name to ID mapping will be removed. If the emsId parameter is not null, then the trigger listener and default content entries will be removed as well.
        Parameters:
        name - The name of the e-Marketing Spot for which entries should be removed from the cache.
        usage - The usage type of the e-Marketing Spot for which entries should be removed from the cache.
        storeId - The ID of the store associated with the e-Marketing Spot.
        emsId - The ID of the e-Marketing Spot for which entries should be removed from the cache.
      • getExistingElementUniqueIdFromElementName

        public static java.lang.Integer getExistingElementUniqueIdFromElementName(java.lang.String elementName,
                                                                                  java.lang.Integer activityId)
        This method gets the unique ID of a campaign element based on the name of the element. If the unique ID is not found, null is returned.
        Parameters:
        elementName - The name of a campaign element.
        activityId - The ID of the activity associated with the element.
        Returns:
        This method returns the unique ID of the campaign element.
      • getElementUniqueIdFromElementName

        public static java.lang.String getElementUniqueIdFromElementName(java.lang.String elementName,
                                                                         java.lang.Integer activityId)
        This method gets the unique ID of a campaign element based on the name of the element. If the unique ID is not found, the element name is returned.
        Parameters:
        elementName - The name of a campaign element.
        activityId - The ID of the activity associated with the element.
        Returns:
        This method returns the unique ID of the campaign element.
      • getElementUniqueIdFromElementName

        public static java.lang.String getElementUniqueIdFromElementName(java.lang.String elementName,
                                                                         java.lang.String activityName)
        This method gets the unique ID of a campaign element based on the name of the element. If the unique ID is not found, the element name is returned.
        Parameters:
        elementName - The name of a campaign element.
        activityName - The name of the activity associated with the element.
        Returns:
        This method returns the unique ID of the campaign element.
      • isInitialized

        public static boolean isInitialized()
        This method returns if the singleton MarketingEngineCache object has been initialized.
        Returns:
        This method returns if the singleton MarketingEngineCache object has been initialized.
      • invalidateBehaviorRulesLoadedIndicator

        public static void invalidateBehaviorRulesLoadedIndicator()
        This method should be called when the behavior rules need to be updated in the marketing cache. The behavior rules need to be updated when an activity is activated or deactivated in order to add or remove the associated behavior rules. This method will remove the DM_BHVRLOAD entry from the cache to indicate that the behavior rules need to be reloaded.
      • checkBehaviorRulesLoaded

        public static void checkBehaviorRulesLoaded(boolean fromSensor)
        The method checks if the behavior rules have been loaded into the cache. If the rules have not been loaded into the cache, then the rules will be loaded and cached. This method checks for the existence of a cache entry key named DM_BHVRLOAD. If the entry exists in the cache, then it is assumed that all the behavior rules are loaded into the cache. If the entry does not exist, then the behavior rules need to be loaded.
        Parameters:
        fromSensor - This indicates that the sensor event listener has called to get the behavior rules. In that situation, a service needs to be called in order to load the behavior rules. Otherwise, it is assumed the code is already running under a service and the behavior rules can be directly loaded.
      • loadBehaviorRulesByServiceCall

        public static void loadBehaviorRulesByServiceCall()
        This method calls a service to load the existing behavior rules. The Process MarketingTrigger EvaluateForTrigger service is called as all customers have access to this service. This service call will load the behavior rules into the cache.
      • getPromotionIdFromName

        public java.lang.String getPromotionIdFromName(java.lang.String promoName)
        This method returns the promotion ID based on an promotion name. If the data cannot be found in the cache, it is loaded from the database and placed in the cache.
        Parameters:
        promoName - The promotion name for which to retrieve the promotion ID.
        Returns:
        The promotion ID.
      • setFlowElement

        public void setFlowElement(FlowElement entry,
                                   Activity activity,
                                   com.ibm.commerce.marketing.internal.runtime.objects.ActivityElementData activityElementData)
        This method updates the cache with the provided FlowElement object. It parses the flow element XML. For triggers, the type and name value pairs are stored in the FlowElement object. For targets and actions, the invocation parameters are stored in the FlowElement object.
        Parameters:
        entry - The FlowElement object for which to update the cache.
        activity - The Activity business object.
        activityElementData - The element and element nvp data for all the elements in the activity.
      • loadExistingBehaviorRulesAndTriggerListeners

        public static void loadExistingBehaviorRulesAndTriggerListeners(Activity activity,
                                                                        com.ibm.commerce.marketing.internal.runtime.objects.ActivityElementData activityElementData,
                                                                        com.ibm.commerce.marketing.internal.runtime.objects.TriggerListen[] triggerListeners)
                                                                 throws DataMediatorException
        This method will set up the cache so that is has the latest information about behavior rules and trigger listeners for an activity. If the activity has any associated behavior rules, then the behavior rules indicator (DM_BHVRLOAD) will be invalidated. This will result in removing all the behavior rules from the cache. Each time the behavior rules need to be checked, the code checks for the existence of the behavior rule indicator in the cache. If the behavior rule indicator does not exist, then the behavior rules will be loaded and cached. If the activity has any associated e-Marketing Spot trigger listeners, then the entries will be invalidated and removed from the cache. The next time an e-Marketing Spot is viewed and a trigger listener does not exist in the cache, then the trigger listeners will loaded and cached.
        Parameters:
        activity - The activity object associated with the activity.
        activityElementData - The element and element nvp data for all the elements in the activity.
        triggerListeners - The array of TriggerListen objects associated with the activity's e-Marketing Spot trigger listeners.
        Throws:
        DataMediatorException
      • setActivity

        public void setActivity(com.ibm.commerce.marketing.internal.runtime.objects.ActivityElementData activityElementData,
                                Activity entry,
                                com.ibm.commerce.marketing.internal.runtime.objects.TriggerListen[] triggerListeners)
        This method returns an Activity object based on an activityId. If the activity cannot be found in the cache, it is loaded from the database and placed in the cache. It parses the flow elements, and stores the ActivityFlowElementobjects in the Activity object.
        Parameters:
        activityElementData - The element and element nvp data for all the elements in the activity.
        entry - The activity object associated with the activity.
        triggerListeners - The array of TriggerListen objects associated with the activity's e-Marketing Spot trigger listeners.
      • getEmarketingSpotRelatedInfo

        public java.util.Map getEmarketingSpotRelatedInfo(java.lang.Integer emsId,
                                                          java.lang.Integer storeId)
        This method gets the information related to an e-Marketing Spot in a specific store. The information includes the trigger listeners, default content, default title content, and ordering. First the information is looked for in the cache. If it is not in the cache, then the information is loaded from the database.
        Parameters:
        emsId - The ID of the e-Marketing Spot.
        storeId - The ID of the store in which to find the e-Marketing Spot.
        Returns:
        The business object definition of the e-Marketing Spot.
      • getCurrentFoundationVersionIsFEP6

        public static boolean getCurrentFoundationVersionIsFEP6()
        This method returns if the foundation feature is currently at FEP6. In this situation, the cache needs to load the e-Marketing spot default title information in a separate query.
        Returns:
        If the foundation feature is currently at FEP6.
      • getCurrentCmcVersionIsFEP6orHigher

        public static boolean getCurrentCmcVersionIsFEP6orHigher()
        This method returns if the CMC feature is currently at FEP6 or higher. In this situation, check for and return title information for an activity and for an e-Marketing Spot.
        Returns:
        If the CMC feature is currently at FEP6 or higher.