com.ibm.commerce.marketing.promotion.policy

Class EachItemCanParticipateInPromotionOncePolicy

  • java.lang.Object
    • com.ibm.commerce.marketing.promotion.policy.EachItemCanParticipateInPromotionOncePolicy
  • All Implemented Interfaces:
    PromotionPolicy, XMLizable, java.io.Serializable


    public class EachItemCanParticipateInPromotionOncePolicy
    extends java.lang.Object
    implements PromotionPolicy
    This is a group level promotion policy and prevents any order items from being targeted or affected by a promotion more than once. By default, an order item cannot be targeted or affected by more than one promotion. However, exemptions can be made so that an order item can be affected by more than one promotion although it cannot be targeted more than once. Similar exemptions can be made so that an order item can be targeted by more than one promotion but cannot be affected by more than one promotion.

    XML Snippet of EachItemCanParticipateInPromotionOncePolicy:

     <PromotionPolicy impl="com.ibm.commerce.marketing.promotion.policy.EachItemCanParticipateInPromotionOncePolicy">
      <PromotionPolicyKey>
      <PolicyName>Shipping: Any order item can only participate in one promotion</PolicyName>
      <StoreKey>
            <DN>ou=bluemall b2b organization,o=seller organization,o=root organization</DN>
            <Identifier>BlueStore 202</Identifier>
      </StoreKey>
      </PromotionPolicyKey>
      
      <!-- Exemptions are optional and can be listed like the following:
      
      <Exemption>Targeted</Exemption>
      OR
      <Exemption>Affected</Exemption>
      
      -->
      <Status>Active</Status>
     </PromotionPolicy>
     
     
     
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      boolean apply(PromotionContext context, PromotionExecutionRecord record)
      This method is used to mark line items in the PromotionContext, to not be targeted or to not be affected, by promotions, at current group level, depending upon the Exemption configuration value.
      void fromXML(org.w3c.dom.Node anXMLNode)
      Transforms the XML node into its corresponding real Object.
      java.lang.String getDescription(java.util.Locale locale, int type)
      Returns the description of the promotion policy based on its type and locale.
      PromotionPolicyKey getKey()
      Returns the key of this promotion policy
      int getStatus()
      Returns the status of this promotion policy
      boolean isExemptedFromAffectRule()
      Returns the flag that controls whether to enforce the each item can be affected by a single promotion rule or not
      boolean isExemptedFromTargetRule()
      Returns the flag that controls whether to enforce the each item can be targeted by a single promotion rule or not
      void setExemptedFromAffectRule(boolean b)
      Sets the flag that controls whether to enforce the each item can be affected by a single promotion rule or not
      void setExemptedFromTargetRule(boolean b)
      Sets the flag that controls whether to enforce the each item can be targeted by a single promotion rule or not
      void setKey(PromotionPolicyKey akey)
      Sets the key of this promotion policy
      void setStatus(int newStatus)
      Sets the status of a promotion policy.
      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
    • Constructor Detail

      • EachItemCanParticipateInPromotionOncePolicy

        public EachItemCanParticipateInPromotionOncePolicy()
        Constructor.
    • Method Detail

      • getDescription

        public java.lang.String getDescription(java.util.Locale locale,
                                               int type)
        Description copied from interface: PromotionPolicy
        Returns the description of the promotion policy based on its type and locale.
        Specified by:
        getDescription in interface PromotionPolicy
        Parameters:
        locale - for which the description is being retrieved.
        type - the type of description to retrieve. Possible type values include Description.ADMIN_DESC, Description.SHOPPER_LONG_DESC or Description.SHOPPER_SHORT_DESC.
        Returns:
        the description
        See Also:
        PromotionPolicy.getDescription(Locale, int)
      • apply

        public boolean apply(PromotionContext context,
                             PromotionExecutionRecord record)
                      throws PromotionPolicyApplicationException
        This method is used to mark line items in the PromotionContext, to not be targeted or to not be affected, by promotions, at current group level, depending upon the Exemption configuration value.
        • If the Exemption node value is Targeted, then it obtains targeted items from the PromotionExecutionRecord and marks these line items in the PromotionContext to not be targeted by promotions at group level.
        • If the Exemption node value is Affected, then it obtains targeted items from the PromotionExecutionRecord and marks these line items in the PromotionContext to not be affected by promotions at group level; it also obtains the affected line items from the PromotionExecutionRecord and marks these line items in the PromotionContext to not be affected or targeted by promotions at current group level.
        • If cross sections are found between the line items in the PromotionContext that can no longer be affected by current promotion and the line items that are currently affected in the PromotionExecutionRecord, then the method returns false.
        • If cross sections are found between the line items in the PromotionContext that can no longer be targeted by current promotion and the line items that are targeted in the PromotionExecutionRecord, then the method returns false.
        Specified by:
        apply in interface PromotionPolicy
        Parameters:
        context - PromotionContext, created and passed to this policy by the engine
        record - the PromotionExecutionRecord for which violation is tested.
        Returns:
        true if by applying this promotion (as indicated by the record parameter), no violation with this policy is found. false a violation is found, this promotion can not be applied.
        Throws:
        PromotionPolicyApplicationException - when the evaluation runs into any unexpected error
        See Also:
        PromotionPolicy.apply(PromotionContext, PromotionExecutionRecord)
      • getStatus

        public int getStatus()
        Description copied from interface: PromotionPolicy
        Returns the status of this promotion policy
        Specified by:
        getStatus in interface PromotionPolicy
        Returns:
        status of this promotion: one of the constants of POLICY_STATUS_ACTIVE, POLICY_STATUS_INACTIVE, POLICY_STATUS_DELETED.
        See Also:
        PromotionPolicy.getStatus()
      • setStatus

        public void setStatus(int newStatus)
        Description copied from interface: PromotionPolicy
        Sets the status of a promotion policy. Possible values include one of the constants of POLICY_STATUS_ACTIVE, POLICY_STATUS_INACTIVE, POLICY_STATUS_DELETED.
        Specified by:
        setStatus in interface PromotionPolicy
        Parameters:
        newStatus - the new status to set
        See Also:
        PromotionPolicy.setStatus(int)
      • isExemptedFromAffectRule

        public boolean isExemptedFromAffectRule()
        Returns the flag that controls whether to enforce the each item can be affected by a single promotion rule or not
        Returns:
        true if the "affected" rule is not enforced, false otherwise.
      • isExemptedFromTargetRule

        public boolean isExemptedFromTargetRule()
        Returns the flag that controls whether to enforce the each item can be targeted by a single promotion rule or not
        Returns:
        true if the "targeted" rule is not enforced, false otherwise.
      • setExemptedFromAffectRule

        public void setExemptedFromAffectRule(boolean b)
        Sets the flag that controls whether to enforce the each item can be affected by a single promotion rule or not
        Parameters:
        b - true if the "affected" rule is not enforced, false otherwise.
      • setExemptedFromTargetRule

        public void setExemptedFromTargetRule(boolean b)
        Sets the flag that controls whether to enforce the each item can be targeted by a single promotion rule or not
        Parameters:
        b - true if the "targeted" rule is not enforced, false otherwise.