com.ibm.commerce.marketing.promotion.policy

Class GroupExclusivenessEnforcementPolicy

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


    public class GroupExclusivenessEnforcementPolicy
    extends java.lang.Object
    implements PromotionPolicy
    This is a group level policy and enforces the exclusivity of promotions at the group level. If this policy is not registered with a promotion group, then the promotion exclusivity at group level in that group will NOT be enforced. This means that even if a promotion in that group is marked as exclusive at the group level, it can still be combined with other promotions in the same group.

    XML Snippet:

         <PromotionPolicy impl="com.ibm.commerce.marketing.promotion.policy.GroupExclusivenessEnforcementPolicy">
            <PromotionPolicyKey>
                    <PolicyName>Unique Name for the policy</PolicyName>
                    <StoreKey>
                            <DN>o=root organization</DN>
                            <Identifier>BlueStore 202</Identifier>
                    </StoreKey>
            </PromotionPolicyKey>
            <!-- Active, Inactive or Deleted -->
            <Status>Active</Status>
         </PromotionPolicy>
     
     
    See Also:
    Serialized Form
    • Constructor Detail

      • GroupExclusivenessEnforcementPolicy

        public GroupExclusivenessEnforcementPolicy()
        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
        Enforces the exclusivity of promotions at the group level. This method gets the promotion under evaluation from the PromotionContext context parameter passed and checks if the promotion has group exclusiveness policy set. If this policy is set, it gets the other promotions from the PromotionArgument object (referenced using PromotionContext context) and for each such promotion, checks for two things:

        1. If the group name of the promotion obtained from the PromotionArgument is same as the group name of the promotion under evaluation.

        2. If the promotion obtained from the PromotionArgument is same as the promotion referenced in the PromotionExecutionRecord record parameter.

        If 1 is satisfied and 2 is not, then the record's state is set to eliminated and this policy is set to have been violated in the record; false is returned.

        Otherwise, the method obtains the other promotions in sequence from the context, checks if their group name is the same as the group name of the promotion under evaluation and marks them as not applicable to the current order; in other words, it enforces the group exclusiveness setting on the promotion under evaluation by marking all the other promotions as not applicable.
        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)