atg.commerce.pricing
Class ShippingCalculatorImpl

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.commerce.pricing.ShippingCalculatorImpl
All Implemented Interfaces:
ShippingPricingCalculator, 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, java.util.EventListener
Direct Known Subclasses:
DoubleRangeShippingCalculator, FixedPriceShippingCalculator

public abstract class ShippingCalculatorImpl
extends GenericService
implements ShippingPricingCalculator

This abstract class is a starting point for some general functionality on calculating pricing for shipping groups. The implementation of priceShippingGroup checks to make sure there are items in the shipping group. If there are no items then we reset the price quote back to zero. If there are items to price for shipping, then we confirm through the performPricing method that the items in the group should be priced. For example softgoods, like gift certificates, should not be priced for shipping. The developer who extends this class should implement the getAmount method which will be used as the base shipping cost in this calculator. Finally the amount returned is set into the ShippingPriceInfo. If the addAmount property is true, then we take the amount returned and add it to the current ShippingPriceInfo.amount. This allows surcharges to be tacked on.

The shippingMethod property should be set to the name of a particular delivery process. For example: UPS Ground, UPS 2-day or UPS Next Day.

If the ignoreShippingMethod property is true, then this calculator does not expose a shipping method name (through getAvailableMethods). In addition this calculator will always attempt to perform pricing. This option is available if the user is not given a choice of different shipping methods.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
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
ShippingCalculatorImpl()
          Constructs an instanceof ShippingCalculatorImpl
 
Method Summary
 void doStartService()
          This is called after a Service has been created, placed into the naming hierarchy, and initialized with its configured property values.
protected  double getAmount(Order pOrder, ShippingPriceInfo pPriceQuote, ShippingGroup pShippingGroup, RepositoryItem pPricingModel, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters)
          Return the amount which should be used for the pricing of this shipping group The default implementation just returns the subtotal of the shipping group, or zero if the subtotal cannot be found
protected  double getAmount(ShippingPriceInfo pPriceQuote, ShippingGroup pShippingGroup, RepositoryItem pPricingModel, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters)
          Deprecated.  
 void getAvailableMethods(java.util.List pMethods, ShippingGroup pShippingGroup, RepositoryItem pPricingModel, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters)
          Get shipping methods available to deliver the shipping group.
 PricingTools getPricingTools()
          pricing tools to help in calculating prices
 java.lang.String getShippingMethod()
          Returns property ShippingMethod
protected  boolean haveItemsToShip(ShippingGroup pShippingGroup)
          Return true if there are any items in the shipping group to price.
 boolean isAddAmount()
          Returns property AddAmount
 boolean isIgnoreShippingMethod()
          Returns property IgnoreShippingMethod
protected  boolean performPricing(ShippingGroup pShippingGroup)
          Return true if we should price the shipping group
 void priceShippingGroup(Order pOrder, ShippingPriceInfo pPriceQuote, ShippingGroup pShippingGroup, RepositoryItem pPricingModel, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters)
          Price a shipment within a context
protected  void priceShippingPriceInfo(double pAmount, ShippingPriceInfo pPriceQuote)
          Set the amount that is given into the price quote.
protected  void resetShippingPriceInfo(ShippingPriceInfo pPriceQuote)
          Reset the price quote back to zero
 void setAddAmount(boolean pAddAmount)
          Sets property AddAmount
 void setIgnoreShippingMethod(boolean pIgnoreShippingMethod)
          Sets property IgnoreShippingMethod
 void setPricingTools(PricingTools pPricingTools)
          pricing tools to help in calculating prices
 void setShippingMethod(java.lang.String pShippingMethod)
          Sets property ShippingMethod
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStopService, 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

ShippingCalculatorImpl

public ShippingCalculatorImpl()
Constructs an instanceof ShippingCalculatorImpl

Method Detail

setPricingTools

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

Parameters:
pPricingTools - new value to set

getPricingTools

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

Returns:
property PricingTools

setShippingMethod

public void setShippingMethod(java.lang.String pShippingMethod)
Sets property ShippingMethod


getShippingMethod

public java.lang.String getShippingMethod()
Returns property ShippingMethod


setIgnoreShippingMethod

public void setIgnoreShippingMethod(boolean pIgnoreShippingMethod)
Sets property IgnoreShippingMethod


isIgnoreShippingMethod

public boolean isIgnoreShippingMethod()
Returns property IgnoreShippingMethod


setAddAmount

public void setAddAmount(boolean pAddAmount)
Sets property AddAmount


isAddAmount

public boolean isAddAmount()
Returns property AddAmount


priceShippingGroup

public void priceShippingGroup(Order pOrder,
                               ShippingPriceInfo pPriceQuote,
                               ShippingGroup pShippingGroup,
                               RepositoryItem pPricingModel,
                               java.util.Locale pLocale,
                               RepositoryItem pProfile,
                               java.util.Map pExtraParameters)
                        throws PricingException
Price a shipment within a context

Specified by:
priceShippingGroup in interface ShippingPricingCalculator
Parameters:
pOrder - the Order in the context of which pShipment is being priced.
pPriceQuote - ShippingPriceInfo representing the price quote for the shipment
pShippingGroup - The shipment to price
pPricingModels - A Collection of RepositoryItems representing PricingModels
pProfile - The user's profile
pExtraParameters - A Map of extra parameters to be used in the pricing, may be null
Throws:
PricingException

getAmount

protected double getAmount(Order pOrder,
                           ShippingPriceInfo pPriceQuote,
                           ShippingGroup pShippingGroup,
                           RepositoryItem pPricingModel,
                           java.util.Locale pLocale,
                           RepositoryItem pProfile,
                           java.util.Map pExtraParameters)
                    throws PricingException
Return the amount which should be used for the pricing of this shipping group The default implementation just returns the subtotal of the shipping group, or zero if the subtotal cannot be found

Throws:
PricingException

getAmount

protected double getAmount(ShippingPriceInfo pPriceQuote,
                           ShippingGroup pShippingGroup,
                           RepositoryItem pPricingModel,
                           java.util.Locale pLocale,
                           RepositoryItem pProfile,
                           java.util.Map pExtraParameters)
                    throws PricingException
Deprecated. 

Return the amount which should be used for the pricing of this shipping group

Throws:
PricingException

resetShippingPriceInfo

protected void resetShippingPriceInfo(ShippingPriceInfo pPriceQuote)
Reset the price quote back to zero


priceShippingPriceInfo

protected void priceShippingPriceInfo(double pAmount,
                                      ShippingPriceInfo pPriceQuote)
Set the amount that is given into the price quote. This method looks at the addAmount property, and if it is true, then we add the base amount to the current amount.


haveItemsToShip

protected boolean haveItemsToShip(ShippingGroup pShippingGroup)
Return true if there are any items in the shipping group to price. If there are no items then the shipping amount will be reset to 0.


performPricing

protected boolean performPricing(ShippingGroup pShippingGroup)
Return true if we should price the shipping group


getAvailableMethods

public void getAvailableMethods(java.util.List pMethods,
                                ShippingGroup pShippingGroup,
                                RepositoryItem pPricingModel,
                                java.util.Locale pLocale,
                                RepositoryItem pProfile,
                                java.util.Map pExtraParameters)
                         throws PricingException
Get shipping methods available to deliver the shipping group. Always add ourselves to the list of methods.

Specified by:
getAvailableMethods in interface ShippingPricingCalculator
Parameters:
pMethods - List of Strings representing shipping methods
pShippingGroup - The shipping group to deliver
pPricingModels - A Collection of RepositoryItems representing PricingModels
pProfile - The user's profile
pExtraParameters - A Map of extra parameters to be used in the pricing, may be null
Throws:
PricingException

doStartService

public void doStartService()
                    throws ServiceException
Description copied from class: GenericService
This is called after a Service has been created, placed into the naming hierarchy, and initialized with its configured property values. The Service should override this method to start any processes it requires.

Overrides:
doStartService in class GenericService
Throws:
ServiceException - if the Service had a problem starting up