atg.commerce.pricing
Class SpendAmountAggregator

java.lang.Object
  extended by atg.commerce.pricing.Aggregator
      extended by atg.commerce.pricing.SpendAmountAggregator

public class SpendAmountAggregator
extends Aggregator

An implementation of the Aggregator class. SpendAmountAggregator is a specific implementation, written to handle "Spend Y in X" promotion types. It provides a method of calculating an aggregated amount from (possibly) multiple DetailedItemPriceInfo objects for a specific item.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Constructor Summary
SpendAmountAggregator()
           
 
Method Summary
protected  AggregatorInfo calculate(java.lang.String pOperation, java.lang.Double pAggValueSoFar, java.lang.Long pQuantityMatched, java.lang.Double pTargetValue, CommerceItem pItem, java.util.Map pAttributes)
          This method will calculate (based on the given operation) an aggregated amount value for pItem based on it's collection of DetailedItemPriceInfo objects.
 java.lang.Number parseValue(java.lang.String pValue, java.lang.Class<?> pType)
          Parses a localized string value and returns a Number representation, suitable for use in the PMDL.
 
Methods inherited from class atg.commerce.pricing.Aggregator
getOperations, getOverrideProperty, isValidOperation, setOperations, setOverrideProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string

Constructor Detail

SpendAmountAggregator

public SpendAmountAggregator()
Method Detail

calculate

protected AggregatorInfo calculate(java.lang.String pOperation,
                                   java.lang.Double pAggValueSoFar,
                                   java.lang.Long pQuantityMatched,
                                   java.lang.Double pTargetValue,
                                   CommerceItem pItem,
                                   java.util.Map pAttributes)
                            throws PricingException
This method will calculate (based on the given operation) an aggregated amount value for pItem based on it's collection of DetailedItemPriceInfo objects. The only operation provided by this method is "total". The number of qualifying items is also tracked through the pQuantityMatched parameter. Tracking of this value will stop when the target value is met or exceeded. It should be noted that even although the processing of the quantity amount stops when the target value has been reached, the aggregated value is processed for all quantities of the current dipi. This processing handles calling logic from both the quantifiers (only interested in aggregated value) and iterators (only interested in quantity that matched the target value). It is therefore possible that the final aggregated value will not be in sync with the quantity matched when considered from the perspective of an iterator. This processing anomaly should be taken into consideration if both values are going to be used for further processing.

Parameters:
pOperation - the operation to invoke on the aggregator
pAggValueSoFar - the aggregated value so far, which may be potentially derived from many calculations from multiple items
pQuantityMatched - the number of items that have contributed to the aggregated value
pTargetValue - a value specified in the condition/offer of a promotion which can be used as a target in relation to the aggregated value. May or may not be relevant to an aggregator
pItem - the item that is currently being evaluated
pAttributes - extra parameters
Returns:
holds amended aggValueSoFar and quantityMatched values
Throws:
PricingException

parseValue

public java.lang.Number parseValue(java.lang.String pValue,
                                   java.lang.Class<?> pType)
                            throws java.lang.NumberFormatException
Parses a localized string value and returns a Number representation, suitable for use in the PMDL.

Parameters:
pValue - value to be parsed
pType - class type of pValue
Returns:
parsed value
Throws:
java.lang.NumberFormatException - if pValue could not be parsed