com.ibm.commerce.marketing.promotion.condition

Class Pattern

  • java.lang.Object
    • com.ibm.commerce.marketing.promotion.condition.Pattern
  • All Implemented Interfaces:
    com.ibm.commerce.marketing.promotion.condition.GenericPattern, XMLizable, java.io.Serializable


    public class Pattern
    extends java.lang.Object
    implements com.ibm.commerce.marketing.promotion.condition.GenericPattern
    Pattern is the approach to group a set of products and items in the shop cart in order to identify if the purchase condition criteria is met. A pattern is made up of multiple constraints, each specifying a list of items that make up part of the pattern. A typical example of a pattern is: Purchase 2 pairs of pants and 1 sweater. In this example, 2 constraints are used: �2 pairs of pants� and �1 sweater�. Pattern class is the default implementation of GenericPattern interface used by PurchaseCondition.
    An XML Snippet for Pattern is provided below.
      
       <Pattern impl="com.ibm.commerce.marketing.promotion.condition.Pattern">
              <!-- The line item sets should be kept unique between multiple constraints in 
                 the pattern. The default value is false. -->
                    <UniqueConstraints>false</UniqueConstraints>
               <Constraint impl= "com.ibm.commerce.marketing.promotion.condition.Constraint">
                <!-- Quantity requirement of this constraint -->
                <WeightedRange impl= "com.ibm.commerce.marketing.promotion.condition.WeightedRange">
                  <!-- Minimum number of items is 1 --> 
                  <LowerBound>1</LowerBound>
     
                  <!-- Maximum number of items is not limited -->
                   <UpperBound>-1</UpperBound>
     
                   <!-- Match as many as items that satisfy the criteria defined in 
                        the filter chain next -->
                   <Weight>1</Weight>
                </WeightedRange>
     
                 <!-- Selection criteria -->
                <FilterChain impl= "com.ibm.commerce.marketing.promotion.condition.FilterChain">
       
                  <!-- Multiple filters can be specified; they are applied in a 
                       contiguous fashion, that is, connected using a logical "and". -->
                  <!-- The dummy filter returns anything passed to it, it 
                       effectively selects everything -->
                  <Filter impl= "com.ibm.commerce.marketing.promotion.condition.DummyFilter" />
               </FilterChain>
     
               <!-- The combination of the quantity requirement and the filter 
                     chain would return everything present in the shopcart as one big 
                     matched pattern -->
     
            </Constraint>
     
         </Pattern>
       
     
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String COPYRIGHT
      IBM copyright notice field.
      static java.lang.String TAG_UNIQUE_CONSTRAINTS
      XML tag - "UniqueConstraints"
    • Constructor Summary

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

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void fromXML(org.w3c.dom.Node anXMLNode)
      Transforms the XML node into its corresponding real Object.
      Constraint[] getConstraints()
      Returns the array of Constraints that make up the pattern definition
      static boolean isLeastExpensiveItemsFirst()
      A get method to return the value of config flag which determines if promotion is set to apply to least expensive items first
      boolean isUniqueConstraints()
      Gets the flag indicating whether the line item sets should be kept unique between multiple constraints in the pattern.
      LineItemSet[] match(LineItemSet order, PromotionContext context)
      This function uses the constraints that make up the pattern to spot as many matched items as possible in a single test.
      void setConstraints(Constraint[] aConstraints)
      Sets the array of Constraints that make up the pattern definition
      void setUniqueConstraints(boolean aUniqueConstraints)
      Sets the flag that indicates whether the line item sets should be kept unique between multiple constraints in the pattern.
      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
      • TAG_UNIQUE_CONSTRAINTS

        public static final java.lang.String TAG_UNIQUE_CONSTRAINTS
        XML tag - "UniqueConstraints"
        See Also:
        Constant Field Values
    • Constructor Detail

      • Pattern

        public Pattern()
        Constructor for Pattern.
    • Method Detail

      • isLeastExpensiveItemsFirst

        public static boolean isLeastExpensiveItemsFirst()
        A get method to return the value of config flag which determines if promotion is set to apply to least expensive items first
        Returns:
        returns the value of leaseExpensiveItemsFirst flag set by config
      • match

        public LineItemSet[] match(LineItemSet order,
                                   PromotionContext context)
                            throws PromotionRuntimeException
        This function uses the constraints that make up the pattern to spot as many matched items as possible in a single test. Each resultant line item set represents a match of this pattern. The algorithm used in this match routine is a batched routine.
        Specified by:
        match in interface com.ibm.commerce.marketing.promotion.condition.GenericPattern
        Parameters:
        order - LineItemSet
        context - PromotionContext
        Returns:
        List of matched LineItemSet
        Throws:
        PromotionRuntimeException - is thrown when the system encounters an error
      • getConstraints

        public Constraint[] getConstraints()
        Returns the array of Constraints that make up the pattern definition
        Returns:
        an array of Constraints
      • setConstraints

        public void setConstraints(Constraint[] aConstraints)
        Sets the array of Constraints that make up the pattern definition
        Parameters:
        aConstraints -
      • isUniqueConstraints

        public boolean isUniqueConstraints()
        Gets the flag indicating whether the line item sets should be kept unique between multiple constraints in the pattern.
        Returns:
        A value true indicates that the line item sets should be kept unique between multiple constraints in the pattern; false otherwise.
      • setUniqueConstraints

        public void setUniqueConstraints(boolean aUniqueConstraints)
        Sets the flag that indicates whether the line item sets should be kept unique between multiple constraints in the pattern.
        Parameters:
        aUniqueConstraints - The value to set.