com.ibm.commerce.couponredemption.commands
Class CalculateDiscountAmtCmdImpl

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.CalculateDiscountAmtCmdImpl
All Implemented Interfaces:
BusinessPolicyCommand, CalculateDiscountAmtCmd, CalculationCmd, ECCommand, ECTargetableCommand, TaskCommand

public class CalculateDiscountAmtCmdImpl
extends CalculationCmdImpl
implements CalculateDiscountAmtCmd

The purpose of the task command is to computes the discount amount for each eCoupon that satisfy the purchase order conditions of the of the eCoupon.

First the orderItems for a order are found out and for each cpwalletId, corresponding promoId is found out from the CouponWalletAccessBean. The corresponding calcodeId are found out from PromoDiscAccessBean by using the obtained promoId. A mapping is computed between OrderItemAccessBean (corresponding to the items qualified for this cpwalletId) and the Categorized MonetaryAmount(Set to zero). The task command CalculationCodeCalculate command with usage type as eCoupons and the mapping created above are called and the discount amounts are stored in TempCouponItemMapAccessBean. These above steps are performed for each cpwalletId.

See Also:
Serialized Form

Field Summary
protected  java.util.Vector[] appItems
          The nth element of this array contains the IDs of applicable items for the nth coupon.
protected  java.lang.Long[] bcIds
          The IDs of the coupons to be applied to this order
protected  java.lang.Long orderId
          ID of the order
protected  CommandContext processingContext
          The command context holder
protected  TypedProperty reqProp
          The request properties
protected  java.util.Hashtable returnTable
          This tables stores the discount amounts computed by this command.
protected  TypedProperty rspProp
          The response properties
 
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. CalculateDiscountAmtCmd
COPYRIGHT, defaultCommandClassName, Name
 
Fields inherited from interface com.ibm.commerce.order.calculation. CalculationCmd
NAME
 
Fields inherited from interface com.ibm.commerce.command. ECCommand
defaultCommandClassName
 
Constructor Summary
CalculateDiscountAmtCmdImpl()
          CouponDSSCmdImpl constructor, call super.
 
Method Summary
 boolean checkParentCatEntryIds(java.lang.Long oiCatEntryId, java.lang.Long walletCatEntryId)
          Checks the parent catalog entry.
 java.util.Vector[] getAppItems()
          Gets the applicable items.
static java.lang.String getIClassName()
          Gets the class name.
 java.lang.Long getOrderId()
          Gets the orderId.
  CommandContext getProcessingContext()
          Gets the processing context.
  TypedProperty getReqProp()
          Gets request properties.
  TypedProperty getResponseProperties()
          Gets the response properties.
 java.util.Hashtable getReturnTable()
          Gets the return table.
  TypedProperty getRspProp()
          Gets the response properties.
 boolean isReadyToCallExecute()
          It always returns true.
 void performExecute()
          First the orderItems for a order are found out and for each cpwalletId, corresponding promoId is found out from the CouponWalletAccessBean.
 void setAppItems(java.util.Vector[] newAppItems)
          Sets the applied items.
 void setBcIds(java.lang.Long[] paramBcIds)
          Sets the eCouponIds.
 void setOrderId(java.lang.Long newOrderId)
          Sets the order IDs.
 void setProcessingContext( CommandContext newProcessingContext)
          Sets the processing context.
 void setReqProp( TypedProperty newReqProp)
          Sets the request properties.
 void setRequestProperties( TypedProperty paramReqProp)
          Sets the request properties.
 void setReturnTable(java.util.Hashtable newReturnTable)
          Sets the return table.
 void setRspProp( TypedProperty newRspProp)
          Sets the responce properties.
 
Methods inherited from class com.ibm.commerce.order.calculation. CalculationCmdImpl
createCommand, getCurrency, getCustomProperties, getCustomProperty, getTimestamp, getUsageId, reset, setCurrency, setCustomProperties, setCustomProperty, setTimestamp, setUsageId
 
Methods inherited from class com.ibm.commerce.command. BusinessPolicyCommandImpl
getPolicyId, getRequestProperties, setPolicyId
 
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, setAccCheck, setCommandContext, setCommandIfName, setCommandStoreId, setDefaultProperties, validateParameters
 
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. BusinessPolicyCommand
getPolicyId, getRequestProperties, setPolicyId
 

Field Detail

bcIds

protected java.lang.Long[] bcIds
The IDs of the coupons to be applied to this order

orderId

protected java.lang.Long orderId
ID of the order

processingContext

protected CommandContext processingContext
The command context holder

reqProp

protected TypedProperty reqProp
The request properties

rspProp

protected TypedProperty rspProp
The response properties

appItems

protected java.util.Vector[] appItems
The nth element of this array contains the IDs of applicable items for the nth coupon.

returnTable

protected java.util.Hashtable returnTable
This tables stores the discount amounts computed by this command. The key of this hashtable is the couponId and the value is another hashtable. This second hastable has the orderItemId as the key and the discount amount as the value.
Constructor Detail

CalculateDiscountAmtCmdImpl

public CalculateDiscountAmtCmdImpl()
CouponDSSCmdImpl constructor, call super.
Method Detail

checkParentCatEntryIds

public boolean checkParentCatEntryIds(java.lang.Long oiCatEntryId,
                                      java.lang.Long walletCatEntryId)
                               throws ECSystemException
Checks the parent catalog entry.
Parameters:
oiCatEntryId - The child catalog entry ID.
walletCatEntryId - The parent catalog entry ID.
Returns:
true if the oiCatEntryId is indeed the child of the walletCatEntryId.
Throws:
ECSystemException

getAppItems

public java.util.Vector[] getAppItems()
Gets the applicable items.
Returns:
the applicable items.

getIClassName

public static final java.lang.String getIClassName()
Gets the class name.
Returns:
name of the class.

getOrderId

public java.lang.Long getOrderId()
Gets the orderId.
Returns:
the order ID for which the discount is being calculated.

getProcessingContext

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

getReqProp

public TypedProperty getReqProp()
Gets request properties.
Returns:
the request properties

getResponseProperties

public TypedProperty getResponseProperties()
Gets the response properties.
Specified by:
getResponseProperties in interface CalculateDiscountAmtCmd
Returns:
the response properties

getReturnTable

public java.util.Hashtable getReturnTable()
Gets the return table.
Specified by:
getReturnTable in interface CalculateDiscountAmtCmd
Returns:
the hashtable containing the discount information.

getRspProp

public TypedProperty getRspProp()
Gets the response properties.
Specified by:
getRspProp in interface CalculateDiscountAmtCmd
Returns:
the response properties

isReadyToCallExecute

public boolean isReadyToCallExecute()
It always returns true.
Overrides:
isReadyToCallExecute in class AbstractECTargetableCommand
Returns:
boolean

performExecute

public void performExecute()
                    throws ECException

First the orderItems for a order are found out and for each cpwalletId, corresponding promoId is found out from the CouponWalletAccessBean. The corresponding calcodeId are found out from PromoDiscAccessBean by using the obtained promoId. A mapping is computed between OrderItemAccessBean (corresponding to the items qualified for this cpwalletId) and the Categorized MonetaryAmount(Set to zero). The task command CalculationCodeCalculate command with usage type as eCoupons and the mapping created above are called and the discount amounts are stored in TempCouponItemMapAccessBean. These above steps are performed for each cpwalletId.

Specified by:
performExecute in interface ECCommand
Overrides:
performExecute in class AbstractECTargetableCommand
ECException

setAppItems

public void setAppItems(java.util.Vector[] newAppItems)
Sets the applied items.
Specified by:
setAppItems in interface CalculateDiscountAmtCmd
Parameters:
newAppItems - the applicable items to be set.

setBcIds

public void setBcIds(java.lang.Long[] paramBcIds)
Sets the eCouponIds.
Specified by:
setBcIds in interface CalculateDiscountAmtCmd
Parameters:
paramBcIds - the couponIds to be used on this order.

setOrderId

public void setOrderId(java.lang.Long newOrderId)
Sets the order IDs.
Specified by:
setOrderId in interface CalculateDiscountAmtCmd
Parameters:
newOrderId - the orderId

setProcessingContext

public void setProcessingContext(CommandContext newProcessingContext)
Sets the processing context.
Specified by:
setProcessingContext in interface CalculateDiscountAmtCmd
Parameters:
newProcessingContext - the new command context to be used.

setReqProp

public void setReqProp(TypedProperty newReqProp)
Sets the request properties.
Specified by:
setReqProp in interface CalculateDiscountAmtCmd
Parameters:
newReqProp - the new request properties

setRequestProperties

public void setRequestProperties(TypedProperty paramReqProp)
Sets the request properties.
Specified by:
setRequestProperties in interface CalculateDiscountAmtCmd
Overrides:
setRequestProperties in class BusinessPolicyCommandImpl
Parameters:
paramReqProp - the new request properties

setReturnTable

public void setReturnTable(java.util.Hashtable newReturnTable)
Sets the return table.
Parameters:
newReturnTable - the hashtable containing discount information

setRspProp

public void setRspProp(TypedProperty newRspProp)
Sets the responce properties.
Parameters:
newRspProp - the new response properties