com.ibm.commerce.marketing.promotion.runtime

Class PromotionExecutionRecord

  • java.lang.Object
    • com.ibm.commerce.marketing.promotion.runtime.PromotionExecutionRecord
  • All Implemented Interfaces:
    XMLizable, java.io.Serializable, java.lang.Cloneable


    public class PromotionExecutionRecord
    extends java.lang.Object
    implements XMLizable, java.lang.Cloneable
    This class represents a record of a promotion applied once. PromotionExecutionRecord has a state which represents its life cycle. A set of PromotionExecutionRecords for an order will be processed after promotion engine invocation based on the policies defined. Those accepted by rule engine invocation will be applied to the order total cost in the form of different types of adjustments.

    XML Snippet for PromotionExecutionRecord:

        <PromotionExecutionRecord impl="com.ibm.commerce.marketing.promotion.runtime.PromotionExecutionRecord">
        <EngineName>Promotion engine name</EngineName>
        <Code>abcd</Code>
        <OrderKey><OrderId>1234</OrderId></OrderKey>        
        <PromotionKey>
            <PromotionName>DollarsOffPromotionOne</PromotionName>
            <StoreKey>
                    <DN>o=Root Organization</DN>
                    <Identifier>BlueStore 201</Identifier>
            </StoreKey>
            <Version>0</Version>
            <Revision>0</Revision>
         </PromotionKey>      
         <State>ELIMINATED</State>
         <PromotionPolicyKey>
            <PolicyName>A policy</PolicyName>
            <StoreKey>
                    <DN>o=root organization</DN>
                    <Identifier>BlueStore 202</Identifier>
            </StoreKey>
              </PromotionPolicyKey>
         <TargetedItems>
         <LineItemSet>
            <AssociatedOrderItem impl="com.ibm.commerce.marketing.promotion.runtime.AssociatedOrderItem" >
                    <OrderItemKey>
                            <OrderItemId>1234</OrderItemId>
                    </OrderItemKey>
                    <StartIndex>2</StartIndex>
                    <Quantity>4</Quantity>
            </AssociatedOrderItem>
            <AssociatedOrderItem impl="com.ibm.commerce.marketing.promotion.runtime.AssociatedOrderItem" >
                    <OrderItemKey>
                            <OrderItemId>3456</OrderItemId>
                    </OrderItemKey>
                    <StartIndex>1</StartIndex>
                    <Quantity>9</Quantity>
            </AssociatedOrderItem>
         </LineItemSet>
         </TargetedItems>
        <TargetedAmount>500</TargetedAmount>
        <!-- The types of monetary value targeted by the this promotion, see the 4
        constants of MonetaryAdjustment PRICE, SHIPPING, SHIPPING_TAX, and TAX -->
        <TargetedAmountTypes>1</TargetedAmountTypes>
        <AppliedAdjustments>
        <Adjustment impl="com.ibm.commerce.marketing.promotion.reward.FixedAmountOffAdjustment">
                    <AmountOff>15</AmountOff>
                    <Currency>CAD</Currency>
                    <!-- wholeOrder or AllAffectedItems or IndividualAffectedItems -->
                    <AdjustmentType>wholeOrder</AdjustmentType>
            </Adjustment>
        <AffectedItems>
        <LineItemSet>
            <AssociatedOrderItem impl="com.ibm.commerce.marketing.promotion.runtime.AssociatedOrderItem" >
                    <OrderItemKey>
                            <OrderItemId>1234</OrderItemId>
                    </OrderItemKey>
                    <StartIndex>2</StartIndex>
                    <Quantity>4</Quantity>
            </AssociatedOrderItem>
            <AssociatedOrderItem impl="com.ibm.commerce.marketing.promotion.runtime.AssociatedOrderItem" >
                    <OrderItemKey>
                            <OrderItemId>3456</OrderItemId>
                    </OrderItemKey>
                    <StartIndex>1</StartIndex>
                    <Quantity>9</Quantity>
            </AssociatedOrderItem>
         </LineItemSet>
        </AffectedItems>
        </AppliedAdjustments>
        </PromotionExecutionRecord>
     
     
     
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String COPYRIGHT
      IBM Copyright
      static int STATE_APPLIED
      Actual changes are made to the order and the order should be fulfilled.
      static int STATE_ASSESSED
      A promotion is applicable to the current order.
      static int STATE_ELIMINATED
      A promotion is applicable to the current order, but due to policy violations it should not be applied
      static int STATE_EXPIRED
      Reward has expired, either due to the order to which it is applicable to has changed or a session has started
      static int STATE_INIT
      A PromotionExecutionRecord has just been created, initial state
      static int STATE_QUALIFIED
      A promotion is applicable to the current order.
      static int STATE_REJECTED
      User declined this reward.
      static int STATE_WAIT_FOR_USER_CHOICE
      A promotion is applicable but there are more than one choices available.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method and Description
      void addCustomeValue(java.lang.String name, XMLizable value)
      Sets a custom value on PromotionExecutionRecord
      void applied()
      Sets the state of this record to STATE_APPLIED, raises a PromotionAppliedEvent.
      void assessed()
      Sets the state of this record to STATE_ASSESSED and raise a PromotionAssessedEvent
      java.lang.Object clone() 
      void eliminated()
      Sets the state of this record to STATE_ELIMINATED, raises a PromotionEliminatedEvent.
      void fromXML(org.w3c.dom.Node node)
      Transforms the XML node into its corresponding real Object.
      Adjustment[] getAdjustments()
      Returns the adjustments associated with the PromotionExecutionRecord.
      LineItemSet[] getAffectedItems()
      Returns the list of order items to which the adjustment will be applied.
      java.lang.Long[] getAffectedOrderItemIDs(int type)
      Deprecated. 
      not for general public use. For order subsystem only in the V5.6 release, no future support for this is planned.
      AssociatedOrderItem[] getAffectedOrderItems(Adjustment adjustment)
      Returns all the order items (or portions of order items) affected by a particular adjustment
      java.lang.String getCode()
      Returns the promotion code.
      com.ibm.commerce.marketing.promotion.coupon.Coupon getCoupon()
      Returns the coupon redeemed in this promotion
      com.ibm.commerce.marketing.promotion.coupon.CouponKey getCouponKey()
      Returns the coupon key of the promotion
      java.util.Date getCouponValTime()
      Gets time to validate coupon
      XMLizable getCustomValue(java.lang.String name)
      Getter for a custom value saved in the PromotionExecutionRecord
      PromotionEngine getEngine()
      Returns the associated promotion engine.
      java.lang.String getEngineName()
      Returns the name of the PromotionEngine which created this promotion execution record
      java.math.BigDecimal getMonetaryAdjustmentForOrder(int type)
      Returns all the monetary adjustment on "type" (that is price, shipping charge, tax, shipping tax).
      java.math.BigDecimal getMonetaryAdjustmentTotalForOrderItem(java.lang.Long orderItemID, int type)
      Deprecated. 
      not for general public use. For order subsystem only in the V5.6 release, no future support for this is planned.
      PromotionExecutionRecord getNextChoice()
      In the case of a choice of rewards, it returns the next option.
      Order getOrder()
      Returns the order to which the reward applies.
      OrderKey getOrderKey()
      Returns the order key of the promotion
      Promotion getPromotion()
      Returns the promotion of the PromotionExecutionRecord.
      PromotionKey getPromotionKey()
      Returns the unique promotion key for the promotion
      java.util.List getRewardOptions()
      Gets a list of RewardOption objects that are associated with this record.
      int getState()
      Returns the state of the PromotionExecutionRecord namely one of the values of the constants STATE_INIT, STATE_WAIT_FOR_USER_CHOICE, STATE_ELIMINATED, STATE_ASSESSED, STATE_EXPIRED, STATE_QUALIFIED, STATE_REJECTED or STATE_APPLIED.
      java.math.BigDecimal getTargetedAmount()
      Returns the targeted monetary amount used to qualify for this promotion, in order currency.
      int getTargetedAmountTypes()
      Return the targeted monetary value types, if this promotion targets order qualifying total
      LineItemSet getTargetedItems()
      Returns the targeted items of the promotion in the PromotionExecutionRecord.
      AssociatedOrderItem[] getTargetedOrderItems()
      Returns all the order items (or portions of order items) targeted by this promotion
      PromotionPolicy getViolatedPolicy()
      Returns the policy that is violated by this promotion, if it has been violated; else return null.
      PromotionPolicyKey getViolatedPolicyKey()
      Returns the violated promotion policy key
      boolean isCodeEntered()
      Checks to see if a promotion code is entered for the PromotionExecutionRecord.
      void pendingSelection()
      Sets the state of this record to STATE_WAIT_FOR_USER_CHOICE and raise a PromotionAssessedEvent also for each available option This method is intended for customization only, and is not supported by default Promotion engine implementation.
      void qualified()
      Sets the state of this record to STATE_QUALIFIED, raises a PromotionQualifiedEvent.
      void recordMonetaryAdjustmentForOrderItem(java.lang.Long orderItemID, java.math.BigDecimal value, int type)
      Records a monetary adjustment on an order item.
      void rejected()
      Sets the state of this record to STATE_REJECTED, raises a PromotionRejectedEvent.
      void setAdjustments(Adjustment[] aAdjustments)
      Sets the adjustments associated with the PromotionExecutionRecord.
      void setAffectedItems(LineItemSet[] aAffectedItems)
      Sets the list of order items to which the adjustment will be applied.
      void setCode(java.lang.String aCode)
      Sets the promotion code.
      void setCodeEntered(boolean aCodeEntered)
      Sets a boolean value to indicate if promotion code has been entered for the PromotionExecutionRecord.
      void setCoupon(com.ibm.commerce.marketing.promotion.coupon.Coupon aCoupon)
      Sets the coupon that is redeemed in this promotion
      void setCouponValTime(java.util.Date date)
      Sets time to validate coupon
      void setEngine(PromotionEngine aEngine)
      Sets the promotion engine.
      void setEngineName(java.lang.String string)
      Sets the name of the promotion engine which created this promotion execution record
      void setNextChoice(PromotionExecutionRecord aNextInGroup)
      In the case of a choice of rewards, it sets the next option.
      void setOrder(Order aOrder)
      Sets the order to which this reward applies.
      void setPromotion(Promotion aPromotion)
      Sets the promotion of the PromotionExecutionRecord.
      void setState(int aState)
      Sets the state of the PromotionExecutionRecord.
      void setTargetedAmount(java.math.BigDecimal amount)
      Sets the targeted monetary amount used to qualify for this promotion, in order currency.
      void setTargetedAmountTypes(int i)
      Set the targeted monetary value types bit pattern.
      void setTargetedItems(LineItemSet aTtargetedItems)
      Sets the targeted Items for the promotion.
      void setViolatedPolicy(PromotionPolicy aViolatedPolicy)
      Sets the promotion policy that is violated by this promotion.
      java.lang.String toString() 
      java.lang.String toXML()
      Converts the object into its corresponding XML format representation.
      • Methods inherited from class java.lang.Object

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

      • COPYRIGHT

        public static final java.lang.String COPYRIGHT
        IBM Copyright
        See Also:
        Constant Field Values
      • STATE_INIT

        public static final int STATE_INIT
        A PromotionExecutionRecord has just been created, initial state
        See Also:
        Constant Field Values
      • STATE_WAIT_FOR_USER_CHOICE

        public static final int STATE_WAIT_FOR_USER_CHOICE
        A promotion is applicable but there are more than one choices available. And the user is expected to make a selection between these rewards. This state is intended for customization only, and is not supported by default Promotion engine implementation.
        See Also:
        Constant Field Values
      • STATE_ELIMINATED

        public static final int STATE_ELIMINATED
        A promotion is applicable to the current order, but due to policy violations it should not be applied
        See Also:
        Constant Field Values
      • STATE_ASSESSED

        public static final int STATE_ASSESSED
        A promotion is applicable to the current order. Policy violations have not been tested
        See Also:
        Constant Field Values
      • STATE_EXPIRED

        public static final int STATE_EXPIRED
        Reward has expired, either due to the order to which it is applicable to has changed or a session has started
        See Also:
        Constant Field Values
      • STATE_QUALIFIED

        public static final int STATE_QUALIFIED
        A promotion is applicable to the current order. There is no policy violation when this promotion is applied
        See Also:
        Constant Field Values
      • STATE_REJECTED

        public static final int STATE_REJECTED
        User declined this reward. This state is intended for customization only, and is not supported by default Promotion engine implementation.
        See Also:
        Constant Field Values
      • STATE_APPLIED

        public static final int STATE_APPLIED
        Actual changes are made to the order and the order should be fulfilled.
        See Also:
        Constant Field Values
    • Constructor Detail

      • PromotionExecutionRecord

        public PromotionExecutionRecord(PromotionEngine aEngine)
        Constructor for the PromotionExecutionRecord.
        Parameters:
        aEngine - the promotion engine.
      • PromotionExecutionRecord

        public PromotionExecutionRecord(PromotionExecutionRecord aPreviousInChain)
        Constructor for the PromotionExecutionRecord. This constructor is intended for customization only, and is not supported by default Promotion engine implementation.
        Parameters:
        aPreviousInChain - in the case when user's choice of promotions is needed, a chain of promotion records will be returned. This is a convenience constructor for creating promotion execution record in that scenario.
    • Method Detail

      • clone

        public java.lang.Object clone()
                               throws java.lang.CloneNotSupportedException
        Overrides:
        clone in class java.lang.Object
        Throws:
        java.lang.CloneNotSupportedException
        See Also:
        Object.clone()
      • getState

        public int getState()
        Returns the state of the PromotionExecutionRecord namely one of the values of the constants STATE_INIT, STATE_WAIT_FOR_USER_CHOICE, STATE_ELIMINATED, STATE_ASSESSED, STATE_EXPIRED, STATE_QUALIFIED, STATE_REJECTED or STATE_APPLIED.
        Returns:
        String
      • getTargetedItems

        public LineItemSet getTargetedItems()
        Returns the targeted items of the promotion in the PromotionExecutionRecord.
        Returns:
        the targeted items of the promotion.
      • getTargetedAmount

        public java.math.BigDecimal getTargetedAmount()
        Returns the targeted monetary amount used to qualify for this promotion, in order currency.
        Returns:
        targeted amount used to qualify for the promotion.
      • setState

        public void setState(int aState)
        Sets the state of the PromotionExecutionRecord. Possible values of the state include one of the constants of STATE_INIT, STATE_WAIT_FOR_USER_CHOICE, STATE_ELIMINATED, STATE_ASSESSED, STATE_EXPIRED, STATE_QUALIFIED, STATE_REJECTED or STATE_APPLIED.
        Parameters:
        aState - The state to set
      • setTargetedItems

        public void setTargetedItems(LineItemSet aTtargetedItems)
        Sets the targeted Items for the promotion.
        Parameters:
        aTtargetedItems - The targetedItems to set
      • setTargetedAmount

        public void setTargetedAmount(java.math.BigDecimal amount)
        Sets the targeted monetary amount used to qualify for this promotion, in order currency.
        Parameters:
        amount - the new targeted amount.
      • getOrder

        public Order getOrder()
        Returns the order to which the reward applies.
        Returns:
        the order to which the reward applies.
      • getPromotion

        public Promotion getPromotion()
        Returns the promotion of the PromotionExecutionRecord.
        Returns:
        the promotion of the PromotionExecutionRecord.
      • getViolatedPolicy

        public PromotionPolicy getViolatedPolicy()
        Returns the policy that is violated by this promotion, if it has been violated; else return null.
        Returns:
        the promotion policy violated by the promotion in the PromotionExecutionRecord.
      • setOrder

        public void setOrder(Order aOrder)
        Sets the order to which this reward applies.
        Parameters:
        aOrder - The order to set
      • setPromotion

        public void setPromotion(Promotion aPromotion)
        Sets the promotion of the PromotionExecutionRecord.
        Parameters:
        aPromotion - The promotion to set
      • setViolatedPolicy

        public void setViolatedPolicy(PromotionPolicy aViolatedPolicy)
        Sets the promotion policy that is violated by this promotion.
        Parameters:
        aViolatedPolicy - The violated promotion policy to set
      • getNextChoice

        public PromotionExecutionRecord getNextChoice()
        In the case of a choice of rewards, it returns the next option. This method is intended for customization only, and is not supported by default Promotion engine implementation.
        Returns:
        the next choice of the PromotionExecutionRecord.
      • setNextChoice

        public void setNextChoice(PromotionExecutionRecord aNextInGroup)
        In the case of a choice of rewards, it sets the next option. This method is intended for customization only, and is not supported by default Promotion engine implementation.
        Parameters:
        aNextInGroup - The next in group PromotionExecutionRecord to set
      • isCodeEntered

        public boolean isCodeEntered()
        Checks to see if a promotion code is entered for the PromotionExecutionRecord.
        Returns:
        true to indicate that a promotion code has been entered; false otherwise.
      • setCodeEntered

        public void setCodeEntered(boolean aCodeEntered)
        Sets a boolean value to indicate if promotion code has been entered for the PromotionExecutionRecord.
        Parameters:
        aCodeEntered - true to indicate that a promotion code has been set for the PromotionExecutionRecord.
      • getCode

        public java.lang.String getCode()
        Returns the promotion code.
        Returns:
        the promotion code.
      • setCode

        public void setCode(java.lang.String aCode)
        Sets the promotion code.
        Parameters:
        aCode - The promotion code to set
      • assessed

        public void assessed()
        Sets the state of this record to STATE_ASSESSED and raise a PromotionAssessedEvent
      • pendingSelection

        public void pendingSelection()
        Sets the state of this record to STATE_WAIT_FOR_USER_CHOICE and raise a PromotionAssessedEvent also for each available option This method is intended for customization only, and is not supported by default Promotion engine implementation.
      • qualified

        public void qualified()
        Sets the state of this record to STATE_QUALIFIED, raises a PromotionQualifiedEvent.
      • eliminated

        public void eliminated()
        Sets the state of this record to STATE_ELIMINATED, raises a PromotionEliminatedEvent.
      • applied

        public void applied()
        Sets the state of this record to STATE_APPLIED, raises a PromotionAppliedEvent.
      • rejected

        public void rejected()
        Sets the state of this record to STATE_REJECTED, raises a PromotionRejectedEvent. This method is intended for customization only, and is not supported by default Promotion engine implementation.
      • getAdjustments

        public Adjustment[] getAdjustments()
        Returns the adjustments associated with the PromotionExecutionRecord.
        Returns:
        an array of Promotion adjustments.
      • getAffectedItems

        public LineItemSet[] getAffectedItems()
        Returns the list of order items to which the adjustment will be applied.
        Returns:
        list of order items to which the adjustment will be applied.
      • getEngine

        public PromotionEngine getEngine()
        Returns the associated promotion engine.
        Returns:
        the Promotion Engine
      • setAdjustments

        public void setAdjustments(Adjustment[] aAdjustments)
        Sets the adjustments associated with the PromotionExecutionRecord.
        Parameters:
        aAdjustments - The adjustments to set
      • setAffectedItems

        public void setAffectedItems(LineItemSet[] aAffectedItems)
        Sets the list of order items to which the adjustment will be applied.
        Parameters:
        aAffectedItems - The affectedItems to set
      • setEngine

        public void setEngine(PromotionEngine aEngine)
        Sets the promotion engine.
        Parameters:
        aEngine - The engine to set
      • getTargetedOrderItems

        public AssociatedOrderItem[] getTargetedOrderItems()
        Returns all the order items (or portions of order items) targeted by this promotion
        Returns:
        an array of associated order items.
      • getAffectedOrderItems

        public AssociatedOrderItem[] getAffectedOrderItems(Adjustment adjustment)
        Returns all the order items (or portions of order items) affected by a particular adjustment
        Parameters:
        adjustment - the adjustment
        Returns:
        an array of associated order items
      • getCoupon

        public com.ibm.commerce.marketing.promotion.coupon.Coupon getCoupon()
        Returns the coupon redeemed in this promotion
        Returns:
        the coupon redeemed in this promotion
      • setCoupon

        public void setCoupon(com.ibm.commerce.marketing.promotion.coupon.Coupon aCoupon)
        Sets the coupon that is redeemed in this promotion
        Parameters:
        aCoupon - the coupon
      • getCouponKey

        public com.ibm.commerce.marketing.promotion.coupon.CouponKey getCouponKey()
        Returns the coupon key of the promotion
        Returns:
        the Coupon Key.
      • getOrderKey

        public OrderKey getOrderKey()
        Returns the order key of the promotion
        Returns:
        the Order Key.
      • getPromotionKey

        public PromotionKey getPromotionKey()
        Returns the unique promotion key for the promotion
        Returns:
        the Promotion Key
      • getViolatedPolicyKey

        public PromotionPolicyKey getViolatedPolicyKey()
        Returns the violated promotion policy key
        Returns:
        the violated Promotion Policy Key.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        See Also:
        Object.toString()
      • getAffectedOrderItemIDs

        public java.lang.Long[] getAffectedOrderItemIDs(int type)
        Deprecated. not for general public use. For order subsystem only in the V5.6 release, no future support for this is planned.
        Returns the list of order item ids that are affected by this promotion. This method is not for general public use.
        Parameters:
        type - the type of monetary value adjustment, for example, PRICE, SHIPPING, TAX, SHIPPING TAX.
        Returns:
        an array of affected order items.
      • getMonetaryAdjustmentTotalForOrderItem

        public java.math.BigDecimal getMonetaryAdjustmentTotalForOrderItem(java.lang.Long orderItemID,
                                                                           int type)
        Deprecated. not for general public use. For order subsystem only in the V5.6 release, no future support for this is planned.
        Returns the sum of all adjustment on an order item as the result of applying this promotion. This method is not for general public use.
        Parameters:
        orderItemID - id of the order item
        type - to which monetary value is the adjustment applied: price, shipping, tax, shipping tax, see the constant attributes of MonetaryAdjustment
        Returns:
        the sum of all adjustment on this order item as the result of applying this promotion
      • recordMonetaryAdjustmentForOrderItem

        public void recordMonetaryAdjustmentForOrderItem(java.lang.Long orderItemID,
                                                         java.math.BigDecimal value,
                                                         int type)
        Records a monetary adjustment on an order item.
        Parameters:
        orderItemID - id of the order item to which the adjustment will apply
        value - the adjustment value.
        type - to which monetary value is the adjustment applied: price, shipping, tax, shipping tax, see the constant attributes of MonetaryAdjustment
      • getMonetaryAdjustmentForOrder

        public java.math.BigDecimal getMonetaryAdjustmentForOrder(int type)
        Returns all the monetary adjustment on "type" (that is price, shipping charge, tax, shipping tax). This method is not for general public use.
        Parameters:
        type - to which monetary value is the adjustment applied: price, shipping, tax, shipping tax, see the constant attributes of MonetaryAdjustment
        Returns:
        total adjustment
      • getEngineName

        public java.lang.String getEngineName()
        Returns the name of the PromotionEngine which created this promotion execution record
        Returns:
        the name of the promotion engine.
      • setEngineName

        public void setEngineName(java.lang.String string)
        Sets the name of the promotion engine which created this promotion execution record
        Parameters:
        string - name of the engine
      • addCustomeValue

        public void addCustomeValue(java.lang.String name,
                                    XMLizable value)
        Sets a custom value on PromotionExecutionRecord
        Parameters:
        name - name of the custom value
        value - value of the custom value. It has to be an XMLizable object
      • getCustomValue

        public XMLizable getCustomValue(java.lang.String name)
        Getter for a custom value saved in the PromotionExecutionRecord
        Parameters:
        name - of the custom value
        Returns:
        the custom value as an XMLizable object
      • getTargetedAmountTypes

        public int getTargetedAmountTypes()
        Return the targeted monetary value types, if this promotion targets order qualifying total
        Returns:
        the targeted monetary values in a bit pattern.
      • setTargetedAmountTypes

        public void setTargetedAmountTypes(int i)
        Set the targeted monetary value types bit pattern.
        Parameters:
        i - new targeted monetary value types pattern
      • getCouponValTime

        public java.util.Date getCouponValTime()
        Gets time to validate coupon
        Returns:
        Coupon validation time
      • setCouponValTime

        public void setCouponValTime(java.util.Date date)
        Sets time to validate coupon
        Parameters:
        date - Coupon validation time
      • getRewardOptions

        public java.util.List getRewardOptions()
        Gets a list of RewardOption objects that are associated with this record.
        Returns:
        A list of RewardOption objects.