com.ibm.commerce.couponredemption.commands
Class ApplyCouponUsageCmdImpl

java.lang.Object
  |
  +--CacheableCommandImpl
        |
        +--com.ibm.commerce.command.AbstractECTargetableCommand
              |
              +--com.ibm.commerce.command.TaskCommandImpl
                    |
                    +--com.ibm.commerce.command.BusinessPolicyCommandImpl
                          |
                          +--com.ibm.commerce.order.calculation.CalculationCmdImpl
                                |
                                +--com.ibm.commerce.couponredemption.commands.ApplyCouponUsageCmdImpl
All Implemented Interfaces:
ApplyCalculationUsageCmd, ApplyCouponUsageCmd, BusinessPolicyCommand, CalculationCmd, ECCommand, ECTargetableCommand, TaskCommand

public class ApplyCouponUsageCmdImpl
extends CalculationCmdImpl
implements ApplyCouponUsageCmd

This task command is called from OrderPrepare command to incorporate the eCoupon discount onto the Adjustments in ORDERS and ORDERITEMS table. The command is invoked when user asks to redeem the eCoupons before preparing order.

The eCoupons which are to be applied to an order are found out from OrderCouponMapAccessBean. They are removed from OrderCouponMapAccessBean and CouponItemMapAccessBean. The eCoupons are checked for expiry by calling CheckValidityTaskCmd command. The eCoupons that are not expired are checked for applicability by calling CheckApplicabilityTaskCmd command. The CalculateDiscountAmountCmd task command is called on the applicable coupons to find the discount amount to be incorporated in the currect order.

See Also:
Serialized Form

Field Summary
protected  java.lang.Long orderId
          The ID of the order which is being prepared.
protected  CommandContext processingContext
          The command context is kept in this.
 
Fields inherited from class com.ibm.commerce.order.calculation. CalculationCmdImpl
COPYRIGHT
 
Fields inherited from class com.ibm.commerce.command. BusinessPolicyCommandImpl
policyId, requestProperties
 
Fields inherited from class com.ibm.commerce.command. AbstractECTargetableCommand
commandContext
 
Fields inherited from interface com.ibm.commerce.couponredemption.commands. ApplyCouponUsageCmd
COPYRIGHT, defaultCommandClassName, NAME
 
Fields inherited from interface com.ibm.commerce.command. ECCommand
defaultCommandClassName
 
Constructor Summary
ApplyCouponUsageCmdImpl()
          Constructor for ApplyCouponUsageCmdImpl call super.
 
Method Summary
protected  void callCodeApply( Group aGroup)
          This method is called by performExecute() to invoke the CalculationCodeApply calculation method.
 void checkAppliedItems()
          It checks applied items.
 java.util.Set getAppliedItems()
          Gets the applied items.
protected  Item[] getItems()
          Gets the items.
 java.lang.Long getOrderId()
          Gets the orderId.
  CommandContext getProcessingContext()
          Gets the processing context.
protected  java.lang.Integer[] getTaxCategoryIds()
          Gets the tax categories.
 void insertIntoDB(java.lang.Long orderId, java.util.Hashtable couponHashtable)
          It inserts data into database.
 void performExecute()
          The eCoupons which are to be applied to an order are found out from OrderCouponMapAccessBean.
 void removeOldEntries()
          It removes the old entries.
 void reset()
          Sets the various variables to their default values (null).
 void setItems( Item[] aItems)
          Sets the items.
 void setOrderId(java.lang.Long newOrderId)
          Sets the order IDs.
 void setProcessingContext( CommandContext newProcessingContext)
          Sets the processing context.
 void setTaxCategoryIds(java.lang.Integer[] anTaxCategoryIds)
          Sets the tax category..
 void validateParameters()
          Checks the parameters.
 
Methods inherited from class com.ibm.commerce.order.calculation. CalculationCmdImpl
createCommand, getCurrency, getCustomProperties, getCustomProperty, getTimestamp, getUsageId, setCurrency, setCustomProperties, setCustomProperty, setTimestamp, setUsageId
 
Methods inherited from class com.ibm.commerce.command. BusinessPolicyCommandImpl
getPolicyId, getRequestProperties, setPolicyId, setRequestProperties
 
Methods inherited from class com.ibm.commerce.command. AbstractECTargetableCommand
accessControlCheck, checkIsAllowed, checkParameters, checkResourcePermission, createCommandExecutionEvent, execute, finalize, getAccCheck, getCommandContext, getCommandIfName, getCommandName, getCommandStoreId, getDefaultProperties, getResources, getStoreId, getUser, getUserId, isReadyToCallExecute, setAccCheck, setCommandContext, setCommandIfName, setCommandStoreId, 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.order.calculation. CalculationCmd
getCurrency, getCustomProperties, getCustomProperty, getTimestamp, getUsageId, setCurrency, setCustomProperties, setCustomProperty, setTimestamp, setUsageId
 
Methods inherited from interface com.ibm.commerce.command. BusinessPolicyCommand
getPolicyId, getRequestProperties, setPolicyId, setRequestProperties
 

Field Detail

processingContext

protected CommandContext processingContext
The command context is kept in this.

orderId

protected java.lang.Long orderId
The ID of the order which is being prepared.
Constructor Detail

ApplyCouponUsageCmdImpl

public ApplyCouponUsageCmdImpl()
Constructor for ApplyCouponUsageCmdImpl call super.
Method Detail

callCodeApply

protected void callCodeApply(Group aGroup)
                      throws ECException
This method is called by performExecute() to invoke the CalculationCodeApply calculation method.
Throws:
: - com.ibm.commerce.exception.ECException.
ECException

checkAppliedItems

public void checkAppliedItems()
                       throws ECException
It checks applied items.
Specified by:
checkAppliedItems in interface ApplyCalculationUsageCmd
Throws:
: - com.ibm.commerce.exception.ECException.
ECException

getAppliedItems

public java.util.Set getAppliedItems()
Gets the applied items.
Specified by:
getAppliedItems in interface ApplyCalculationUsageCmd
Returns:
The set of applied items.

getItems

protected Item[] getItems()
Gets the items.

getOrderId

public java.lang.Long getOrderId()
Gets the orderId.
Returns:
java.lang.Long

getProcessingContext

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

getTaxCategoryIds

protected java.lang.Integer[] getTaxCategoryIds()
Gets the tax categories.
Returns:
Integer

insertIntoDB

public void insertIntoDB(java.lang.Long orderId,
                         java.util.Hashtable couponHashtable)
                  throws ECSystemException
It inserts data into database.
ECSystemException

performExecute

public void performExecute()
                    throws ECException

The eCoupons which are to be applied to an order are found out from OrderCouponMapAccessBean. They are removed from OrderCouponMapAccessBean and CouponItemMapAccessBean. The eCoupons are checked for expiry by calling CheckValidityTaskCmd command. The eCoupons that are not expired are checked for applicability by calling CheckApplicabilityTaskCmd command. The CalculateDiscountAmountCmd task command is called on the applicable coupons to find the discount amount to be incorporated in the currect order.

Specified by:
performExecute in interface ECCommand
Overrides:
performExecute in class AbstractECTargetableCommand
Throws:
: - com.ibm.commerce.exception.ECException.
ECException

removeOldEntries

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

reset

public void reset()
Sets the various variables to their default values (null).
Overrides:
reset in class CalculationCmdImpl
See Also:
com.ibm.websphere.command.Command#reset()

setItems

public void setItems(Item[] aItems)
Sets the items.
Specified by:
setItems in interface ApplyCalculationUsageCmd
Parameters:
aItems - the items.

setOrderId

public void setOrderId(java.lang.Long newOrderId)
Sets the order IDs.
Parameters:
newOrderId - java.lang.Long

setProcessingContext

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

setTaxCategoryIds

public void setTaxCategoryIds(java.lang.Integer[] anTaxCategoryIds)
Sets the tax category..
Specified by:
setTaxCategoryIds in interface ApplyCalculationUsageCmd
Parameters:
anTaxCategoryIds - an Integer.

validateParameters

public void validateParameters()
                        throws ECException
Checks the parameters.
Specified by:
validateParameters in interface ECCommand
Overrides:
validateParameters in class AbstractECTargetableCommand
Throws:
: - com.ibm.commerce.exception.ECException.
ECException