com.ibm.commerce.couponredemption.commands
Class CheckApplicabilityCmdImpl

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

public class CheckApplicabilityCmdImpl
extends TaskCommandImpl
implements CheckApplicabilityCmd

The purpose of this command is to check for applicability of the coupons on the shopping cart. The purchase condition are evaluated and the information is put in applicable variable which is used by the calling command.

First the order amount is calculated. Then the cppmnId is found out by using corresponding cpwalletId for that eCoupon. If the purchase order condition type for an eCoupon promotion is of product type, then the required products and their minumum quantities are found out from PromoProdAccessBean. If all the required products are present in the order with the required quantities, then the applicable eCoupons are found out.If the purchase order condition type for an eCoupon promotion is of type order, then the required amount for that order is found from PromoOrderAccessBean and the currency from CouponPromotionAccessBean. If the order amount satisfies the conditions, then the eCoupon is applicable. These above steps are performed for each cpwalletId.

See Also:
Serialized Form

Field Summary
protected  java.util.Vector[] applicableItems
          The nth element of this array is the Vector of order items that satisfy the purchase conditions of the nth coupon.
protected  java.lang.Long[] bcIds
          The IDs of the coupons to be applied to this order
protected  java.sql.Timestamp currentTimeStamp
          The current system time.
protected  TypedProperty inParam
          The request properties.
protected  java.lang.Long orderId
          ID of the order
protected  TypedProperty outParam
          The response properties.
protected  CommandContext processingContext
          The command context holder
protected  TypedProperty reqParam
          The request properties.
protected  boolean[] validCoupons
          The nth element denotes if the nth coupon is applicable.
 
Fields inherited from class com.ibm.commerce.command. AbstractECTargetableCommand
commandContext
 
Fields inherited from interface com.ibm.commerce.couponredemption.commands. CheckApplicabilityCmd
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
CheckApplicabilityCmdImpl()
          CheckValidityCmdImpl constructor calls super.
 
Method Summary
 java.math.BigDecimal calculateTotalOrderAmt(java.util.Vector vecoiAB, StoreAccessBean sAB, CurrencyManager cm, java.lang.String curCurrency)
          Calculates the total order amount.
 boolean checkParentCatEntryIds(java.lang.Long oiCatEntryId, java.lang.Long walletCatEntryId)
          Checks the parent catalog entry.
 java.util.Vector[] getApplicableItems()
          Gets applicable items.
 java.lang.Long[] getBcIds()
          Gets the eCoupon IDs.
 java.sql.Timestamp getCurrentTimeStamp()
          Gets current time from system.
 java.lang.Long getOrderId()
          Gets order ID.
  CommandContext getProcessingContext()
          Gets the processing context.
  TypedProperty getRequestProperties()
          Gets the request properties.
  TypedProperty getResponseProperties()
          Gets the response properties.
 boolean[] getValidCoupons()
          Gets the array indicating whether the Coupons are applicable or not.
 void performExecute()
          First the order amount is calculated.
 void setApplicableItems(java.util.Vector[] newApplicableItems)
          Sets the applicable items.
 void setBcIds(java.lang.Long[] newBcIds)
          Sets eCoupon IDs.
 void setCurrentTimeStamp(java.sql.Timestamp newCurrentTimeStamp)
          Sets the current time from system.
 void setOrderId(java.lang.Long newOrderId)
          Sets the order ID.
 void setProcessingContext( CommandContext newProcessingContext)
          Sets the processing context.
 void setRequestProperties( TypedProperty param)
          Sets the request properties.
 void setValidCoupons(boolean[] newValidCoupons)
          Sets the array indicating whether the Coupons are applicable or not.
 void validateParameters()
          It 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, isReadyToCallExecute, 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

outParam

protected TypedProperty outParam
The response properties.

reqParam

protected TypedProperty reqParam
The request properties.

bcIds

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

currentTimeStamp

protected java.sql.Timestamp currentTimeStamp
The current system time.

inParam

protected TypedProperty inParam
The request properties.

orderId

protected java.lang.Long orderId
ID of the order

processingContext

protected CommandContext processingContext
The command context holder

applicableItems

protected java.util.Vector[] applicableItems
The nth element of this array is the Vector of order items that satisfy the purchase conditions of the nth coupon.

validCoupons

protected boolean[] validCoupons
The nth element denotes if the nth coupon is applicable.
Constructor Detail

CheckApplicabilityCmdImpl

public CheckApplicabilityCmdImpl()
CheckValidityCmdImpl constructor calls super.
Method Detail

calculateTotalOrderAmt

public java.math.BigDecimal calculateTotalOrderAmt(java.util.Vector vecoiAB,
StoreAccessBean sAB,
CurrencyManager cm,
                                                   java.lang.String curCurrency)
                                            throws ECSystemException,
                                                   javax.naming.NamingException,
                                                   java.rmi.RemoteException,
                                                   javax.ejb.CreateException,
                                                   javax.ejb.FinderException
Calculates the total order amount.
Returns:
the order amount.
ECSystemException
javax.naming.NamingException
java.rmi.RemoteException
javax.ejb.CreateException
javax.ejb.FinderException

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.
ECSystemException

getApplicableItems

public java.util.Vector[] getApplicableItems()
Gets applicable items.
Specified by:
getApplicableItems in interface CheckApplicabilityCmd
Returns:
the applicable items.

getBcIds

public java.lang.Long[] getBcIds()
Gets the eCoupon IDs.
Returns:
the coupon IDs to be checked for applicability.

getCurrentTimeStamp

public java.sql.Timestamp getCurrentTimeStamp()
Gets current time from system.
Returns:
the current time stamp.

getOrderId

public java.lang.Long getOrderId()
Gets order ID.
Returns:
the order on which the coupons are being applied.

getProcessingContext

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

getRequestProperties

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

getResponseProperties

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

getValidCoupons

public boolean[] getValidCoupons()
Gets the array indicating whether the Coupons are applicable or not.
Specified by:
getValidCoupons in interface CheckApplicabilityCmd
Returns:
the nth element of the returned array is true if the nth coupon was applicable.

performExecute

public void performExecute()
                    throws ECException

First the order amount is calculated. Then the cppmnId is found out by using corresponding cpwalletId for that eCoupon. If the purchase order condition type for an eCoupon promotion is of product type, then the required products and their minumum quantities are found out from PromoProdAccessBean. If all the required products are present in the order with the required quantities, then the applicable eCoupons are found out. If the purchase order condition type for an eCoupon promotion is of type order, then the required amount for that order is found from PromoOrderAccessBean and the currency from CouponPromotionAccessBean. If the order amount satisfies the conditions, then the eCoupon is applicable. These above steps are performed for each cpwalletId.

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

setApplicableItems

public void setApplicableItems(java.util.Vector[] newApplicableItems)
Sets the applicable items.
Specified by:
setApplicableItems in interface CheckApplicabilityCmd
Parameters:
newApplicableItems - the applicable items.

setBcIds

public void setBcIds(java.lang.Long[] newBcIds)
Sets eCoupon IDs.
Specified by:
setBcIds in interface CheckApplicabilityCmd

setCurrentTimeStamp

public void setCurrentTimeStamp(java.sql.Timestamp newCurrentTimeStamp)
Sets the current time from system.
Parameters:
newCurrentTimeStamp - the current time

setOrderId

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

setProcessingContext

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

setRequestProperties

public void setRequestProperties(TypedProperty param)
Sets the request properties.
Specified by:
setRequestProperties in interface CheckApplicabilityCmd
Parameters:
param - the request properties.

setValidCoupons

public void setValidCoupons(boolean[] newValidCoupons)
Sets the array indicating whether the Coupons are applicable or not.
Parameters:
newValidCoupons - array whose nth element indicates if the nth coupon is applicable

validateParameters

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