atg.commerce.pricing
Class AggregatorManager

java.lang.Object
  extended by atg.commerce.pricing.AggregatorManager

public class AggregatorManager
extends java.lang.Object

This class is responsible for keeping a track of the currently configured aggregators.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Constructor Summary
AggregatorManager()
           
 
Method Summary
 AggregatorInfo calculate(java.lang.String pAggregator, 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 call the correct aggregator based on the given pAggregator parameter.
 java.util.Set<java.lang.String> getAggregatorKeys()
          Returns a list of the aggregator keys.
 ServiceMap getAggregators()
          Get the aggregators.
 java.util.Set<java.lang.String> getOperations()
          Returns a list of the combined operations that are available from all of the aggregators.
 java.util.Set<java.lang.String> getOverriddenProperties()
          Returns a set of the properties that have been overridden by the aggregators.
 java.lang.String getPropertyAggregatorKey()
          Get the property aggregator key.
 java.lang.String getQuantityAggregatorKey()
          Get the quantity aggregator key.
 java.lang.String getTotalOperationName()
          Get the total operation name property.
 boolean isPropertyAggregator(java.lang.String pValue)
          Returns true if the given value indicates that it is related to a property aggregator.
 boolean isValidAggregator(java.lang.String pAggregator)
          Returns true if the aggregator has been registered, false otherwise.
 boolean isValidOperation(java.lang.String pOperation, java.lang.String pAggregator)
          Returns true if the given operation is valid for the given aggregator, false otherwise.
 java.lang.Number parseValue(java.lang.String pAggregator, java.lang.String pValue, java.lang.Class<?> pType)
          Parses a string value and returns a Number representation.
 void setAggregators(ServiceMap pAggregators)
          Setter for the aggregators property.
 void setTotalOperationName(java.lang.String pTotalOperationName)
          Set the total operation name.
protected  void setupAggregatorKeys()
          Sets the key names of the quantity and property aggregators based on the key defined in the aggregators map.
 
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

AggregatorManager

public AggregatorManager()
Method Detail

setAggregators

public void setAggregators(ServiceMap pAggregators)
Setter for the aggregators property.

Parameters:
pAggregators - map of aggregators

getAggregators

public ServiceMap getAggregators()
Get the aggregators.

Returns:
a map of aggregators

setTotalOperationName

public void setTotalOperationName(java.lang.String pTotalOperationName)
Set the total operation name.

Parameters:
pTotalOperationName - the total operation name

getTotalOperationName

public java.lang.String getTotalOperationName()
Get the total operation name property.

Returns:
the total operation name.

getQuantityAggregatorKey

public java.lang.String getQuantityAggregatorKey()
Get the quantity aggregator key.

Returns:
the default quantity aggregator key

getPropertyAggregatorKey

public java.lang.String getPropertyAggregatorKey()
Get the property aggregator key.

Returns:
the default property aggregator key

setupAggregatorKeys

protected void setupAggregatorKeys()
Sets the key names of the quantity and property aggregators based on the key defined in the aggregators map.


getOperations

public java.util.Set<java.lang.String> getOperations()
Returns a list of the combined operations that are available from all of the aggregators.

Returns:
a list of all available operations

getAggregatorKeys

public java.util.Set<java.lang.String> getAggregatorKeys()
Returns a list of the aggregator keys.

Returns:
a list of the aggregator keys

calculate

public AggregatorInfo calculate(java.lang.String pAggregator,
                                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 call the correct aggregator based on the given pAggregator parameter. Aggregator specific parameters can be passed in via the pAttributes map.

Parameters:
pAggregator - the name of the aggregator to
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 - if an error occurred whilst calculating

getOverriddenProperties

public java.util.Set<java.lang.String> getOverriddenProperties()
Returns a set of the properties that have been overridden by the aggregators.

Returns:
a set of all properties that have been overridden by aggregators

isValidOperation

public boolean isValidOperation(java.lang.String pOperation,
                                java.lang.String pAggregator)
Returns true if the given operation is valid for the given aggregator, false otherwise. Will also return false if the aggregator has not been registered. The total operation for the quantity aggregator is always valid, no matter if the aggregator has been registered or not.

Parameters:
pOperation - the name of the operation to validate
pAggregator - the name of the aggregator to validate
Returns:
true if the aggregator operation is valid, false otherwise

isValidAggregator

public boolean isValidAggregator(java.lang.String pAggregator)
Returns true if the aggregator has been registered, false otherwise. The quantity aggregator is always valid, no matter if it has been registered or not.

Parameters:
pAggregator - the name of the aggregator to validate
Returns:
true if the aggregator is valid, false otherwise

isPropertyAggregator

public boolean isPropertyAggregator(java.lang.String pValue)
Returns true if the given value indicates that it is related to a property aggregator.

Parameters:
pValue - value to check
Returns:
true if it can be determined that the given value relates to a property aggregator, false otherwise

parseValue

public java.lang.Number parseValue(java.lang.String pAggregator,
                                   java.lang.String pValue,
                                   java.lang.Class<?> pType)
                            throws java.lang.NumberFormatException
Parses a string value and returns a Number representation.

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