com.ibm.commerce.marketing.promotion.reward

Class Distribution

  • java.lang.Object
    • com.ibm.commerce.marketing.promotion.reward.Distribution
  • All Implemented Interfaces:
    com.ibm.commerce.marketing.promotion.reward.GenericDistribution, XMLizable, java.io.Serializable


    public class Distribution
    extends java.lang.Object
    implements com.ibm.commerce.marketing.promotion.reward.GenericDistribution
    Distribution class provides default implementation for GenericDistribution interface. After applying patterns to an order, it will result in zero or more matched patterns. When a distribution is applied to all matched patterns, the cost based volumn or quantity based tiered methodology will be used. As a result, adjustment can be properly applied to the order. XML Snippet for Distribution:
      <Distribution impl="com.ibm.commerce.marketing.promotion.reward.Distribution">
            <!-- Multiple Pattern Filters can go here -->
            <PatternFilter></PatternFilter>
            <!-- Volume or Tiered -->
            <Type>Volume</Type>
            <!-- Quantity or Cost -->
            <Base>Quantity</Base>
            <!-- Multiple Ranges can be specified -->
            <Range>
                <LowerBound>1</LowerBound>
                <UpperBound>5</UpperBound>
                <Reward></Reward>
                <Reward></Reward>
            </Range>
            <Range>
                <LowerBound>6</LowerBound>
                <UpperBound>10</UpperBound>
                <Reward></Reward>
                <Reward></Reward>
            </Range>
        </Distribution>
     
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String COPYRIGHT
      IBM copyright notice field.
      static int COST
      The base of the distribution is Cost.
      static int QUANTITY
      The base of the distribution is Quantity.
      static int TIERED
      The type of the distribution is Tiered.
      static int VOLUME
      The type of the distribution is Volume.
    • Constructor Summary

      Constructors 
      Constructor and Description
      Distribution()
      Constructor for Distribution.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      boolean distribute(LineItemSet[] inputItems, PromotionContext context)
      This method distributes the LineItemSets between different ranges and calculates the rewards for all qualified LineItemSets.
      void fromXML(org.w3c.dom.Node anXMLNode)
      Transforms the XML node into its corresponding real Object.
      int getBase()
      This method gets the quantity-based or cost-based type of the Distribution.
      java.lang.String getCurrency()
      This method gets the Currency used for defining ranges in Cost based Distribution.
      PatternFilter[] getPatternFilters()
      This method gets the PatternFilters of the Distribution.
      DistributionRange[] getRanges()
      This method gets the Ranges of the Distribution.
      int getType()
      This method gets the type of the Distribution (either Volume or Tiered).
      void setBase(int aBase)
      This methods sets the base of the Distribution.
      void setCurrency(java.lang.String aCurrency)
      This method sets the Currency used for defining ranges in Cost based Distribution.
      void setPatternFilters(PatternFilter[] filters)
      This method sets the PatternFilters for the Distribution.
      void setRanges(DistributionRange[] aRanges)
      This method sets the Ranges of the Distribution.
      void setType(int aType)
      This methods sets the type of the Distribution.
      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, toString, wait, wait, wait
    • Field Detail

      • COPYRIGHT

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

        public static final int QUANTITY
        The base of the distribution is Quantity.
        See Also:
        Constant Field Values
      • COST

        public static final int COST
        The base of the distribution is Cost.
        See Also:
        Constant Field Values
      • VOLUME

        public static final int VOLUME
        The type of the distribution is Volume.
        See Also:
        Constant Field Values
      • TIERED

        public static final int TIERED
        The type of the distribution is Tiered.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Distribution

        public Distribution()
        Constructor for Distribution.
    • Method Detail

      • getType

        public int getType()
        This method gets the type of the Distribution (either Volume or Tiered).
        Returns:
        constant VOLUME representing Volume type of Distribution; constant TIERED representing Tiered type of Distribution;
      • getCurrency

        public java.lang.String getCurrency()
        This method gets the Currency used for defining ranges in Cost based Distribution.
        Returns:
        The currency
      • getBase

        public int getBase()
        This method gets the quantity-based or cost-based type of the Distribution.
        Returns:
        constant QUANTITY for Quantity-based Distribution; constant COST for Cost-based Distribution;
      • getPatternFilters

        public PatternFilter[] getPatternFilters()
        This method gets the PatternFilters of the Distribution.
        Returns:
        list of PatternFilters of the Distribution
      • setPatternFilters

        public void setPatternFilters(PatternFilter[] filters)
        This method sets the PatternFilters for the Distribution.
        Parameters:
        filters - list of PatternFilters of the Distribution
      • setType

        public void setType(int aType)
        This methods sets the type of the Distribution.
        Parameters:
        aType - Type of Distribution. Set to one of the constants of VOLUME or TIERED.
      • setBase

        public void setBase(int aBase)
        This methods sets the base of the Distribution.
        Parameters:
        aBase - Base of Distribution. Set to one of the constants of QUANTITY OR COST.
      • setCurrency

        public void setCurrency(java.lang.String aCurrency)
        This method sets the Currency used for defining ranges in Cost based Distribution.
        Parameters:
        aCurrency - The currency to set.
      • getRanges

        public DistributionRange[] getRanges()
        This method gets the Ranges of the Distribution.
        Returns:
        list of DistributionRange
      • setRanges

        public void setRanges(DistributionRange[] aRanges)
        This method sets the Ranges of the Distribution.
        Parameters:
        aRanges - list of DistributionRange
      • distribute

        public boolean distribute(LineItemSet[] inputItems,
                                  PromotionContext context)
        This method distributes the LineItemSets between different ranges and calculates the rewards for all qualified LineItemSets.
        Specified by:
        distribute in interface com.ibm.commerce.marketing.promotion.reward.GenericDistribution
        Parameters:
        inputItems - List of LineItemSet
        context - PromotionContext
        Returns:
        boolean true if successfully distributed, false otherwise;