com.ibm.commerce.marketing.promotion.reward

Class DefaultChoiceOfFreeGiftAdjustment

  • java.lang.Object
    • com.ibm.commerce.marketing.promotion.reward.DefaultChoiceOfFreeGiftAdjustment
  • All Implemented Interfaces:
    Adjustment, ChoiceOfFreeGiftAdjustment, ChoiceOfRewardAdjustment, XMLizable, java.io.Serializable, java.lang.Cloneable


    public class DefaultChoiceOfFreeGiftAdjustment
    extends java.lang.Object
    implements ChoiceOfFreeGiftAdjustment
    This class implements Adjustment interface and uses the FreeGiftSpecification to define the Adjustment rule of a Choice Of Free Gift promotion . Optionally, a default FreeGiftChoice selection can be defined as well. XML Snippet for this Adjustment:
     <p>
     <Adjustment impl="com.ibm.commerce.marketing.promotion.reward.DefaultChoiceOfFreeGiftAdjustment">
            <RewardSpecification impl="com.ibm.commerce.marketing.promotion.choice.gift.FreeGiftSpecification">
                    <MaxQuantity>3</MaxQuantity>
                    <GiftItem impl="com.ibm.commerce.marketing.promotion.choice.gift.CatalogEntryGiftItem">
                            <Quantity>3</Quantity>
                            <CatalogEntryKey>
                                    <SKU>SKU-20101099</SKU>
                                    <DN>o=Root Organization</DN>        
                            </CatalogEntryKey>        
                    </GiftItem>
            </RewardSpecification>
      <RewardChoice impl="com.ibm.commerce.marketing.promotion.choice.gift.FreeGiftChoice">
               <GiftItem impl="com.ibm.commerce.marketing.promotion.choice.gift.CatalogEntryGiftItem">
                    <Quantity>1</Quantity>
                    <CatalogEntryKey>
                            <SKU>SKU-20101099</SKU>
                            <DN>o=Root Organization</DN>        
                    </CatalogEntryKey>        
               </GiftItem>
      </RewardChoice>
            <AdjustmentType>AllAffectedItems</AdjustmentType>
     </Adjustment>
     </p>
     
    See Also:
    Serialized Form
    • Field Detail

      • COPYRIGHT

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

        public static final java.lang.String TAG_ADJUSTMENT_TYPE
        XML Tag names
        See Also:
        Constant Field Values
      • TAG_ADJUSTMENT

        public static final java.lang.String TAG_ADJUSTMENT
        XML tag - Adjustment
        See Also:
        Constant Field Values
      • ATTRIBUTE_NAME_IMPL

        public static final java.lang.String ATTRIBUTE_NAME_IMPL
        XML attribute name - impl
        See Also:
        Constant Field Values
    • Constructor Detail

      • DefaultChoiceOfFreeGiftAdjustment

        public DefaultChoiceOfFreeGiftAdjustment()
    • Method Detail

      • applyNewRewardOption

        public void applyNewRewardOption(PromotionContext context)
        Creates a new RewardOption object.
        Parameters:
        context - The promotion context.
      • applyChoice

        public boolean applyChoice(FreeGiftChoice aFreeGiftChoice,
                                   java.util.Vector affectedVector,
                                   java.util.Vector adjustmentVector)
        Applies the free gift choice to the promotion.
        Parameters:
        aFreeGiftChoice - The FreeGiftChoice object.
        affectedVector - The Vector of affected item set.
        adjustmentVector - The vector of Adjustment.
        Returns:
        true or false indicates if the gift choice is applied or not.
      • apply

        public boolean apply(LineItemSet targeted,
                             java.math.BigDecimal targetedAmount,
                             int targetedAmountTypes,
                             LineItemSet affected,
                             java.util.Vector affectedVector,
                             java.util.Vector adjustmentVector,
                             PromotionContext context)
                      throws PromotionRuntimeException
        Description copied from interface: Adjustment
        This method evaluates the targeted order items to see if they fulfill the conditions of this adjustment ( for example, if the quantity of the order items falls into one of the ranges of the adjustment). Depending upon if and what conditions are fulfilled, an Adjustment object is added to the adjustmentVector Vector object passed as a parameter. The affectedVector Vector object passed as a parameter is updated by adding the affected order items. This method is called in the invoke(LineItemSet, BigDecimal, int, Vector, Vector, PromotionContext) method of AdjustmentFunction.
        Specified by:
        apply in interface Adjustment
        Parameters:
        targeted - The targeted order items. This is a set of order items (or portions of order items) that are used to qualify for the promotion of which this adjustment is a part.
        affected - The affected order items. This is a set of order items, identified by the promotion, to which this adjustment will be attached.
        affectedVector - A Vector which contains the affected LineItemSets.
        adjustmentVector - A Vector which contains the Adjustment objects.
        context - The PromotionContext object which may be used to build the Adjustment to add to the adjustmentVector parameter.
        Returns:
        A boolean value indicating whether the conditions of the adjustment were fulfilled successfully or not. A true value indicates that the conditions of the adjustment were fulfilled successully, otherwise a false value is returned.
        Throws:
        PromotionRuntimeException - when the computation encounters a problem.
        See Also:
        Adjustment.apply(com.ibm.commerce.marketing.promotion.runtime.LineItemSet, java.math.BigDecimal, int, com.ibm.commerce.marketing.promotion.runtime.LineItemSet, java.util.Vector, java.util.Vector, com.ibm.commerce.marketing.promotion.runtime.PromotionContext)
      • getAdjustmentType

        public java.lang.Integer getAdjustmentType()
        This implementation always return value 2 as "AllAffectedItems".
        Specified by:
        getAdjustmentType in interface Adjustment
        Returns:
        one of the defined constants of WHOLE_ORDER, ALL_AFFECTED_ITEMS or INDIVIDUAL_AFFECTED_ITEMS.
        See Also:
        Adjustment.getAdjustmentType()
      • setAdjustmentType

        public void setAdjustmentType(java.lang.Integer aAdjustmentType)
        Description copied from interface: Adjustment
        This method sets the type of Adjustment. An adjustment can be of the following types for whole Order, for All Affected Items, and for Individual Affected Items. Set adjustmentType to one of the defined constants of WHOLE_ORDER, ALL_AFFECTED_ITEMS or INDIVIDUAL_AFFECTED_ITEMS.
        Specified by:
        setAdjustmentType in interface Adjustment
        See Also:
        Adjustment.setAdjustmentType(java.lang.Integer)
      • clone

        public java.lang.Object clone()
                               throws java.lang.CloneNotSupportedException
        Specified by:
        clone in interface Adjustment
        Overrides:
        clone in class java.lang.Object
        Throws:
        java.lang.CloneNotSupportedException
        See Also:
        Object.clone()
      • setRewardSpecification

        public void setRewardSpecification(FreeGiftSpecification aFreeGiftSpecification)
        Sets the FreeGiftSpecification object.
        Parameters:
        aFreeGiftSpecification - The FreeGiftSpecification to set.
      • setFreeGiftChoice

        public void setFreeGiftChoice(FreeGiftChoice aFreeGiftChoice)
        Sets the FreeGiftChoice object as the default RewardChoice.
        Parameters:
        aFreeGiftChoice - The FreeGiftChoice object to set.