com.ibm.commerce.couponredemption.commands
Class UseCouponIdTaskCmdImpl

java.lang.Object
  |
  +--com.ibm.commerce.command.AbstractECCommand
        |
        +--com.ibm.commerce.command.TaskCommandImpl
              |
              +--com.ibm.commerce.couponredemption.commands.UseCouponIdTaskCmdImpl
All Implemented Interfaces:
ECCommand, TaskCommand, UseCouponIdTaskCmd

public class UseCouponIdTaskCmdImpl
extends TaskCommandImpl
implements UseCouponIdTaskCmd

This command is invoked when the shopper specifies a set of eCoupon codes explicitly while checking out.

The input to this command is :

If the given set of BCIDs aren't valid for this shopper from the CPWALLET, then an error page is send to the user. If the above condition is true then, the following steps are performed. The CheckValidityCmd command is called to find the eCoupons that are not expired and for not expired eCoupons, CheckApplicabilityCmd command is called to find out which eCoupons are applicable for this order. For applicable coupons, CalculateDiscountAmtCmd command is called to calculate the discount amount and CouponDSSTaskCmd command is called to check for any conflict.


Field Summary
protected  java.lang.Integer calculationUsage
           
protected  java.util.Hashtable conflicts
           
protected  java.lang.Long[] couponIds
           
protected  java.lang.String currency
           
protected  java.lang.Integer errorCode
           
protected  java.util.Vector invalidCoupons
           
protected  int numCoupons
           
protected  java.lang.Long orderId
           
protected  CommandContext processingContext
           
protected  TypedProperty requestProperties
           
protected  java.lang.Long shopperId
           
protected  java.lang.Integer storeId
           
protected  boolean validSelection
           
protected  java.util.Vector vecInpCouponId
           
 
Fields inherited from class com.ibm.commerce.command.AbstractECCommand
commandContext
 
Fields inherited from interface com.ibm.commerce.couponredemption.commands.UseCouponIdTaskCmd
COPYRIGHT, defaultCommandClassName, Name
 
Constructor Summary
UseCouponIdTaskCmdImpl()
          UseCouponIdCmdImpl constructor call super.
 
Method Summary
 boolean checkCouponIdShopperState()
          Returns true if the CouopnId are for this shopper and in Usable state.
 java.lang.Integer getCalculationUsage()
          Returns the calculationUsage.
 java.util.Hashtable getConflicts()
          Returns the conflicts.
 java.lang.Long[] getCouponIds()
          Returns the couponIds.
 java.lang.String getCurrency()
          Get the currency.
 java.lang.Integer getErrorCode()
          Returns the error code.
 java.util.Vector getInvalidCoupons()
          Returns the invalid coupons.
 int getNumCoupons()
          Returns the number of coupons.
 java.lang.Long getOrderId()
          Get the order id.
 CommandContext getProcessingContext()
          Returns the processing context.
 TypedProperty getRequestProperties()
          Returns the request properties.
 java.lang.Long getShopperId()
          Get the shoperId.
 void insertIntoDB(java.lang.Long orderId, java.util.Hashtable couponHashtable)
          Insert data into database.
 boolean isValidSelection()
          Returns true if the selection was valid.
 void performExecute()
          This command is invoked when the shopper specifies a set of eCoupon codes explicitly while checking out.
 void removeExistingAdjustments(java.lang.Long anOrderId)
          Removes the existing adjustments for this order.
 void removeOldEntries()
          It removes the old entries from the TORCPMAP and TCPITMAP tables.
 void setCalculationUsage(java.lang.Integer newCalculationUsage)
          Sets the calculation usage.
 void setConflicts(java.util.Hashtable newConflicts)
          Sets the conflicts.
 void setCouponIds(java.lang.Long[] newCouponIds)
          Sets the couponIds.
 void setCurrency(java.lang.String newCurrency)
          It set the currency.
 void setErrorCode(java.lang.Integer newErrorCode)
          Sets the errorcode.
 void setInvalidCoupons(java.util.Vector newInvalidCoupons)
          Sets the invalidCoupons.
 void setNumCoupons(int newNumCoupons)
          Sets teh number of coupons.
 void setOrderId(java.lang.Long newOrderId)
          Set the order id.
 void setProcessingContext(CommandContext newProcessingContext)
          Sets the processing context.
 void setRequestProperties(TypedProperty newRequestProperties)
          Sets the processing context.
 void setShopperId(java.lang.Long newShopperId)
          Set the shopperId.
 void setValidSelection(boolean newValidSelection)
          Sets the validSelect field.
 void validateParameters()
          Extracts the couponIds to be used in the command from the request.
 
Methods inherited from class com.ibm.commerce.command.AbstractECCommand
accessControlCheck, checkIsAllowed, checkResourcePermission, execute, finalize, getAccCheck, getCommandContext, getCommandIfName, getCommandName, getDefaultProperties, getResources, getStoreId, getUser, getUserId, isReadyToCallExecute, reset, setAccCheck, setCommandContext, setCommandIfName, setDefaultProperties
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.ibm.commerce.command.ECCommand
checkIsAllowed, checkResourcePermission, execute, getAccCheck, getCommandContext, getCommandIfName, getCommandName, getDefaultProperties, getResources, getStoreId, getUser, getUserId, setAccCheck, setCommandContext, setCommandIfName, setDefaultProperties
 

Field Detail

calculationUsage

protected java.lang.Integer calculationUsage

conflicts

protected java.util.Hashtable conflicts

couponIds

protected java.lang.Long[] couponIds

currency

protected java.lang.String currency

errorCode

protected java.lang.Integer errorCode

invalidCoupons

protected java.util.Vector invalidCoupons

numCoupons

protected int numCoupons

orderId

protected java.lang.Long orderId

processingContext

protected CommandContext processingContext

requestProperties

protected TypedProperty requestProperties

shopperId

protected java.lang.Long shopperId

storeId

protected java.lang.Integer storeId

validSelection

protected boolean validSelection

vecInpCouponId

protected java.util.Vector vecInpCouponId
Constructor Detail

UseCouponIdTaskCmdImpl

public UseCouponIdTaskCmdImpl()
UseCouponIdCmdImpl constructor call super.
Method Detail

checkCouponIdShopperState

public boolean checkCouponIdShopperState()
                                  throws ECSystemException
Returns true if the CouopnId are for this shopper and in Usable state.
Returns:
boolean

getCalculationUsage

public java.lang.Integer getCalculationUsage()
Returns the calculationUsage.
Returns:
java.lang.Integer

getConflicts

public java.util.Hashtable getConflicts()
Returns the conflicts.
Specified by:
getConflicts in interface UseCouponIdTaskCmd
Returns:
java.util.Hashtable

getCouponIds

public java.lang.Long[] getCouponIds()
Returns the couponIds.
Returns:
java.lang.Long[]

getCurrency

public java.lang.String getCurrency()
Get the currency.
Returns:
java.lang.String

getErrorCode

public java.lang.Integer getErrorCode()
Returns the error code.
Specified by:
getErrorCode in interface UseCouponIdTaskCmd
Returns:
java.lang.Integer

getInvalidCoupons

public java.util.Vector getInvalidCoupons()
Returns the invalid coupons.
Specified by:
getInvalidCoupons in interface UseCouponIdTaskCmd
Returns:
java.util.Vector

getNumCoupons

public int getNumCoupons()
Returns the number of coupons.
Specified by:
getNumCoupons in interface UseCouponIdTaskCmd
Returns:
int

getOrderId

public java.lang.Long getOrderId()
Get the order id.

getProcessingContext

public CommandContext getProcessingContext()
Returns the processing context.
Returns:
com.ibm.commerce.command.CommandContext

getRequestProperties

public TypedProperty getRequestProperties()
Returns the request properties.
Returns:
com.ibm.commerce.datatype.TypedProperty

getShopperId

public java.lang.Long getShopperId()
Get the shoperId.
Returns:
java.lang.Long

insertIntoDB

public void insertIntoDB(java.lang.Long orderId,
                         java.util.Hashtable couponHashtable)
                  throws ECSystemException
Insert data into database.
Parameters:
couponHashTable - java.util.Hashtable

isValidSelection

public boolean isValidSelection()
Returns true if the selection was valid.
Specified by:
isValidSelection in interface UseCouponIdTaskCmd
Returns:
boolean

performExecute

public void performExecute()
                    throws ECException

This command is invoked when the shopper specifies a set of eCoupon codes explicitly while checking out.
If the given set of BCIDs aren't valid for this shopper from the CPWALLET, then an error page is send to the user. If the above condition is true then, the following steps are performed. The CheckValidityCmd command is called to find the eCoupons that are not expired and for not expired eCoupons, CheckApplicabilityCmd command is called to find out which eCoupons are applicable for this order. For applicable coupons, CalculateDiscountAmtCmd command is called to calculate the discount amount and CouponDSSTaskCmd command is called to check for any conflict.

Specified by:
performExecute in interface ECCommand
Overrides:
performExecute in class AbstractECCommand
Throws:
ECException -  

removeExistingAdjustments

public void removeExistingAdjustments(java.lang.Long anOrderId)
                               throws ECSystemException
Removes the existing adjustments for this order.
Parameters:
anOrderId - java.lang.Long

removeOldEntries

public void removeOldEntries()
                      throws ECSystemException
It removes the old entries from the TORCPMAP and TCPITMAP tables.
Throws:
: - com.ibm.commerce.exception.ECException.

setCalculationUsage

public void setCalculationUsage(java.lang.Integer newCalculationUsage)
Sets the calculation usage.
Parameters:
newCalculationUsage - java.lang.Integer

setConflicts

public void setConflicts(java.util.Hashtable newConflicts)
Sets the conflicts.
Parameters:
newConflicts - java.util.Hashtable

setCouponIds

public void setCouponIds(java.lang.Long[] newCouponIds)
Sets the couponIds.
Specified by:
setCouponIds in interface UseCouponIdTaskCmd
Parameters:
newCouponIds - java.lang.Long[]

setCurrency

public void setCurrency(java.lang.String newCurrency)
It set the currency.
Parameters:
newCurrency - java.lang.String

setErrorCode

public void setErrorCode(java.lang.Integer newErrorCode)
Sets the errorcode.
Parameters:
newErrorCode - java.lang.Integer

setInvalidCoupons

public void setInvalidCoupons(java.util.Vector newInvalidCoupons)
Sets the invalidCoupons.
Parameters:
newInvalidCoupons - java.util.Vector

setNumCoupons

public void setNumCoupons(int newNumCoupons)
Sets teh number of coupons.
Parameters:
newNumCoupons - int

setOrderId

public void setOrderId(java.lang.Long newOrderId)
Set the order id.
Specified by:
setOrderId in interface UseCouponIdTaskCmd
Parameters:
newOrderId - java.lang.Long

setProcessingContext

public void setProcessingContext(CommandContext newProcessingContext)
Sets the processing context.
Parameters:
newProcessingContext - com.ibm.commerce.command.CommandContext

setRequestProperties

public void setRequestProperties(TypedProperty newRequestProperties)
Sets the processing context.
Specified by:
setRequestProperties in interface UseCouponIdTaskCmd
Parameters:
newRequestProperties - com.ibm.commerce.datatype.TypedProperty

setShopperId

public void setShopperId(java.lang.Long newShopperId)
Set the shopperId.
Specified by:
setShopperId in interface UseCouponIdTaskCmd
Parameters:
newShopperId - java.lang.Long

setValidSelection

public void setValidSelection(boolean newValidSelection)
Sets the validSelect field.
Parameters:
newValidSelection - boolean

validateParameters

public void validateParameters()
                        throws ECException
Extracts the couponIds to be used in the command from the request.
Specified by:
validateParameters in interface ECCommand
Overrides:
validateParameters in class AbstractECCommand
Throws:
ECException. -