com.ibm.commerce.couponredemption.commands
Class CouponDSSTaskCmdImpl

java.lang.Object
  |
  +--CacheableCommandImpl
        |
        +--com.ibm.commerce.command.AbstractECTargetableCommand
              |
              +--com.ibm.commerce.command.TaskCommandImpl
                    |
                    +--com.ibm.commerce.couponredemption.commands.CouponDSSTaskCmdImpl
All Implemented Interfaces:
CouponDSSTaskCmd, ECCommand, ECTargetableCommand, TaskCommand

public class CouponDSSTaskCmdImpl
extends TaskCommandImpl
implements CouponDSSTaskCmd

This task command is called from the CouponDSSCmd when user selects a set of eCoupons to be used on a set of items in her order.

First the eCoupons with selection status whether SELECTED or not is checked and it shouldn't have a common item in their itemlist where the itemlist is obtained from the parameter itemFor<cpwalletIds> if specified or from TempCouponItemMapAccessBean otherwise. This is done for all non order level coupons. Also only one order level eCoupon can be selected per order.
If the above conditions are satisfied, the selected eCoupons are moved from TempOrderCouponMapAccessBean to OrderCouponMapAccessBean and the unselected eCoupons are to deleted from TempOrderCouponMapAccessBean. Also the selected items are moved from TempCouponItemMapAccessBean to CouponItemMapAccessBean.

See Also:
Serialized Form

Field Summary
protected  java.util.Hashtable conflicts
          This hashtable stores the information about the conflict in the coupon selection.
protected  java.lang.Long[] couponId
          The couponIds to be processed.
protected  java.math.BigDecimal[] discAmt
          The nth element is the total discount amount due to the nth coupon.
protected  java.util.Vector[] itemList
          The nth element is the vector containing the items on which the nth coupon is being applied.
protected  int numCoupons
          The the number of coupons to be processed.
protected  java.lang.Long orderId
          The order on which the coupons are to be applied.
protected  CommandContext processingContext
          The command context holder
protected  TypedProperty reqProp
          The request properties.
protected  TypedProperty rspProp
          The response properties.
protected  boolean validSelection
          True if coupons selected can be used together.
 
Fields inherited from class com.ibm.commerce.command. AbstractECTargetableCommand
commandContext
 
Fields inherited from interface com.ibm.commerce.couponredemption.commands. CouponDSSTaskCmd
COPYRIGHT, defaultCommandClassName, Name
 
Fields inherited from interface com.ibm.commerce.command. ECTargetableCommand
COPYRIGHT
 
Fields inherited from interface com.ibm.commerce.command. ECCommand
defaultCommandClassName
 
Constructor Summary
CouponDSSTaskCmdImpl()
          CouponDSSCmdImpl constructor, call super.
 
Method Summary
 void computeItemAndDiscount()
          Finds the items and discount on those corresponding to each cpwalletId.
 java.util.Hashtable getConflicts()
          Returns the conflict hashtable.
 java.lang.Long[] getCouponId()
          Gets the coupon IDs.
 java.util.Hashtable getItemsSelected()
          Gets the items that were selected for the coupons to be applied on.
 int getNumCoupons()
          Gets the number of coupons.
 java.lang.Long getOrderId()
          Gets the order ID.
  TypedProperty getReqProp()
          Gets the request properties.
  TypedProperty getRspProp()
          Gets the response properties.
 java.util.Vector getUnQualifiedCoupons()
          Gets the IDs of the unqualified coupons.
 boolean isReadyToCallExecute()
          It always returns true.
 boolean isValidSelection()
          Returns whether the selection is valid or not.
 void performExecute()
          First the eCoupons with selection status whether SELECTED or not is checked and it shouldn't have a common item in their itemlist where the itemlist is obtained from the parameter itemFor<cpwalletIds> if specified or from TempCouponItemMapAccessBean otherwise.
protected  boolean qualifies(java.lang.Integer paramPromoId, java.util.Vector paramItemList, java.lang.String paramPurchaseCondType)
          This method tests whether the coupon of a given promotion can be applied on the given set of items for the purchase condition type.
 void setConflicts(java.util.Hashtable newConflicts)
          Sets the conflict variable.
 void setCouponId(java.lang.Long[] newCouponId)
          Sets the ecoupon IDs.
 void setItemsSelected(java.util.Hashtable newItemsSelected)
          Sets the items that were selected for the coupons to be applied on.
 void setNumCoupons(int newNumCoupons)
          Sets the number of coupons.
 void setOrderId(java.lang.Long newOrderId)
          Sets the order ID.
 void setValidSelection(boolean newValidSelection)
          Sets valid selection.
 void transferFromTemp()
          Transfer the entries from TempOrderCouponMapAccessBean and TempCouponItemMapAccessBean to the OrderCouponMapAcessBean and CouponItemMapAcessBean.
 void validateParameters()
          Checks the parameters.
 
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, reset, setAccCheck, setCommandContext, setCommandIfName, setCommandStoreId, setDefaultProperties
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

couponId

protected java.lang.Long[] couponId
The couponIds to be processed.

itemList

protected java.util.Vector[] itemList
The nth element is the vector containing the items on which the nth coupon is being applied.

numCoupons

protected int numCoupons
The the number of coupons to be processed.

orderId

protected java.lang.Long orderId
The order on which the coupons are to be applied.

discAmt

protected java.math.BigDecimal[] discAmt
The nth element is the total discount amount due to the nth coupon.

conflicts

protected java.util.Hashtable conflicts
This hashtable stores the information about the conflict in the coupon selection. The key is the first coupon and value is the vector of other coupons conflicting with this coupon.

processingContext

protected CommandContext processingContext
The command context holder

reqProp

protected TypedProperty reqProp
The request properties.

rspProp

protected TypedProperty rspProp
The response properties.

validSelection

protected boolean validSelection
True if coupons selected can be used together.
Constructor Detail

CouponDSSTaskCmdImpl

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

computeItemAndDiscount

public void computeItemAndDiscount()
                            throws ECSystemException
Finds the items and discount on those corresponding to each cpwalletId.
Throws:
ECSystemException

getConflicts

public java.util.Hashtable getConflicts()
Returns the conflict hashtable.
Specified by:
getConflicts in interface CouponDSSTaskCmd
Returns:
the hashtable of conflicts.

getCouponId

public java.lang.Long[] getCouponId()
Gets the coupon IDs.
Returns:
the array of couponIds.

getItemsSelected

public java.util.Hashtable getItemsSelected()
Gets the items that were selected for the coupons to be applied on. The key of the hashtable is the couponId and the value is array of strings representing the order item IDs.
Returns:
hashtable of items being used for coupons.

getNumCoupons

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

getOrderId

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

getReqProp

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

getRspProp

public TypedProperty getRspProp()
Gets the response properties.
Returns:
response properties.

getUnQualifiedCoupons

public java.util.Vector getUnQualifiedCoupons()
Gets the IDs of the unqualified coupons.
Specified by:
getUnQualifiedCoupons in interface CouponDSSTaskCmd
Returns:
a vector of coupon IDs that did not qualify for this order.

isReadyToCallExecute

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

isValidSelection

public boolean isValidSelection()
Returns whether the selection is valid or not.
Specified by:
isValidSelection in interface CouponDSSTaskCmd
Returns:
true if the selection was valid.

performExecute

public void performExecute()
                    throws ECException

First the eCoupons with selection status whether SELECTED or not is checked and it shouldn't have a common item in their itemlist where the itemlist is obtained from the parameter itemFor<cpwalletIds> if specified or from TempCouponItemMapAccessBean otherwise. This is done for all non order level coupons. Also only one order level eCoupon can be selected per order.
If the above conditions are satisfied, the selected eCoupons are moved from TempOrderCouponMapAccessBean to OrderCouponMapAccessBean and the unselected eCoupons are to deleted from TempOrderCouponMapAccessBean. Also the selected items are moved from TempCouponItemMapAccessBean to CouponItemMapAccessBean.

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

qualifies

protected boolean qualifies(java.lang.Integer paramPromoId,
                            java.util.Vector paramItemList,
                            java.lang.String paramPurchaseCondType)
                     throws ECSystemException
This method tests whether the coupon of a given promotion can be applied on the given set of items for the purchase condition type.
Parameters:
paramPromoId - The promotion ID of the coupon being attempted to be applied.
paramItemList - The items on which the coupon is being applied.
paramPurchaseCondType - the purchase condition type for this promotion.
Returns:
true if the coupon qualifies for this set of items.
Throws:
ECSystemException

setConflicts

public void setConflicts(java.util.Hashtable newConflicts)
Sets the conflict variable.
Parameters:
newConflicts - the hashtable containing conflict information.

setCouponId

public void setCouponId(java.lang.Long[] newCouponId)
Sets the ecoupon IDs.
Specified by:
setCouponId in interface CouponDSSTaskCmd
Parameters:
newCouponId - the coupon IDs.

setItemsSelected

public void setItemsSelected(java.util.Hashtable newItemsSelected)
Sets the items that were selected for the coupons to be applied on. The key of the hashtable is the couponId and the value is array of strings representing the order item IDs.
Specified by:
setItemsSelected in interface CouponDSSTaskCmd
Parameters:
newItemsSelected - hashtable of items being used for coupons.

setNumCoupons

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

setOrderId

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

setValidSelection

public void setValidSelection(boolean newValidSelection)
Sets valid selection.
Parameters:
newValidSelection - true if the selection is valid.

transferFromTemp

public void transferFromTemp()
                      throws ECSystemException

Transfer the entries from TempOrderCouponMapAccessBean and TempCouponItemMapAccessBean to the OrderCouponMapAcessBean and CouponItemMapAcessBean.

Throws:
: - com.ibm.commerce.exception.ECException.
ECSystemException

validateParameters

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