atg.commerce.promotion
Class AddItemToOrder

java.lang.Object
  extended by atg.process.action.ActionImpl
      extended by atg.commerce.promotion.AddItemToOrder
All Implemented Interfaces:
Action

public class AddItemToOrder
extends ActionImpl

This action takes is responsible for creating a CommerceItem object from the passed product, sku, and quantity parameters and adding it to the first order that is in a state of INCOMPLETE.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
protected  ComponentName mOrderHolderComponent
          order holder component name
protected  OrderManager mOrderManager
          reference to the order manager object
protected  ComponentName mPromotionToolsComponent
          promotion tools component name
static java.lang.String PRODUCT_PARAM
          Parameter for product id information
 java.lang.String PROMOTION_TOOLS_PATH
          Location of the PromotionTools component.
static java.lang.String QUANTITY_PARAM
          Parameter for quantity information
 java.lang.String SHOPPINGCART_PATH
          Location of the OrderHolder component, called the shopping cart.
static java.lang.String SKU_PARAM
          Parameter for sku id information
 
Constructor Summary
AddItemToOrder()
           
 
Method Summary
protected  void addItem(java.lang.String pSkuId, java.lang.String pProductId, long pQuantity, ProcessExecutionContext pContext)
          This method will actually perform the action of adding an item to an order.
 void configure(java.lang.Object pConfiguration)
          Configures the action using the given configuration object.
protected  void executeAction(ProcessExecutionContext pContext)
          Executes this action in the given single process execution context.
 Order getOrderToAddItemTo(ProcessExecutionContext pContext)
          This method returns the order to which the CommerceItem should be added.
 void initialize(java.util.Map pParameters)
          Initializes the action with the given parameters.
 
Methods inherited from class atg.process.action.ActionImpl
execute, execute, getActionName, getParameterExpression, getParameterValue, storeOptionalParameter, storeRequiredMutableParameter, storeRequiredParameter, toString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string


SHOPPINGCART_PATH

public java.lang.String SHOPPINGCART_PATH
Location of the OrderHolder component, called the shopping cart. By default this is: /atg/commerce/ShoppingCart


PROMOTION_TOOLS_PATH

public java.lang.String PROMOTION_TOOLS_PATH
Location of the PromotionTools component. This is used to notify scenarios of added items. By default this is /atg/commerce/promotion/PromotionTools


PRODUCT_PARAM

public static final java.lang.String PRODUCT_PARAM
Parameter for product id information

See Also:
Constant Field Values

SKU_PARAM

public static final java.lang.String SKU_PARAM
Parameter for sku id information

See Also:
Constant Field Values

QUANTITY_PARAM

public static final java.lang.String QUANTITY_PARAM
Parameter for quantity information

See Also:
Constant Field Values

mOrderManager

protected OrderManager mOrderManager
reference to the order manager object


mOrderHolderComponent

protected ComponentName mOrderHolderComponent
order holder component name


mPromotionToolsComponent

protected ComponentName mPromotionToolsComponent
promotion tools component name

Constructor Detail

AddItemToOrder

public AddItemToOrder()
Method Detail

configure

public void configure(java.lang.Object pConfiguration)
               throws ProcessException
Configures the action using the given configuration object. The configuration object is typically a global Nucleus component which is configured with the information necessary for the action's operation.

Specified by:
configure in interface Action
Overrides:
configure in class ActionImpl
Throws:
ProcessException - if the action could not be configured - for example, because some of the required properties are missing from the configuration

initialize

public void initialize(java.util.Map pParameters)
                throws ProcessException
Description copied from class: ActionImpl
Initializes the action with the given parameters. The keys in the parameter Map are the String parameter names; the values are the Expression objects representing parameter values.

This default implementation does nothing.

Specified by:
initialize in interface Action
Overrides:
initialize in class ActionImpl
Throws:
ProcessException - if the action could not be properly initialized - for example, if not all of the required parameters are present in the Map
See Also:
Expression

executeAction

protected void executeAction(ProcessExecutionContext pContext)
                      throws ProcessException
Description copied from class: ActionImpl
Executes this action in the given single process execution context. Called by both of the execute methods.

Specified by:
executeAction in class ActionImpl
Throws:
ProcessException - if the action can not be executed

getOrderToAddItemTo

public Order getOrderToAddItemTo(ProcessExecutionContext pContext)
                          throws CommerceException,
                                 RepositoryException
This method returns the order to which the CommerceItem should be added. If a session exists the order holder component is resolved and the current order is used. Otherwise the order manager is called and the first order in the incomplete state is used.

Parameters:
pContext - - the process execution context at the time of this event
Throws:
CommerceException
RepositoryException

addItem

protected void addItem(java.lang.String pSkuId,
                       java.lang.String pProductId,
                       long pQuantity,
                       ProcessExecutionContext pContext)
                throws CommerceException,
                       RepositoryException
This method will actually perform the action of adding an item to an order. Additionally, if there is at least one shipping group defined in the order, then a relationship will be created between the first shipping group in the order and the commerce item. If no shipping groups exist in the order than the item will simply be added to the order without a relationship being created. The OrderManager.update call is made to save the information back to the order object. This method calls #see getOrderToAddItemTo to determine which order to use. It also calls the ordermanager to add the item to the order. In addition, PromotionTools.scenarioAddedItemToOrder will be called to send a scenario event announcing this action. If different behavior is desired when an item is being added to the order, this method should be overriden.

Parameters:
pSkuId - the sku id of the commerce item that will be created and added to the order
pProductId - product id of the commerce item that will be created and added
pQuantity - the quantity of the particular item to add
pContext - the context in which the action is occuring
Throws:
CommerceException - if an error occurs
RepositoryException - if an error occurs