com.ibm.commerce.marketing.promotion.condition

Class ItemSortingFilter

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


    public class ItemSortingFilter
    extends java.lang.Object
    implements Filter
    ItemSortingFilter sorts the input LineItemSet according to the order item price (before any discounts), using the specified SortingMethod and returns the ordered LineItems. By default, the order items are sorted in ascending order of prices. If the SortingMethod specified is 'PriceHighToLow', then the order items are sorted in descending order of prices. By default, an item LineItemSet is split from the start to the end for pattern matching. If the SplitMethod specified is 'SplitEndToStart', then the item is split from the end to the start. This class implements the Filter interface. XML Snippet for this type of Filter:
      <Filter impl="com.ibm.commerce.marketing.promotion.condition.ItemSortingFilter">
                    <!-- PriceHighToLow or PriceLowToHigh -->
                    <SortingMethod>PriceLowToHigh</SortingMethod>               
                    <SplitMethod>SplitStartToEnd</SplitMethod>          
     </Filter>
     
    See Also:
    Serialized Form
    • Field Detail

      • COPYRIGHT

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

        public static final java.lang.String TAG_FILTER
        XML Tag 'Filter'.
        See Also:
        Constant Field Values
      • TAG_SORTING_METHOD

        public static final java.lang.String TAG_SORTING_METHOD
        XML Tag 'SortingMethod'.
        See Also:
        Constant Field Values
      • TAG_SPLIT_METHOD

        public static final java.lang.String TAG_SPLIT_METHOD
        XML Tag 'SplitMethod'.
        See Also:
        Constant Field Values
      • SORTING_METHOD_PRICE_HIGH_TO_LOW

        public static final java.lang.String SORTING_METHOD_PRICE_HIGH_TO_LOW
        XML value 'PriceHighToLow'.
        See Also:
        Constant Field Values
      • SORTING_METHOD_PRICE_LOW_TO_HIGH

        public static final java.lang.String SORTING_METHOD_PRICE_LOW_TO_HIGH
        XML value 'PriceLowToHigh'.
        See Also:
        Constant Field Values
      • SPLIT_METHOD_START_TO_END

        public static final java.lang.String SPLIT_METHOD_START_TO_END
        XML value 'SplitStartToEnd'.
        See Also:
        Constant Field Values
      • SPLIT_METHOD_END_TO_START

        public static final java.lang.String SPLIT_METHOD_END_TO_START
        XML value 'SplitEndToStart'.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ItemSortingFilter

        public ItemSortingFilter()
        Constructor for ItemSortingFilter.
    • Method Detail

      • getSortingMethod

        public java.lang.String getSortingMethod()
        This method gets the sorting method.
        Returns:
        one of the two constants of SORTING_METHOD_PRICE_HIGH_TO_LOW or SORTING_METHOD_PRICE_LOW_TO_HIGH.
      • setSortingMethod

        public void setSortingMethod(java.lang.String newSortingMethod)
        This method sets the sorting method.
        Parameters:
        newSortingMethod - Set to one of the two constants of SORTING_METHOD_PRICE_HIGH_TO_LOW or SORTING_METHOD_PRICE_LOW_TO_HIGH
      • getSplitMethod

        public java.lang.String getSplitMethod()
        This method gets the split method.
        Returns:
        one of the two constants of SPLIT_METHOD_START_TO_END or SPLIT_METHOD_END_TO_START.
      • setSplitMethod

        public void setSplitMethod(java.lang.String newSplitMethod)
        This method sets the split method.
        Parameters:
        newSortingMethod - Set to one of the two constants of SPLIT_METHOD_START_TO_END or SPLIT_METHOD_END_TO_START
      • filter

        public LineItemSet filter(LineItemSet input,
                                  PromotionContext context)
        This filter method calls the getSortedLineItemSet() method with the AssociatedOrderItems obtained from the input LineItemSet. The order items are sorted according to their prices in ascending order by default. If the SortingMethod of 'PriceHighToLow' is specified, then the sorting is done in descending order of prices. The sorted LineItemSet is then returned by the method. If an exception is encountered, then an empty LineItemSet is returned by the method.
        Specified by:
        filter in interface Filter
        Parameters:
        input - LineItemSet
        context - PromotionContext
        Returns:
        the filtered LineItemSet
        See Also:
        Filter.filter(LineItemSet, PromotionContext)
      • getSortedLineItemSet

        public LineItemSet getSortedLineItemSet(AssociatedOrderItem[] items)
        This method takes as input an array of AssociatedOrderItems and sorts them according to their prices. The sorting order by default is the ascending order of prices; if however the SortingMethod of 'PriceHighToLow' is set, then the sorting is done in descending order of prices.
        Parameters:
        items - An array of AssociatedOrderItems.
        Returns:
        A LineItemSet containing the AssociatedOrderItems in sorted order.