atg.commerce.pricing
Class ShippingPricingEngineImpl

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.ShippingPricingEngineImpl
All Implemented Interfaces:
PricingEngine, ShippingPricingEngine, 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 ShippingPricingEngineImpl
extends PricingEngineService
implements ShippingPricingEngine

A ShippingPricingEngine implementation which computes the shipping price for an order. It accomplishes this task by invoking a series of ShippingPricingCalculators which incrementally compute the tax price:

Note: if a particular order of calculator invocation is desired, sorting must be done prior to passing discounts/precalculators/postcalculators in to the Engine.

Properties:

See Also:
ShippingPriceInfo, ShippingPricingCalculator

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
ShippingPricingEngineImpl()
           
 
Method Summary
protected  void applyCalculator(java.lang.Object pCalc, ShippingPriceInfo pShippingPriceQuote, ShippingGroup pShippingGroup, PricingContext pPricingContext, java.util.Map pExtraParameters)
          Calls the supplied calculator service to price a ShippingGroup.
protected  java.util.Collection<RepositoryItem> applyPromotions(java.util.Collection pPricingModels, ShippingPriceInfo pShippingPriceQuote, ShippingGroup pShippingGroup, PricingContext pPricingContext, java.util.Map pExtraParameters)
          Apply the pricing models (promotions) to the object being priced.
 void checkPromotionsForCloseness(ShippingPriceInfo pPriceInfo, ShippingGroup pShippingGroup, java.util.Collection pPricingModels, java.util.Locale pLocale, RepositoryItem pProfile, Order pOrder, java.util.Map pExtraParameters)
          Check to see if the shipping group qualifies under any of the pricingModels' "closenessQualifiers".
protected  boolean didPromotionQualify(RepositoryItem pPricingModel, PricingContext pPricingContext, java.util.Map pExtraParameters)
          Determines if a promotion qualified or not.
 java.util.List getAvailableMethods(ShippingGroup pShipment, java.util.Collection pPricingModels, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters)
          Get shipping methods available to deliver the shipping group.
protected  java.lang.String getCurrencyCode(ShippingGroup pShipment, 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
 ShippingPricingCalculator[] getPostCalculators()
          Gets the PricingCalculators which are run after any discounts are applied
 ShippingPricingCalculator[] getPreCalculators()
          Gets the PricingCalculators which are run before any discounts are applied
 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 shipping group.
 java.util.Collection getPricingModels(RepositoryItem pProfile)
          Returns a List of pricing models (e.g.
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.
 boolean isIgnoreEmptyShippingGroups()
          If this is true, then empty shipping groups are given a price of zero.
 boolean isShippingGroupEmpty(ShippingGroup pShippingGroup)
          Return true if the given shipping group is null or empty
 ShippingPriceInfo priceShippingGroup(Order pOrder, ShippingGroup pShipment, java.util.Collection pPricingModels, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters)
          Price a shipment within a context.
 void setIgnoreEmptyShippingGroups(boolean pIgnoreEmptyShippingGroups)
           
 void setPostCalculators(ShippingPricingCalculator[] pPostCalculators)
          Sets the PricingCalculators which are run after any discounts are applied
 void setPreCalculators(ShippingPricingCalculator[] pPreCalculators)
          Sets the PricingCalculators which are run before any discounts are applied
 void setPrePromotionProcessing(atg.commerce.pricing.PromotionProcessingComponent[] pPrePromotionProcessing)
          Sets property PrePromotionProcessing
 
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, getPricingTools, getProfileProperties, getPromotionItemDescriptors, getPromotionItemTypes, getPromotions, getPromotionsRepository, getPromotionTools, getQualifierService, getQualifierService, getQualifierService, getScheduler, getUpdateSchedule, getUserOnlyPromotions, isUseMerge, isValidItemDescriptor, loadGlobalPromotions, performScheduledTask, prepareEvaluationVetoers, prepareHolderVetoers, pricingComplete, removeExpiredPromotions, resetEmptyItemPriceInfos, resolveCalculator, setAlwaysLoadGlobalPromotions, setCalculatorTypeCalculators, setClosenessQualifierEvaluator, setDefaultLocale, setGlobalPromotionsQuery, setGlobalPromotionsSchedulableDate, setPriceInfoClass, setPricingModelComparator, setPricingModelEvaluationVetoers, setPricingModelHolderVetoers, setPricingModelProperties, setPricingTools, 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

ShippingPricingEngineImpl

public ShippingPricingEngineImpl()
Method Detail

setIgnoreEmptyShippingGroups

public void setIgnoreEmptyShippingGroups(boolean pIgnoreEmptyShippingGroups)

isIgnoreEmptyShippingGroups

public boolean isIgnoreEmptyShippingGroups()
If this is true, then empty shipping groups are given a price of zero. The default is true


setPreCalculators

public void setPreCalculators(ShippingPricingCalculator[] pPreCalculators)
Sets the PricingCalculators which are run before any discounts are applied


getPreCalculators

public ShippingPricingCalculator[] getPreCalculators()
Gets the PricingCalculators which are run before any discounts are applied


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(ShippingPricingCalculator[] pPostCalculators)
Sets the PricingCalculators which are run after any discounts are applied


getPostCalculators

public ShippingPricingCalculator[] getPostCalculators()
Gets the PricingCalculators which are run after any discounts are applied


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(ShippingGroup pShipment,
                                           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

priceShippingGroup

public ShippingPriceInfo priceShippingGroup(Order pOrder,
                                            ShippingGroup pShipment,
                                            java.util.Collection pPricingModels,
                                            java.util.Locale pLocale,
                                            RepositoryItem pProfile,
                                            java.util.Map pExtraParameters)
                                     throws PricingException
Price a shipment within a context. The context is represented by the input parameters.

Specified by:
priceShippingGroup in interface ShippingPricingEngine
Parameters:
pOrder - the Order in the context of which pShipment is being priced.
pShipment - The shipment 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:
ShippingPriceInfo representing the price quote for the shipment Return null if no pricing info can be determined. This may occur if the shipping group supplied is null.
Throws:
PricingException - if an error occurs while attempting to price

applyPromotions

protected java.util.Collection<RepositoryItem> applyPromotions(java.util.Collection pPricingModels,
                                                               ShippingPriceInfo pShippingPriceQuote,
                                                               ShippingGroup pShippingGroup,
                                                               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.

Parameters:
pPricingModels - Collection of PricingModel items to apply
pShippingPriceQuote - ShippingPriceInfo for the ShippingGroup being priced
pShippingGroup - ShippingGroup being priced
pPricingContext - PricingContext
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,
                               ShippingPriceInfo pShippingPriceQuote,
                               ShippingGroup pShippingGroup,
                               PricingContext pPricingContext,
                               java.util.Map pExtraParameters)
                        throws PricingException
Calls the supplied calculator service to price a ShippingGroup.

Parameters:
pCalc - ShippingPricingCalculator to call
pShippingPriceQuote - ShippingPriceInfo for the ShippingGroup being priced
pShippingGroup - ShippingGroup being priced
pPricingContext - PricingContext
pExtraParameters - Map of extra parameters
Throws:
PricingException

getAvailableMethods

public java.util.List getAvailableMethods(ShippingGroup pShipment,
                                          java.util.Collection pPricingModels,
                                          java.util.Locale pLocale,
                                          RepositoryItem pProfile,
                                          java.util.Map pExtraParameters)
                                   throws PricingException
Get shipping methods available to deliver the shipping group.

Specified by:
getAvailableMethods in interface ShippingPricingEngine
Parameters:
pShipment - The shipping group to deliver
pPricingModels - A Collection of RepositoryItems representing PricingModels
pLocale - The Locale to use for determining available shipping methods
pProfile - The user's profile
pExtraParameters - A Map of extra parameters to be used in the pricing, may be null
Returns:
List of Strings representing shipping methods. Return null if no pricing info can be determined. This may occur if the shipping group supplied is null.
Throws:
PricingException - if an error occurs while attempting to price

isShippingGroupEmpty

public boolean isShippingGroupEmpty(ShippingGroup pShippingGroup)
Return true if the given shipping group is null or empty


checkPromotionsForCloseness

public void checkPromotionsForCloseness(ShippingPriceInfo pPriceInfo,
                                        ShippingGroup pShippingGroup,
                                        java.util.Collection pPricingModels,
                                        java.util.Locale pLocale,
                                        RepositoryItem pProfile,
                                        Order pOrder,
                                        java.util.Map pExtraParameters)
                                 throws PricingException
Check to see if the shipping group qualifies under any of the pricingModels' "closenessQualifiers". If so, add the closenessQualifiers to the priceInfo.

Parameters:
pPriceInfo - The ShippingPriceInfo object associated with the shipping group.
pShippingGroup - The shipping group to check
pPricingModels - A Collection of RepositoryItems representing PricingModels
pLocale - The Locale to use for pricing
pProfile - The user's profile
pOrder - The order the shipping group belongs to
pExtraParameters - A Map of extra parameters to be used in the pricing, may be null
Throws:
PricingException

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 shipping group.

Overrides:
getPriceInfoDetails in class PricingEngineService
Parameters:
pPricingContext - PricingContext
pExtraParameters - Map of extra parameters, may be null
Returns:
list of price infos

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