atg.commerce.pricing
Class ItemPricingEngineImpl

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.commerce.pricing.PricingEngineService
              extended by atg.commerce.pricing.ItemPricingEngineImpl
All Implemented Interfaces:
ItemPricingEngine, PricingEngine, atg.naming.AbsoluteNameable, NameContextBindingListener, NameContextElement, atg.naming.NameContextParentable, NameResolver, AdminableService, atg.nucleus.Configured, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, Schedulable, java.util.EventListener

public class ItemPricingEngineImpl
extends PricingEngineService
implements ItemPricingEngine

An ItemPricingEngine implementation which computes the price for an order. It accomplishes this task by invoking a series of ItemPricingCalculators which incrementally compute the items' prices:

Properties:

See Also:
ItemPriceInfo, ItemPricingCalculator

Nested Class Summary
 
Nested classes/interfaces inherited from class atg.commerce.pricing.PricingEngineService
PricingEngineService.EmptyItemPriceInfo
 
Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from class atg.commerce.pricing.PricingEngineService
EXTRA_PARAM_QUALIFIERSERVICE, mGlobalPromotions, mPricingCalculatorServices
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
ItemPricingEngineImpl()
           
 
Method Summary
protected  void applyCalculator(java.lang.Object pCalc, int pPricingMethod, java.util.List pItemPriceQuotes, java.util.List pItems, PricingContext pPricingContext, java.util.Map pExtraParameters)
          Calls the supplied calculator service to price one or more items.
protected  java.util.Collection<RepositoryItem> applyPromotions(java.util.Collection pPricingModels, int pPricingMethod, java.util.List pItemPriceQuotes, java.util.List pItems, PricingContext pPricingContext, java.util.Map pExtraParameters)
          Apply the pricing models (promotions) to the object being priced.
 void checkPromotionsForCloseness(java.util.List pPriceInfos, java.util.List pItems, java.util.Collection pPricingModels, java.util.Locale pLocale, RepositoryItem pProfile, Order pOrder, java.util.Map pExtraParameters)
          Check to see if the items qualify under any of the pricingModels' "closenessQualifiers".
protected  boolean didPromotionQualify(RepositoryItem pPricingModel, PricingContext pPricingContext, java.util.Map pExtraParameters)
          Determines if a promotion qualified or not.
protected  java.util.Set<RepositoryItem> getAppliedPromotions(java.util.List pItems)
          Returns a list of applied promotions.
protected  java.lang.String getCurrencyCode(CommerceItem pItem, java.util.Collection pPricingModels, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters)
          Return the currency code that should be used in the context of this pricing request
protected  java.lang.String getCurrencyCode(java.util.List pItems, java.util.Collection pPricingModels, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters)
          Return the currency code that should be used in the context of this pricing request
 ItemPricingCalculator[] getPostCalculators()
          Returns property PostCalculators
 ItemPricingCalculator[] getPreCalculators()
          Returns property PreCalculators
 atg.commerce.pricing.PromotionProcessingComponent[] getPrePromotionProcessing()
          Returns property PrePromotionProcessing
protected  java.util.List<AmountInfo> getPriceInfoDetails(PricingContext pPricingContext, java.util.Map pExtraParameters)
          Returns price info details for each item.
 java.util.Collection getPricingModels(RepositoryItem pProfile)
          Returns a List of pricing models (e.g.
 PricingTools getPricingTools()
          pricing tools to help with calculating prices
protected  java.lang.String getStackingRuleOrderLimitReachedMessageIdentifier()
          Value for stacking rule order limit reached message identifier.
protected  java.lang.String getStackingRulePromotionExcludedMessageIdentifier()
          Value for stacking rule promotion excluded message identifier.
protected  void mapItemToItemPriceSource(java.lang.String pCurrencyCode, java.util.List pItems, java.util.Collection pPricingModels, java.util.Locale pLocale, RepositoryItem pProfile, Order pOrder, java.util.Map pExtraParameters)
          This method is called by the engine prior to the pre-calcualtors being called.
 java.util.List priceEachItem(java.util.List pItems, java.util.Collection pPricingModels, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters)
          Price each of a List of items in a context
 ItemPriceInfo priceItem(CommerceItem pItem, java.util.Collection pPricingModels, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters)
          Price a single item in a context
 java.util.List priceItems(java.util.List pItems, java.util.Collection pPricingModels, java.util.Locale pLocale, RepositoryItem pProfile, Order pOrder, java.util.Map pExtraParameters)
          Price a List of items together in a context
 void setPostCalculators(ItemPricingCalculator[] pPostCalculators)
          Sets property PostCalculators
 void setPreCalculators(ItemPricingCalculator[] pPreCalculators)
          Sets property PreCalculators
 void setPrePromotionProcessing(atg.commerce.pricing.PromotionProcessingComponent[] pPrePromotionProcessing)
          Sets property PrePromotionProcessing
 void setPricingTools(PricingTools pPricingTools)
          pricing tools to help with calculating prices
 
Methods inherited from class atg.commerce.pricing.PricingEngineService
addPromotion, addPromotionToList, applyPromotionProcessing, checkAndAddPromotions, checkAndMergePromotions, checkPromotionExpiration, createEmptyItemPriceInfo, createPriceInfo, createStackingRuleExclusionMessage, didPromotionApply, doStartService, doStopService, expirePromotion, findGlobalPromotions, generateStackingRuleInfo, getAdjustmentPricingModels, getAlwaysLoadGlobalPromotions, getAppliedPromotions, getCalculator, getCalculatorForCalculatorType, getCalculatorTypeCalculators, getCalculatorTypes, getClosenessQualifierEvaluator, getCurrencyCode, getDefaultLocale, getGlobalPromotions, getGlobalPromotionsQuery, getGlobalPromotionsSchedulableDate, getInitialPromotions, getLocale, getPriceInfoClass, getPricingCurrencyCode, getPricingModelComparator, getPricingModelEvaluationVetoers, getPricingModelHolderVetoers, getPricingModelProperties, getProfileProperties, getPromotionItemDescriptors, getPromotionItemTypes, getPromotions, getPromotionsRepository, getPromotionTools, getQualifierService, getQualifierService, getQualifierService, getScheduler, getUpdateSchedule, getUserOnlyPromotions, isUseMerge, isValidItemDescriptor, loadGlobalPromotions, performScheduledTask, prepareEvaluationVetoers, prepareHolderVetoers, pricingComplete, pricingStart, processCQPromotionAnalysisInformation, processDidPromotionApply, removeExpiredPromotions, resetEmptyItemPriceInfos, resolveCalculator, setAlwaysLoadGlobalPromotions, setCalculatorTypeCalculators, setClosenessQualifierEvaluator, setDefaultLocale, setGlobalPromotionsQuery, setGlobalPromotionsSchedulableDate, setPriceInfoClass, setPricingModelComparator, setPricingModelEvaluationVetoers, setPricingModelHolderVetoers, setPricingModelProperties, setProfileProperties, setPromotionItemTypes, setPromotionsRepository, setPromotionTools, setQualifierService, setScheduler, setUpdateSchedule, setupStackingRuleCollections, setUseMerge, skipPromotion, updateStackingRuleTracking, vetoPromotionsForEvaluation, wasPromotionSkipped
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
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

ItemPricingEngineImpl

public ItemPricingEngineImpl()
Method Detail

setPreCalculators

public void setPreCalculators(ItemPricingCalculator[] pPreCalculators)
Sets property PreCalculators


getPreCalculators

public ItemPricingCalculator[] getPreCalculators()
Returns property PreCalculators


setPrePromotionProcessing

public void setPrePromotionProcessing(atg.commerce.pricing.PromotionProcessingComponent[] pPrePromotionProcessing)
Sets property PrePromotionProcessing


getPrePromotionProcessing

public atg.commerce.pricing.PromotionProcessingComponent[] getPrePromotionProcessing()
Returns property PrePromotionProcessing


setPostCalculators

public void setPostCalculators(ItemPricingCalculator[] pPostCalculators)
Sets property PostCalculators


getPostCalculators

public ItemPricingCalculator[] getPostCalculators()
Returns property PostCalculators


setPricingTools

public void setPricingTools(PricingTools pPricingTools)
pricing tools to help with calculating prices

Overrides:
setPricingTools in class PricingEngineService
Parameters:
pPricingTools - new value to set

getPricingTools

public PricingTools getPricingTools()
pricing tools to help with calculating prices

Overrides:
getPricingTools in class PricingEngineService
Returns:
property PricingTools

getPricingModels

public java.util.Collection getPricingModels(RepositoryItem pProfile)
Returns a List of pricing models (e.g. promotions) for given a Profile.

Specified by:
getPricingModels in interface PricingEngine
Parameters:
pProfile - The user's profile from which the engine will extract promotions
Returns:
List of RepositoryItems which represent pricing models for use in pricing.

getCurrencyCode

protected java.lang.String getCurrencyCode(CommerceItem pItem,
                                           java.util.Collection pPricingModels,
                                           java.util.Locale pLocale,
                                           RepositoryItem pProfile,
                                           java.util.Map pExtraParameters)
                                    throws PricingException
Return the currency code that should be used in the context of this pricing request

Throws:
PricingException - if an error occurs while attempting to determine the currency code

getCurrencyCode

protected java.lang.String getCurrencyCode(java.util.List pItems,
                                           java.util.Collection pPricingModels,
                                           java.util.Locale pLocale,
                                           RepositoryItem pProfile,
                                           java.util.Map pExtraParameters)
                                    throws PricingException
Return the currency code that should be used in the context of this pricing request

Throws:
PricingException - if an error occurs while attempting to determine the currency code

priceItem

public ItemPriceInfo priceItem(CommerceItem pItem,
                               java.util.Collection pPricingModels,
                               java.util.Locale pLocale,
                               RepositoryItem pProfile,
                               java.util.Map pExtraParameters)
                        throws PricingException
Price a single item in a context

Specified by:
priceItem in interface ItemPricingEngine
Parameters:
pItem - The item to price
pPricingModels - A Collection of RepositoryItems representing PricingModels
pLocale - The Locale to use for pricing
pProfile - The user's profile
pExtraParameters - A Map of extra parameters to be used in the pricing, may be null
Returns:
ItemPriceInfo representing the price quote for the item. Return null if no pricing info can be determined. This may occur if the item supplied is null.
Throws:
PricingException - if an error occurs while attempting to price

priceEachItem

public java.util.List priceEachItem(java.util.List pItems,
                                    java.util.Collection pPricingModels,
                                    java.util.Locale pLocale,
                                    RepositoryItem pProfile,
                                    java.util.Map pExtraParameters)
                             throws PricingException
Price each of a List of items in a context

Specified by:
priceEachItem in interface ItemPricingEngine
Parameters:
pItems - The items to price (individually)
pPricingModels - A Collection of RepositoryItems representing PricingModels
pLocale - The Locale to use for pricing
pProfile - The user's profile
pExtraParameters - A Map of extra parameters to be used in the pricing, may be null
Returns:
List of ItemPriceInfo objects representing the price quotes for each item. Return null if no pricing info can be determined. This may occur if the list of items supplied is null or empty.
Throws:
PricingException - if an error occurs while attempting to price

priceItems

public java.util.List priceItems(java.util.List pItems,
                                 java.util.Collection pPricingModels,
                                 java.util.Locale pLocale,
                                 RepositoryItem pProfile,
                                 Order pOrder,
                                 java.util.Map pExtraParameters)
                          throws PricingException
Price a List of items together in a context

Specified by:
priceItems in interface ItemPricingEngine
Parameters:
pItems - The items to price
pPricingModels - A Collection of RepositoryItems representing PricingModels
pLocale - The Locale to use for pricing
pProfile - The user's profile
pOrder - The Order object of which the List of items are a part, may be null
pExtraParameters - A Map of extra parameters to be used in the pricing, may be null
Returns:
List of ItemPriceInfo objects representing the price quotes for the items. Return null if no pricing info can be determined. This may occur if the list of items supplied is null or empty.
Throws:
PricingException - if an error occurs while attempting to price

applyPromotions

protected java.util.Collection<RepositoryItem> applyPromotions(java.util.Collection pPricingModels,
                                                               int pPricingMethod,
                                                               java.util.List pItemPriceQuotes,
                                                               java.util.List pItems,
                                                               PricingContext pPricingContext,
                                                               java.util.Map pExtraParameters)
                                                        throws PricingException
Apply the pricing models (promotions) to the object being priced. Evaluates the promotions and calls the associated calculator services to price the object. QualifiedItem's are processed in batches with items batched together if they have the same discount structure.

Parameters:
pPricingMethod - PricingMethod enum
pItemPriceQuotes - List of ItemPriceInfo for the items being priced
pItems - List of CommerceItem being priced
pPricingContext - PricingContext
pPricingModels - Collection of PricingModel to process
pExtraParameters - Map of extra parameters, may be null
Returns:
Collection of RepositoryItem promotions that were applied, i.e. not vetoed
Throws:
PricingException

applyCalculator

protected void applyCalculator(java.lang.Object pCalc,
                               int pPricingMethod,
                               java.util.List pItemPriceQuotes,
                               java.util.List pItems,
                               PricingContext pPricingContext,
                               java.util.Map pExtraParameters)
                        throws PricingException
Calls the supplied calculator service to price one or more items.

Parameters:
pCalc - Calculator to call
pPricingMethod - Calculator method to use
pItemPriceQuotes - List of ItemPriceInfo for the commerce items
pItems - List of CommerceItem to price
pPricingContext - PricingContext
pExtraParameters - Map of extra parameters
Throws:
PricingException

mapItemToItemPriceSource

protected void mapItemToItemPriceSource(java.lang.String pCurrencyCode,
                                        java.util.List pItems,
                                        java.util.Collection pPricingModels,
                                        java.util.Locale pLocale,
                                        RepositoryItem pProfile,
                                        Order pOrder,
                                        java.util.Map pExtraParameters)
                                 throws PricingException
This method is called by the engine prior to the pre-calcualtors being called. It maps the incoming ItemPriceSource objects to the items being priced.

The incoming source objects are extracted from the extra parameter map using the key defined by PricingConstants.ITEM_PRICE_SOURCE_LIST_PARAM

The resulting map is added to the extra parameter map using the key defined by PricingConstants.ITEM_PRICE_SOURCE_MAP_PARAM

Parameters:
pCurrencyCode - the currency code being used for the current pricing operation
pItems - the items being priced
pPricingModels -
pLocale -
pProfile -
pOrder -
pExtraParameters -
Throws:
PricingException
See Also:
PricingTools#generateItemPricingSourceMap(Collection, List, CommerceItem, String)

checkPromotionsForCloseness

public void checkPromotionsForCloseness(java.util.List pPriceInfos,
                                        java.util.List pItems,
                                        java.util.Collection pPricingModels,
                                        java.util.Locale pLocale,
                                        RepositoryItem pProfile,
                                        Order pOrder,
                                        java.util.Map pExtraParameters)
                                 throws PricingException
Check to see if the items qualify under any of the pricingModels' "closenessQualifiers". If so, add the closenessQualifiers to the priceInfo.

Parameters:
pPriceInfos - The PriceInfos associated with the items
pItems - The items to check
pPricingModels - A Collection of RepositoryItems representing PricingModels
pLocale - The Locale to use for pricing
pProfile - The user's profile
pExtraParameters - A Map of extra parameters to be used in the pricing, may be null
Throws:
PricingException - if a problem occurred when checking for closeness

getAppliedPromotions

protected java.util.Set<RepositoryItem> getAppliedPromotions(java.util.List pItems)
Returns a list of applied promotions.

Parameters:
pItems - list of all items in the order
Returns:
a set of applied promotions

didPromotionQualify

protected boolean didPromotionQualify(RepositoryItem pPricingModel,
                                      PricingContext pPricingContext,
                                      java.util.Map pExtraParameters)
                               throws PricingException
Determines if a promotion qualified or not. Returns true if the promotion qualified, false otherwise.

Overrides:
didPromotionQualify in class PricingEngineService
Parameters:
pPricingModel - promotion to check
pPricingContext - PricingContext
pExtraParameters - Map of extra parameters, may be null
Returns:
true if the promotion qualified, false otherwise
Throws:
PricingException - if something went wrong

getPriceInfoDetails

protected java.util.List<AmountInfo> getPriceInfoDetails(PricingContext pPricingContext,
                                                         java.util.Map pExtraParameters)
Returns price info details for each item.

Overrides:
getPriceInfoDetails in class PricingEngineService
Parameters:
pPricingContext - PricingContext
pExtraParameters - Map of extra parameters, may be null
Returns:
true if the promotion qualified, false otherwise

getStackingRuleOrderLimitReachedMessageIdentifier

protected java.lang.String getStackingRuleOrderLimitReachedMessageIdentifier()
Value for stacking rule order limit reached message identifier.

Overrides:
getStackingRuleOrderLimitReachedMessageIdentifier in class PricingEngineService
Returns:
message identifier

getStackingRulePromotionExcludedMessageIdentifier

protected java.lang.String getStackingRulePromotionExcludedMessageIdentifier()
Value for stacking rule promotion excluded message identifier.

Overrides:
getStackingRulePromotionExcludedMessageIdentifier in class PricingEngineService
Returns:
message identifier