atg.commerce.pricing
Class ShippingDiscountCalculator

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.commerce.pricing.DiscountCalculatorService
              extended by atg.commerce.pricing.ShippingDiscountCalculator
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:
BulkShippingDiscountCalculator

public class ShippingDiscountCalculator
extends DiscountCalculatorService
implements ShippingPricingCalculator

Calculates ShippingPriceInfos for ShippingGroups which the calculator is given. This calculator can either be passed in a MatchingObject via the extra parameters map with key Constants.MATCHING_OBJECT containing the ShippingGroup that qualified for the promotion or it can consult the Qualifier service, looking for the ShippingGroup to be priced. It calls Qualifier.findQualifyingShipping for this purpose. If it gets back a ShippingGroup, a ShippingPriceInfo is computed based on the input PricingModel (RepositoryItem).

If it obtains an ShippingGroup that qualified then it can determine the discount either via a DiscountStructure object being passed into the calculator via the extra parameters map with key Constants.DISCOUNT_STRUCTURE or by getting the discountType and adjuster properties of the input PricingModel (RepositoryItem).

See Also:
Qualifier

Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from class atg.commerce.pricing.DiscountCalculatorService
AMOUNT_INCREASE_TYPE, AMOUNT_OFF_TYPE, FIXED_PRICE_TYPE, ILLEGAL_TYPE, mPromotionTools, PERCENT_OFF_TYPE
 
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
ShippingDiscountCalculator()
           
 
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 getAmountToDiscount(Order pOrder, ShippingPriceInfo pPriceQuote, ShippingGroup pShippingGroup, RepositoryItem pPricingModel, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters)
          This will return the amount that will eventually be discounted.
 void getAvailableMethods(java.util.List pMethods, ShippingGroup pShipment, 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 with generating prices
 void priceShippingGroup(Order pOrder, ShippingPriceInfo pPriceQuote, ShippingGroup pShipment, RepositoryItem pPricingModel, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters)
          Price a shipment within a context
 void setPricingTools(PricingTools pPricingTools)
          pricing tools to help with generating prices
 
Methods inherited from class atg.commerce.pricing.DiscountCalculatorService
adjust, adjustAmount, getAdjuster, getDiscountType, getDiscountType, getPricingModelProperties, getPromotionTools, getQualifierService, getQualifierService, isNegativeAmountException, setNegativeAmountException, setPricingModelProperties, setPromotionTools, setQualifierService
 
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

ShippingDiscountCalculator

public ShippingDiscountCalculator()
Method Detail

setPricingTools

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

Parameters:
pPricingTools - new value to set

getPricingTools

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

Returns:
property PricingTools

priceShippingGroup

public void priceShippingGroup(Order pOrder,
                               ShippingPriceInfo pPriceQuote,
                               ShippingGroup pShipment,
                               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
pShipment - 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

getAvailableMethods

public void getAvailableMethods(java.util.List pMethods,
                                ShippingGroup pShipment,
                                RepositoryItem pPricingModel,
                                java.util.Locale pLocale,
                                RepositoryItem pProfile,
                                java.util.Map pExtraParameters)
                         throws PricingException
Get shipping methods available to deliver the shipping group. Since this is a discounting calculator and not an actual shipping method, this method does nothing.

Specified by:
getAvailableMethods in interface ShippingPricingCalculator
Parameters:
pMethods - List of Strings representing shipping methods
pShipment - 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

getAmountToDiscount

protected double getAmountToDiscount(Order pOrder,
                                     ShippingPriceInfo pPriceQuote,
                                     ShippingGroup pShippingGroup,
                                     RepositoryItem pPricingModel,
                                     java.util.Locale pLocale,
                                     RepositoryItem pProfile,
                                     java.util.Map pExtraParameters)
                              throws PricingException
This will return the amount that will eventually be discounted. This will be priceQuote.amount by default (and there will usually be no need to change this.)

Parameters:
pOrder - The order containing the shipping group
pPriceQuote - ShippingPriceInfo representing the current price quote for the shipping group
pShippingGroup - The shipping group that will be discounted (ignored by default)
pPricingModel - A RepositoryItems representing a PricingModel (ignored by default)
pProfile - The user's profile (ignored by default)
pExtraParameters - A Map of extra parameters to be used in the pricing, may be null (ignored by default)
Returns:
The amount to discount... defaults to pPriceQuote.getAmount()
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