com.ibm.commerce.order.commands
Class OrderCalculateCmdImpl

java.lang.Object
  |
  +--CacheableCommandImpl
        |
        +--com.ibm.commerce.command.AbstractECTargetableCommand
              |
              +--com.ibm.commerce.command.ControllerCommandImpl
                    |
                    +--com.ibm.commerce.order.commands.OrderCalculateCmdImpl
All Implemented Interfaces:
AccCommand, ControllerCommand, ECCommand, ECTargetableCommand, OrderCalculateCmd

public class OrderCalculateCmdImpl
extends ControllerCommandImpl
implements OrderCalculateCmd

Default implementation of the OrderCalculate controller command interface. This command calls the following TaskCommands:

This command uses the following AccessBeans:
See Also:
Serialized Form

Field Summary
static java.lang.String COPYRIGHT
          The IBM copyright string.
 
Fields inherited from class com.ibm.commerce.command. ControllerCommandImpl
requestProperties, responseProperties, retriable, viewReqProperties
 
Fields inherited from class com.ibm.commerce.command. AbstractECTargetableCommand
commandContext
 
Fields inherited from interface com.ibm.commerce.order.commands. OrderCalculateCmd
defaultCommandClassName, NAME
 
Constructor Summary
OrderCalculateCmdImpl()
          Constructor for OrderCalculateCmdImpl.
 
Method Summary
protected  void addCatalogEntriesToOrder( OrderAccessBean aabOrder, java.util.Map amapCatalogEntryQuantitiesToAdd)
          Adds the specified Map of CatalogEntries and their quantities to the specified Order.
protected  DiscountContext createDiscountContext( OrderAccessBean aabOrder)
          Creates the DiscountContext.
protected  java.util.Map getCatalogEntryQuantitiesToAdd( OrderAccessBean aabOrder, java.util.HashMap ahshCustomProperties)
          Returns the CatalogEntries to add to the Order, and their quantities.
protected  java.util.Map getFreebies( Discount[] aDiscounts)
          Returns the freebies in the specified Discounts.
protected   OrderItemAccessBean[] getOrderItems( OrderAccessBean aabOrder)
          Returns the OrderItems of the specified Order.
protected  OrderAccessBean[] getOrders()
          Returns the Orders specified to be processed by this command.
 java.lang.Long[] getOutOfInventoryCatalogEntryIds()
          Returns the identifiers of CatalogEntries that do not have sufficient inventory, when ATP inventory is not enabled.
protected  java.util.Set getOutOfInventoryCatalogEntryIds(java.util.Map amapCatalogEntryQuantitiesToAdd)
          Returns the CatalogEntries in the specified Map of CatalogEntries/quantities that are out of inventory.
  AccessVector getResources()
          Returns an AccessVector containing the OrderAccessBeans to be processed.
protected  java.lang.Integer[] getUsageIds()
          Returns the CalculationUsages specified to be recalculated by this command.
protected  void invokeRuleService( DiscountContext aDiscountContext)
          Invokes the rule service "Discount Service".
 void performExecute()
          Executes the main business logic of the command.
protected  void removeExcessFreebies(java.util.Map amapFreebies, OrderAccessBean aabOrder)
          Removes excess freebies from the specified Map of freebies.
 void reset()
          Resets instance variables to their initial values.
 void setOrders( OrderAccessBean[] aabOrders)
          Sets the Orders.
protected  void setOutOfInventoryCatalogEntryIds(java.lang.Long[] anOutOfInventoryCatalogEntryIds)
          Sets the CatalogEntries that are out of inventory.
 void setRequestProperties( TypedProperty aRequestProperties)
          Sets the request properties.
protected  void setResponseProperties()
          Sets the response properties: For each name that was specified by the outOrderName request property, add a response property with that name.
 void setUsageIds(java.lang.Integer[] anUsageIds)
          Sets the CalculationUsages.
protected  void updateOrderItemProductTotal( OrderItemAccessBean aabOrderItem, java.lang.String astrCurrency)
          Updates the productTotal of the specified OrderItem.
protected  void updateOrderProductTotal( OrderAccessBean aabOrder, OrderItemAccessBean[] aabOrderItems)
          Updates the productTotal of the specified Order and OrderItems.
 void validateParameters()
          Does nothing.
 
Methods inherited from class com.ibm.commerce.command. ControllerCommandImpl
checkPermission, fulfills, getForUserId, getGeneric, getOwner, getRequestProperties, getResolvedRequestProperties, getResourceOwners, getResponseProperties, getRetriable, getViewInputProperties, isGeneric, isRetriable, mergeProperties, setForUserId, setGeneric, setOwner, setResponseProperties, setRetriable, setViewInputProperties
 
Methods inherited from class com.ibm.commerce.command. AbstractECTargetableCommand
accessControlCheck, checkIsAllowed, checkParameters, checkResourcePermission, createCommandExecutionEvent, execute, finalize, getAccCheck, getCommandContext, getCommandIfName, getCommandName, getCommandStoreId, getDefaultProperties, 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.command. ControllerCommand
checkPermission, execute, getGeneric, getRequestProperties, getResolvedRequestProperties, getResponseProperties, getRetriable, getViewInputProperties, isGeneric, isRetriable, mergeProperties, setGeneric, setRetriable, setViewInputProperties
 
Methods inherited from interface com.ibm.commerce.command. AccCommand
accessControlCheck, getAccCheck, getForUserId, getResourceOwners, setAccCheck, setForUserId, setOwner
 
Methods inherited from interface com.ibm.commerce.command. ECCommand
checkIsAllowed, checkResourcePermission, createCommandExecutionEvent, getCommandContext, getCommandIfName, getCommandName, getCommandStoreId, getDefaultProperties, getStoreId, getUser, getUserId, setCommandContext, setCommandIfName, setCommandStoreId, setDefaultProperties
 

Field Detail
public static final java.lang.String COPYRIGHT
The IBM copyright string.
See Also:
Constant Field Values
Constructor Detail

OrderCalculateCmdImpl

public OrderCalculateCmdImpl()
Constructor for OrderCalculateCmdImpl.
Method Detail

setOrders

public void setOrders(OrderAccessBean[] aabOrders)
Description copied from interface: OrderCalculateCmd
Sets the Orders.
Specified by:
setOrders in interface OrderCalculateCmd
Parameters:
aabOrders - the Orders.
See Also:
OrderCalculateCmd.setOrders(OrderAccessBean[])

setUsageIds

public void setUsageIds(java.lang.Integer[] anUsageIds)
Description copied from interface: OrderCalculateCmd
Sets the CalculationUsages.
Specified by:
setUsageIds in interface OrderCalculateCmd
Parameters:
anUsageIds - the CalculationUsage identifiers.
See Also:
OrderCalculateCmd.setUsageIds(Integer[])

setOutOfInventoryCatalogEntryIds

protected void setOutOfInventoryCatalogEntryIds(java.lang.Long[] anOutOfInventoryCatalogEntryIds)
Sets the CatalogEntries that are out of inventory.
Parameters:
anOutOfInventoryCatalogEntryIds - the CatalogEntry identifiers.

getOrders

protected OrderAccessBean[] getOrders()
Returns the Orders specified to be processed by this command.
Returns:
the Orders.

getUsageIds

protected java.lang.Integer[] getUsageIds()
Returns the CalculationUsages specified to be recalculated by this command.
Returns:
the CalculationUsage identifiers.

getOutOfInventoryCatalogEntryIds

public java.lang.Long[] getOutOfInventoryCatalogEntryIds()
Description copied from interface: OrderCalculateCmd
Returns the identifiers of CatalogEntries that do not have sufficient inventory, when ATP inventory is not enabled.
Specified by:
getOutOfInventoryCatalogEntryIds in interface OrderCalculateCmd
Returns:
the CatalogEntry identifiers of catalog items that could not be added to the Order due to insufficient inventory.
.
See Also:
OrderCalculateCmd.getOutOfInventoryCatalogEntryIds()

setRequestProperties

public void setRequestProperties(TypedProperty aRequestProperties)
                          throws ECException
Description copied from interface: ControllerCommand
Sets the request properties. The WebController calls this method before invoking the execute method in this command to set the request properties for this command. It is the responsibility of the implementer of the ControllerCommand to extract the required input parameters from the request properties and perform parameter checking.
Specified by:
setRequestProperties in interface ControllerCommand
Overrides:
setRequestProperties in class ControllerCommandImpl
Parameters:
aRequestProperties - the request properties. The following request properties are recognized:
Throws:
ECApplicationException - The _ERR_BAD_MISSING_CMD_PARAMETER message is passed, with the name of the invalid or missing property name.
ECException -
See Also:
ControllerCommand.setRequestProperties(TypedProperty)

getResources

public AccessVector getResources()
                          throws ECException
Returns an AccessVector containing the OrderAccessBeans to be processed.
Specified by:
getResources in interface ECCommand
Overrides:
getResources in class AbstractECTargetableCommand
Returns:
the AccessVector.
Throws:
ECException
See Also:
ECCommand.getResources()

getOrderItems

protected OrderItemAccessBean[] getOrderItems(OrderAccessBean aabOrder)
                                       throws ECException
Returns the OrderItems of the specified Order.
Parameters:
aabOrder - the Order.
Returns:
the OrderItems.
Throws:
ECException

createDiscountContext

protected DiscountContext createDiscountContext(OrderAccessBean aabOrder)
                                         throws ECException
Creates the DiscountContext.
Parameters:
aabOrder - the Order.
Returns:
the DiscountContext.
Throws:
ECException

invokeRuleService

protected void invokeRuleService(DiscountContext aDiscountContext)
                          throws ECException
Invokes the rule service "Discount Service".
Parameters:
aDiscountContext - the DiscountContext.
Throws:
ECException

getFreebies

protected java.util.Map getFreebies(Discount[] aDiscounts)
Returns the freebies in the specified Discounts.
Parameters:
aDiscounts - the Discounts.
Returns:
the freebies.
  • Key: CatalogEntry identifier (Long).
  • Value: quantity (Double).

removeExcessFreebies

protected void removeExcessFreebies(java.util.Map amapFreebies,
OrderAccessBean aabOrder)
                             throws ECException
Removes excess freebies from the specified Map of freebies.
Parameters:
amapFreebies - the freebies.
  • Key: CatalogEntry identifier (Long).
  • Value: quantity (Double).
aabOrder - the Order.
Throws:
ECException

getCatalogEntryQuantitiesToAdd

protected java.util.Map getCatalogEntryQuantitiesToAdd(OrderAccessBean aabOrder,
                                                       java.util.HashMap ahshCustomProperties)
                                                throws ECException
Returns the CatalogEntries to add to the Order, and their quantities.
Parameters:
aabOrder - the Order.
ahshCustomProperties - the custom properties.
Returns:
the CatalogEntries and their quantities.
  • Key: CatalogEntry identifier (Long).
  • Value: quantity (Double).
Throws:
ECException

getOutOfInventoryCatalogEntryIds

protected java.util.Set getOutOfInventoryCatalogEntryIds(java.util.Map amapCatalogEntryQuantitiesToAdd)
                                                  throws ECException
Returns the CatalogEntries in the specified Map of CatalogEntries/quantities that are out of inventory.
Parameters:
amapCatalogEntryQuantitiesToAdd - the CatalogEntries and their quantities (Map).
  • Key: CatalogEntry identifier (Long).
  • Value: quantity (Double).
Returns:
the CatalogEntry identifiers (Set of Long).
Throws:
ECException

addCatalogEntriesToOrder

protected void addCatalogEntriesToOrder(OrderAccessBean aabOrder,
                                        java.util.Map amapCatalogEntryQuantitiesToAdd)
                                 throws ECException
Adds the specified Map of CatalogEntries and their quantities to the specified Order.
Parameters:
aabOrder - the Order.
amapCatalogEntryQuantitiesToAdd - the CatalogEntries and their quantities.
  • Key: CatalogEntry identifier (Long).
  • Value: quantity (Double).
Throws:
ECException

updateOrderItemProductTotal

protected void updateOrderItemProductTotal(OrderItemAccessBean aabOrderItem,
                                           java.lang.String astrCurrency)
                                    throws ECException
Updates the productTotal of the specified OrderItem.
Parameters:
aabOrderItem - the OrderItem.
astrCurrency - the Order currency.
Throws:
ECException

updateOrderProductTotal

protected void updateOrderProductTotal(OrderAccessBean aabOrder,
OrderItemAccessBean[] aabOrderItems)
                                throws ECException
Updates the productTotal of the specified Order and OrderItems.
Parameters:
aabOrder - the Order.
aabOrderItems - the OrderItems.
Throws:
ECException

validateParameters

public void validateParameters()
                        throws ECException
Does nothing.
Specified by:
validateParameters in interface ECCommand
Overrides:
validateParameters in class AbstractECTargetableCommand
Throws:
ECException
See Also:
ECCommand.validateParameters()

performExecute

public void performExecute()
                    throws ECException
Executes the main business logic of the command. Behaviour: For each Order specified: Finally, call the setResponseProperties() method.
Specified by:
performExecute in interface ECCommand
Overrides:
performExecute in class AbstractECTargetableCommand
Throws:
ECException
See Also:
ECCommand.performExecute()

setResponseProperties

protected void setResponseProperties()
                              throws ECException
Sets the response properties:
  • For each name that was specified by the outOrderName request property, add a response property with that name. The values of the added response property are the identifiers of the Orders processed by this command.
  • If ATP inventory is not enabled, and add a response property named outOfInventoryCatalogEntryId. Its values are the identifiers of the CatalogEntries that could not be added to the Order due to insufficient inventory.
  • The viewTaskName property is added. It's value is set to "RedirectView".
Throws:
ECException

reset

public void reset()
Resets instance variables to their initial values.
Overrides:
reset in class AbstractECTargetableCommand