atg.projects.b2bstore.order
Class AverageOrderAction

java.lang.Object
  extended by atg.process.action.ActionImpl
      extended by atg.projects.b2bstore.order.AverageOrderAction
All Implemented Interfaces:
Action

public class AverageOrderAction
extends ActionImpl

This Action handles updating user profile with avg order amount whenever he places new order. It gets the value of Order's priceinfo from the Scenario and updates the profile by calculating average amt using it.


Field Summary
static java.lang.String AVG_ORDER_AMT
           
static java.lang.String CLASS_VERSION
           
static java.lang.String MY_RESOURCE_NAME
           
static java.lang.String NUM_OF_ORDERS
           
static java.lang.String PARAM_ORDER_PRICE
           
static java.lang.String USER_PROPERTY_NOT_FOUND
           
 
Constructor Summary
AverageOrderAction()
           
 
Method Summary
protected  double calculateAverage(java.lang.Double pOrgAvgTotal, java.lang.Double pOrderTotal, java.lang.Integer pNumOfOrders)
          Calculates the Average value of all order amounts of user.
protected  void executeAction(ProcessExecutionContext pContext)
          Executes this action in the given single process execution context.
 void initialize(java.util.Map pParameters)
          Initializes the action with the given parameters.
 
Methods inherited from class atg.process.action.ActionImpl
configure, 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

PARAM_ORDER_PRICE

public static final java.lang.String PARAM_ORDER_PRICE
See Also:
Constant Field Values

NUM_OF_ORDERS

public static final java.lang.String NUM_OF_ORDERS
See Also:
Constant Field Values

AVG_ORDER_AMT

public static final java.lang.String AVG_ORDER_AMT
See Also:
Constant Field Values

MY_RESOURCE_NAME

public static final java.lang.String MY_RESOURCE_NAME
See Also:
Constant Field Values

USER_PROPERTY_NOT_FOUND

public static final java.lang.String USER_PROPERTY_NOT_FOUND
See Also:
Constant Field Values
Constructor Detail

AverageOrderAction

public AverageOrderAction()
Method Detail

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

calculateAverage

protected double calculateAverage(java.lang.Double pOrgAvgTotal,
                                  java.lang.Double pOrderTotal,
                                  java.lang.Integer pNumOfOrders)
Calculates the Average value of all order amounts of user. Algorithm: numOfOrders give total no of orders for the given user including the current one. Get the existing avg amount from the profile, multiply it by (numOfOrders - 1) to get the total order amount excluding the current one. Then add it to the current order amt and divide it by total number of orders(numOfOrders).

Parameters:
pOrgAvgTotal - is the current average order total
pOrderTotal - is the order amt of the current order
numOfOrders - is the total no of orders placed by the user
Returns:
the average order amt including the current order amt.