com.ibm.commerce.couponredemption.commands
Class ApplyCouponUsageCmdImpl

java.lang.Object
  |
  +--com.ibm.commerce.command.AbstractECCommand
        |
        +--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, TaskCommand

public class ApplyCouponUsageCmdImpl
extends CalculationCmdImpl
implements ApplyCouponUsageCmd

This task command is called from OrderPrepare command to incorpurate 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 input to this command is :

The eCoupons which are to be applied to an order are found out from ORCPMAP table. They are removed from ORCPMAP table and CPITMAP table. The eCoupons are checked for expiry by calling CheckValidityTaskCmd command. The eCoupons those are not expired for applicability are checked by calling CheckApplicabilityTaskCmd command. The applicable eCoupons are called by the CalculateDiscountAmountCmd task command and discount amount in the current order is incorporated.


Field Summary
protected  java.lang.Long orderId
           
protected  CommandContext processingContext
           
 
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.AbstractECCommand
commandContext
 
Fields inherited from interface com.ibm.commerce.couponredemption.commands.ApplyCouponUsageCmd
COPYRIGHT, defaultCommandClassName, NAME
 
Constructor Summary
ApplyCouponUsageCmdImpl()
          Conctructor 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 check applied items.
 java.util.Set getAppliedItems()
          Get the applied items.
protected  Item[] getItems()
          Gets the items.
 java.lang.Long getOrderId()
          It get the orderids.
 CommandContext getProcessingContext()
          Get the processing context.
protected  java.lang.Integer[] getTaxCategoryIds()
          Gets the tax categories.
 void insertIntoDB(java.lang.Long orderId, java.util.Hashtable couponHashtable)
          It insert data into database.
 void performExecute()
          This task command is called from OrderPrepare command to incorpurate the eCoupon discount onto the Adjustments in ORDERS and ORDERITEMS table.
 void removeOldEntries()
          It remove the old entries.
 void reset()
          This method is called after a command has been executed to reset its states variables.
 void setItems(Item[] aItems)
          Set the items.
 void setOrderId(java.lang.Long newOrderId)
          Set the order ids.
 void setProcessingContext(CommandContext newProcessingContext)
          It set the processing context.
 void setTaxCategoryIds(java.lang.Integer[] anTaxCategoryIds)
          It set the tax category..
 void validateParameters()
          It 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.AbstractECCommand
accessControlCheck, checkIsAllowed, checkResourcePermission, execute, finalize, getAccCheck, getCommandContext, getCommandIfName, getCommandName, getDefaultProperties, getResources, getStoreId, getUser, getUserId, isReadyToCallExecute, 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.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
 
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

orderId

protected java.lang.Long orderId

processingContext

protected CommandContext processingContext
Constructor Detail

ApplyCouponUsageCmdImpl

public ApplyCouponUsageCmdImpl()
Conctructor 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.

checkAppliedItems

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

getAppliedItems

public java.util.Set getAppliedItems()
Get the applied items.
Specified by:
getAppliedItems in interface ApplyCalculationUsageCmd
Returns:
Set

getItems

protected Item[] getItems()
Gets the items.

getOrderId

public java.lang.Long getOrderId()
It get the orderids.

Creation date: (7/15/2001 7:44:09 AM)

Returns:
java.lang.Long

getProcessingContext

public CommandContext getProcessingContext()
Get 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 insert data into database.
Parameters:
couponHashTable - java.util.Hashtable

performExecute

public void performExecute()
                    throws ECException

This task command is called from OrderPrepare command to incorpurate 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 ORCPMAP table. They are removed from ORCPMAP table and CPITMAP table. The eCoupons are checked for expiry by calling CheckValidityTaskCmd command. The eCoupons those are not expired for applicability are checked by calling CheckApplicabilityTaskCmd command. The applicable eCoupons are called by the CalculateDiscountAmountCmd task command and discount amount in the current order is incorporated.

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

removeOldEntries

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

reset

public void reset()
Description copied from class: AbstractECCommand
This method is called after a command has been executed to reset its states variables. After the call to reset, we should be able to execute the command again.
Overrides:
reset in class CalculationCmdImpl

setItems

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

setOrderId

public void setOrderId(java.lang.Long newOrderId)
Set the order ids.
Parameters:
newOrderId - java.lang.Long

setProcessingContext

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

setTaxCategoryIds

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

validateParameters

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