atg.projects.store.scenario
Class MerchandiseTotalCondition

java.lang.Object
  extended by atg.process.filter.Filter
      extended by atg.process.filter.ExpressionFilter
          extended by atg.projects.store.scenario.MerchandiseTotalCondition

public class MerchandiseTotalCondition
extends atg.process.filter.ExpressionFilter

This expression filter (Scenario Condition) allows us to write scenarios that say "Order contains [less than] [$24.00] merchandise where items [in category ] [x]. This is specifically to handle the case where a merchant wishes to give a free gift when a user purchases at least $24.50 of items from a specific category.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string.
static int EQUAL_TO
          Equal constant.
static int GREATER_THAN
          Greater than constant.
static int LESS_THAN
          Less than constant.
static java.lang.String MESSAGE_ORDER_PROPERTY
          The property of the message that points to the order.
 
Fields inherited from class atg.process.filter.Filter
FALSE, TRUE
 
Constructor Summary
MerchandiseTotalCondition()
           
 
Method Summary
 void configure(java.lang.String pOperator, java.lang.Object pConfiguration)
          Configures this ExpressionFilter using the given configuration object.
protected  atg.process.filter.Filter evaluate(atg.process.ProcessExecutionContext pContext)
          This filter takes the amount entered by the business user an the pmdl rule.
protected  boolean evaluatePMDLRule(atg.process.ProcessExecutionContext pContext, atg.commerce.order.Order pOrder, atg.commerce.order.CommerceItem pItem)
          Evaluate the rule put before us for the commerce item in question.
 void initialize(java.lang.String pOperator, atg.process.expression.Expression[] pOperands)
          Initializes this ExpressionFilter, given its operator and operands.
 
Methods inherited from class atg.process.filter.ExpressionFilter
equals, getOperands, getOperator, operandsEquals, setOperands, setOperator, toString
 
Methods inherited from class atg.process.filter.Filter
andFilters, andFilters, assumeFalse, assumeTrue, createProcessInstanceQuery, createSubjectQuery, getResourceBundle, getSubjectType, hashCode, implies, isCacheable, negate, orFilters, orFilters, setCacheable, test
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string.


LESS_THAN

public static final int LESS_THAN
Less than constant.

See Also:
Constant Field Values

EQUAL_TO

public static final int EQUAL_TO
Equal constant.

See Also:
Constant Field Values

GREATER_THAN

public static final int GREATER_THAN
Greater than constant.

See Also:
Constant Field Values

MESSAGE_ORDER_PROPERTY

public static final java.lang.String MESSAGE_ORDER_PROPERTY
The property of the message that points to the order.

See Also:
Constant Field Values
Constructor Detail

MerchandiseTotalCondition

public MerchandiseTotalCondition()
Method Detail

configure

public void configure(java.lang.String pOperator,
                      java.lang.Object pConfiguration)
               throws atg.process.ProcessException
Configures this ExpressionFilter using the given configuration object. The configuration object is typically a global Nucleus component which is configured with the information necessary for the filter's operation.

Overrides:
configure in class atg.process.filter.ExpressionFilter
Parameters:
pOperator - - operator
pConfiguration - - configuration
Throws:
atg.process.ProcessException - if the filter could not be configured - for example, because some of the required properties are missing from the configuration

initialize

public void initialize(java.lang.String pOperator,
                       atg.process.expression.Expression[] pOperands)
                throws atg.process.ProcessException
Initializes this ExpressionFilter, given its operator and operands. The default implementation of this method simply sets the operator and operands properties.

This implementation, in addition, verifies that there is exactly one operand, and that its value is a constant. The constant value of the operand is the PMDL string that defines this filter.

Overrides:
initialize in class atg.process.filter.ExpressionFilter
Parameters:
pOperator - - operator
pOperands - - operands
Throws:
atg.process.ProcessException - if the operands argument is invalid

evaluate

protected atg.process.filter.Filter evaluate(atg.process.ProcessExecutionContext pContext)
                                      throws atg.process.ProcessException

This filter takes the amount entered by the business user an the pmdl rule. It then finds all the commerce items in the order that match the given pmdl rule. Of those that match this filter totals up their ItemPriceInfo.amount fields and applies the logic supplied by the business user to determine if the total amount of all the items matches the price criteria.

Evaluates this filter in the given scenario execution context. The context may not yet contain all of the information necessary to evaluate the filter - specifically, it may be missing the particular scenario instance and/or profile that the scenario is being executed on. If that is the case, the filter is evaluated as much as possible, and the simplified filter is returned.

The possible return values of this method are as follows:

Specified by:
evaluate in class atg.process.filter.Filter
Parameters:
pContext - - process execution context
Returns:
The Filter object or null after evaluation of the context
Throws:
atg.process.ProcessException - if there is a problem evaluating the filter (other than information missing from the context)

evaluatePMDLRule

protected boolean evaluatePMDLRule(atg.process.ProcessExecutionContext pContext,
                                   atg.commerce.order.Order pOrder,
                                   atg.commerce.order.CommerceItem pItem)
                            throws atg.process.ProcessException
Evaluate the rule put before us for the commerce item in question.

Parameters:
pContext - - process execution context
pOrder - - order
pItem - - the commerce item to evaluate the rule for
Returns:
rule
Throws:
atg.process.ProcessException - if process error occurs