com.ibm.commerce.marketing.promotion.runtime

Class PromotionArgument

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


    public class PromotionArgument
    extends java.lang.Object
    implements XMLizable, java.lang.Cloneable
    The class contains the input parameters and evaluation results after an instance of PromotionEngine is invoked. As the input parameters, it has all the input parameters used by promotion engine invocation. For example, invocation template which has predefined promotion groups applied to a particular store. The input parameters are used to keep record of what has been processed by the promotion rule engine. As the evaluation results, the PromotionArgument carries a list of PromotionExecutionRecords. A PromotionExecutionRecord is the evidence that a promotion is applied to an order once. If a promotion is applied to an order N times, N PromotionExecutionRecords are appended. Each PromotionExecutionRecord carries a large variety of information. PromotionArgument also includes a list of PromotionErrorReports to indicate any errors that may have arisen during promotion evaluation, for example incorrect or expired codes and coupons.

    XML Snippet for PromotionArgument:

     
        <PromotionArgument impl="com.ibm.commerce.marketing.promotion.runtime.PromotionArgument">
        <EngineName>Promotion Engine name</EngineName>
        <OrderKey><OrderId>1234</OrderId></OrderKey>
        <CustomerKey><LogonId>wcsadmin</LogonId></CustomerKey>
        <InvocationTemplate>
            <Template name="Store 201 Order Level Promotion">
                    <DefaultDN>Blue mall organization</DefaultDN>
                    <DefaultStore>Store 201</DefaultStore>
                    <PromotionGroups>
                            <Group>OrderLevelPriceDiscounts</Group>
                    <Group>OrderLevelShippingDiscounts</Group>
                            <Group DN="root organization" Store="Default Store">SiteWideFreeGiftPromotionsForNewSignUps</Group>
                            </PromotionGroups>
            </Template>
        </InvocationTemplate>
        <DiscardPreviousResult>false</DiscardPreviousResult>
        <SaveCurrentResult>true</SaveCurrentResult>
        <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>
        </PromotionArgument>
     
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String COPYRIGHT
      IBM Copyright
    • Constructor Summary

      Constructors 
      Constructor and Description
      PromotionArgument()
      Constructor for PromotionArgument.
      PromotionArgument(Order aOrder, Customer aCustomer, java.lang.String aTemplate, boolean aDiscard, boolean aSave, java.util.Hashtable aNVP)
      Constructor used to create a PromotionArgument
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void appendPromotionErrorReport(PromotionErrorReport report)
      Appends a promotion error report to a list of error reports.
      void appendPromotionExecutionRecord(PromotionExecutionRecord record)
      Appends a promotion execution record
      java.lang.Object clone() 
      void finalizePromotionArgument()
      Finalizes promotion argument, marks all applicable PromotionExecutionRecords as applied and logs statistics.
      void fromXML(org.w3c.dom.Node anXMLNode)
      Transforms the XML node into its corresponding real Object.
      java.lang.String getEngineName()
      Returns the name of the promotion engine that is invoked.
      java.lang.String getInvocationTemplate()
      Returns the invocation Template.
      Order getOrder()
      Returns the order to which promotions will be applied
      OrderKey getOrderKey()
      Returns the key of an Order
      Customer getOwner()
      Returns the reference of Customer entity which belongs to the PromotionArgument
      CustomerKey getOwnerKey()
      Returns the key of the Owner
      java.lang.Object getParameter(java.lang.String name)
      Returns object value from name and value pair stored in a Hashtable containing any additional parameters to promotion engine and promotions.
      PromotionErrorReport[] getPromotionErrorReports()
      Returns all the promotion error reports accumulated so far.
      java.util.Iterator getPromotionExecutionRecords()
      Returns the list of all results from evaluation of promotions
      OrderRunningTotal getRunningTotal()
      Returns the order running total object.
      java.util.Hashtable getRuntimeAttributes()
      Returns a Hashtable containing the name-value pairs representing additional parameters to promotion engine and promotions.
      boolean hasApplicablePromotions()
      This method determines if promotion argument contains any applicable promotions.
      boolean hasUnusedFreeGifts(PromotionExecutionRecord record)
      Checks a promotion execution record to determine if this is a free gift promotion where no free gift was selected.
      boolean isCurrentResultSaved()
      This method determines if the result of current session will be saved in persistent storage or not.
      boolean isPreviousResultDiscarded()
      This method determines if previous promotion results will be discarded or not.
      void setAdditionalParameters(java.util.Hashtable aNVP)
      This method is used to specify a Hashtable which contains additional parameters to promotion engine and promotions, using a name-value pair style.
      void setCurrentResultSaved(boolean aCurrentResultSaved)
      Sets whether the result of current session will be saved in persistent storage or not.
      void setEngineName(java.lang.String string)
      Sets the name of the promotion engine that is invoked.
      void setHasApplicablePromotions(boolean aHasApplicablePromotions)
      Set to true if this PromotionArgument contains applicable promotions.
      void setInvocationTemplate(java.lang.String aInvocationTemplate)
      Sets the invocation template.
      void setOrder(Order aOrder)
      Sets the order.
      void setOwner(Customer aOwner)
      Sets the owner.
      void setParameter(java.lang.String name, java.lang.Object value)
      Sets name/value pair in the hash table used for storing any additional parameters to promotion engine and promotions.
      void setPreviousResultDiscarded(boolean aPreviousResultDiscarded)
      Sets whether previous promotion results will be discarded or not.
      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
    • Constructor Detail

      • PromotionArgument

        public PromotionArgument()
        Constructor for PromotionArgument.
      • PromotionArgument

        public PromotionArgument(Order aOrder,
                                 Customer aCustomer,
                                 java.lang.String aTemplate,
                                 boolean aDiscard,
                                 boolean aSave,
                                 java.util.Hashtable aNVP)
        Constructor used to create a PromotionArgument
        Parameters:
        aOrder - The order to which promotion will be applied
        aCustomer - Owner of the order
        aTemplate - The name of the invocation template (point)
        aDiscard - Whether previous promotion results will be discarded or not
        aSave - Whether the result of current session will be saved in persistent storage or not
        aNVP - any additional parameters in name-value pair style
    • 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()
      • getOwner

        public Customer getOwner()
        Returns the reference of Customer entity which belongs to the PromotionArgument
        Returns:
        the reference of Customer entity
      • getPromotionExecutionRecords

        public java.util.Iterator getPromotionExecutionRecords()
        Returns the list of all results from evaluation of promotions
        Returns:
        the list of all results from evaluation of promotions
      • appendPromotionExecutionRecord

        public void appendPromotionExecutionRecord(PromotionExecutionRecord record)
        Appends a promotion execution record
        Parameters:
        record - the promotion execution record to append
      • getParameter

        public java.lang.Object getParameter(java.lang.String name)
        Returns object value from name and value pair stored in a Hashtable containing any additional parameters to promotion engine and promotions. Returns null if the name-value pair searched using the name parameter cannot be found.
        Parameters:
        name - the name of the object to be fetched
        Returns:
        object value from name and value pair stored in the Hashtable.
      • setParameter

        public void setParameter(java.lang.String name,
                                 java.lang.Object value)
        Sets name/value pair in the hash table used for storing any additional parameters to promotion engine and promotions.
        Parameters:
        name - the name of name and value pair stored in the hash table
        value - the value of name and value pair stored in the hash table
      • toXML

        public java.lang.String toXML()
                               throws XMLizationException
        Description copied from interface: XMLizable
        Converts the object into its corresponding XML format representation.
        Specified by:
        toXML in interface XMLizable
        Returns:
        The string format of the XML that represents this XMLizable object
        Throws:
        XMLizationException - when this process fails
        See Also:
        com.ibm.commerce.marketing.common.XMLizable#toXML()
      • fromXML

        public void fromXML(org.w3c.dom.Node anXMLNode)
                     throws DeXMLizationException
        Description copied from interface: XMLizable
        Transforms the XML node into its corresponding real Object.
        Specified by:
        fromXML in interface XMLizable
        Parameters:
        anXMLNode - The node that represents an XMLizable object
        Throws:
        DeXMLizationException - when this process fails
        See Also:
        com.ibm.commerce.marketing.common.XMLizable#fromXML(Node)
      • setOrder

        public void setOrder(Order aOrder)
        Sets the order.
        Parameters:
        aOrder - The order to set
      • setOwner

        public void setOwner(Customer aOwner)
        Sets the owner.
        Parameters:
        aOwner - The owner to set
      • getInvocationTemplate

        public java.lang.String getInvocationTemplate()
        Returns the invocation Template.
        Returns:
        String is the name of predefined promotion invocation template.
      • setInvocationTemplate

        public void setInvocationTemplate(java.lang.String aInvocationTemplate)
        Sets the invocation template.
        Parameters:
        aInvocationTemplate - The invocation template to set
      • setAdditionalParameters

        public void setAdditionalParameters(java.util.Hashtable aNVP)
        This method is used to specify a Hashtable which contains additional parameters to promotion engine and promotions, using a name-value pair style.
        Parameters:
        aNVP - Hashtable containing the name-value pair style parameters to promotion engine and promotions.
      • isCurrentResultSaved

        public boolean isCurrentResultSaved()
        This method determines if the result of current session will be saved in persistent storage or not.
        Returns:
        true if the result of current session will be saved to persistent storage.
      • isPreviousResultDiscarded

        public boolean isPreviousResultDiscarded()
        This method determines if previous promotion results will be discarded or not.
        Returns:
        true if previous promotion results will be discarded.
      • hasApplicablePromotions

        public boolean hasApplicablePromotions()
        This method determines if promotion argument contains any applicable promotions.
        Returns:
        true if promotion argument contains any applicable promotions.
      • setHasApplicablePromotions

        public void setHasApplicablePromotions(boolean aHasApplicablePromotions)
        Set to true if this PromotionArgument contains applicable promotions.
        Parameters:
        aHasApplicablePromotions - Set to true if there are any applicable promotions.
      • setCurrentResultSaved

        public void setCurrentResultSaved(boolean aCurrentResultSaved)
        Sets whether the result of current session will be saved in persistent storage or not.
        Parameters:
        aCurrentResultSaved - Set to true if the current session should be saved to persistent storage.
      • setPreviousResultDiscarded

        public void setPreviousResultDiscarded(boolean aPreviousResultDiscarded)
        Sets whether previous promotion results will be discarded or not.
        Parameters:
        aPreviousResultDiscarded - Set to true if previous promotion results should be discarded.
      • getOrderKey

        public OrderKey getOrderKey()
        Returns the key of an Order
        Returns:
        OrderKey The OrderKey object.
      • getOwnerKey

        public CustomerKey getOwnerKey()
        Returns the key of the Owner
        Returns:
        CustomerKey The CustomerKey object.
      • hasUnusedFreeGifts

        public boolean hasUnusedFreeGifts(PromotionExecutionRecord record)
        Checks a promotion execution record to determine if this is a free gift promotion where no free gift was selected.
        Parameters:
        record - A promotion execution record to check for unused free gifts.
        Returns:
        True if free gifts were available but none were selected. False if either a free gift was selected or this is not a free gift promotion.
      • finalizePromotionArgument

        public void finalizePromotionArgument()
                                       throws PromotionRuntimeException
        Finalizes promotion argument, marks all applicable PromotionExecutionRecords as applied and logs statistics.
        Throws:
        PromotionRuntimeException - when this process fails
      • getRunningTotal

        public OrderRunningTotal getRunningTotal()
        Returns the order running total object.
        Returns:
        The order running total object
      • toString

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

        public java.util.Hashtable getRuntimeAttributes()
        Returns a Hashtable containing the name-value pairs representing additional parameters to promotion engine and promotions.
        Returns:
        A Hashtable of Name-Value pairs for the additional parameters passed to PromotionArgument by the caller.
      • getEngineName

        public java.lang.String getEngineName()
        Returns the name of the promotion engine that is invoked.
        Returns:
        Name of the promotion engine.
      • setEngineName

        public void setEngineName(java.lang.String string)
        Sets the name of the promotion engine that is invoked.
        Parameters:
        string - Name of the promotion engine to set.
      • appendPromotionErrorReport

        public void appendPromotionErrorReport(PromotionErrorReport report)
        Appends a promotion error report to a list of error reports.
        Parameters:
        report - The error report to be added.
      • getPromotionErrorReports

        public PromotionErrorReport[] getPromotionErrorReports()
        Returns all the promotion error reports accumulated so far.
        Returns:
        An array of promotion error reports.