com.ibm.commerce.marketing.commands

Class PromotionCodeAddRemoveControllerCmdImpl

  • All Implemented Interfaces:
    AccCommand, ControllerCommand, ECCommand, ECTargetableCommand, PromotionCodeAddRemoveControllerCmd, Protectable, com.ibm.websphere.cache.Sizeable, com.ibm.websphere.command.CacheableCommand, com.ibm.websphere.command.Command, com.ibm.websphere.command.CommandCaller, com.ibm.websphere.command.TargetableCommand, java.io.Serializable


    public class PromotionCodeAddRemoveControllerCmdImpl
    extends ControllerCommandImpl
    implements PromotionCodeAddRemoveControllerCmd

    This Controller Command adds or removes a PromotionCode from an Order. It implements the PromotionCodeAddRemoveControllerCmd interface. This command is mapped to the PromotionCodeManage URL.

    If the command is executed as a URL Command the following url parameters must be set

    • promoCode (PromotionCode. If more than one promotion code needs to be specified they should be separated by a , )
    • orderId (The id of the order to which promotion code should be added to or removed from)
    • taskType (The task type. A for adding the promotion code to Order R for removing promotion code from Order.)

    Optionally the following url parameters can be set

    • URL (URL to which the request should be redirected after the command is successfully executed)
    • VIEW (VIEW to which the request should be forwarded after the command is successfully executed)
    • userIdentifier (If for guest shopper we need to set a token which uniquely identifies her/him)
              Note: If both URL & VIEW parameters are specified, the request will be redirected to URL. 
                        If both are not specified the request will be forwarded to CouponsDisplayView.
     

    If executing this Command as a task Command, the methods listed below must be invoked before calling the command

    • setPromotionCodes
    • setURL or setViewName
    • setTaskType
    • setOrderId

    Optionally the following methods can be invoked

    • setUserIdentifier (If for guest shopper we need to set a token which uniquely identifies her/him)
    See Also:
    Serialized Form
    • Constructor Detail

      • PromotionCodeAddRemoveControllerCmdImpl

        public PromotionCodeAddRemoveControllerCmdImpl()
        Constructor
    • Method Detail

      • setUserIdentifier

        public void setUserIdentifier(java.lang.String aUserIdentifier)
        This method sets the user identifier.
        Parameters:
        aUserIdentifier - the user identifier to set.
      • setURL

        public void setURL(java.lang.String aUrl)
        This method sets the redirect URL.
        Parameters:
        aUrl - the redirect URL to set.
      • setTaskType

        public void setTaskType(java.lang.String aTaskType)
        This method sets the task type. The taskType should be A for adding promotion code to order or R for removing promotion code from order.
        Parameters:
        aTaskType - the task type of A(adding) or R(removing) of promotion code from order.
      • setOrderId

        public void setOrderId(java.lang.Long aOrderId)
        This method sets the order ID for which the promotion code should be added or removed.
        Parameters:
        aOrderId - the order ID to set.
      • setPromotionCodes

        public void setPromotionCodes(java.util.Vector aPromotionCodes)
        This method sets the promotion codes.
        Parameters:
        aPromotionCodes - the promotion codes to set.
      • setViewName

        public void setViewName(java.lang.String aViewName)
        This method sets the view name.
        Parameters:
        aViewName - the view name to set.
      • getViewName

        public java.lang.String getViewName()
        This methods returns the view name.
        Returns:
        The view name.
      • getUserIdentifier

        public java.lang.String getUserIdentifier()
        This method gets the user identifier.
        Returns:
        The user identifier.
      • getURL

        public java.lang.String getURL()
        This method gets the redirect URL
        Returns:
        The redirect URL
      • getTaskType

        public java.lang.String getTaskType()
        This method gets the task type. Possible values include A for adding promotion code to order or R for removing promotion code from order.
        Returns:
        The task type of A or R.
      • getOrderId

        public java.lang.Long getOrderId()
        This method gets the order ID for which the promotion code should be added or removed.
        Returns:
        The order ID for which the promotion code should be added or removed.
      • getPromotionCodes

        public java.util.Vector getPromotionCodes()
        This method gets the promotion codes.
        Returns:
        The promotion codes.
      • removePromoCodeFromOrder

        public void removePromoCodeFromOrder()
                                      throws ECException
        Removes a promotion code from the current order.
        Throws:
        ECException - when such operation fails
      • addPromoCodeToOrder

        public void addPromoCodeToOrder()
                                 throws ECApplicationException
        Adds a promotion code to the current order
        Throws:
        ECApplicationException - when an error is encountered on adding a promotion code to the current order.
      • validatePromotionCode

        public boolean validatePromotionCode(java.lang.String pCode)
                                      throws ECApplicationException
        This method checks if the Promotion Code is valid.
        Parameters:
        pCode - java.lang.String is the promotion code.
        Returns:
        boolean true if promotion code is valid, false otherwise
        Throws:
        ECApplicationException - when the validation fails.
      • performExecute

        public void performExecute()
                            throws ECSystemException,
                                   ECException
        Command execution body for performing different tasks depending upon the task type. Possible values of the task types include A for adding Coupon to order or R for removing Coupon from order.
        Specified by:
        performExecute in interface ECCommand
        Specified by:
        performExecute in interface com.ibm.websphere.command.TargetableCommand
        Overrides:
        performExecute in class AbstractECTargetableCommand
        Throws:
        ECSystemException - a system exception when such operation fails.
        ECException - a general exception when such operation fails.