atg.commerce.pricing.priceLists
Class ItemPriceCalculator

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.commerce.pricing.priceLists.ItemPriceCalculator
All Implemented Interfaces:
ItemPriceSourceHandler, ItemPricingCalculator, NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener
Direct Known Subclasses:
ConfigurableItemPriceListCalculator, ItemSalePriceCalculator

public class ItemPriceCalculator
extends GenericService
implements ItemPricingCalculator, ItemPriceSourceHandler

This class can either price a single commerce item or price a list of commerce items. It will first select the priceList to use based on the profilePriceListPropertyName property, then it will delegate the pricing to different ItemSchemePriceCalculators based on the item's pricing scheme by the pricingSchemePropertyName property.

Properties:

See Also:
ItemPricingCalculator

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
ItemPriceCalculator()
           
 
Method Summary
protected  RepositoryItem getDifferentPriceList(ItemPriceInfo pPriceQuote, CommerceItem pItem, RepositoryItem pPricingModel, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters)
          Get the price list from the extra parameters.
 ItemPriceSource getItemPriceSource(ItemPriceInfo pPriceQuote, CommerceItem pItem, RepositoryItem pPricingModel, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters)
          This method is called by the calculator to get the ItemPriceSource that should be used to price the given CommerceItem
 java.lang.String getLoggingIdentifier()
          the ID that this class uses to identify itself in logs
 ItemPricingCalculator getNoPriceCalculator()
          Gets the price calculator to use as a fallback when the price is null in the price list.
 PriceListManager getPriceListManager()
          Returns the reference to the PriceListManager which handles the operations of the PriceList Note: this property now defaults to pricingTools.priceListManager and it is recommended to use that instead
protected  java.lang.String getPricingScheme(RepositoryItem pPrice)
          Return the pricing scheme in the Price RepositoryItem
 java.util.Properties getPricingSchemeNames()
          Returns the key/Value pair for the allowed scheme names and its corresponding Calculator
 java.lang.String getPricingSchemePropertyName()
          the name of the property for the PricingScheme
 PricingTools getPricingTools()
          Returns the reference to the PricingTools which has utility methods for pricing
 java.lang.String getProfilePriceListPropertyName()
          The name of the property in the profile that stores the price list.
 boolean isNoPriceIsError()
          If this is true, and the price list is null or there is not price in the price list, then an error is thrown.
 boolean isUseDefaultPriceList()
          If true and ProfilePriceListPropertyName is null, then the value of PriceListManager.automaticallyUseDefaultPriceList determines if the default price list is used.
 boolean populateItemPriceSource(ItemPriceSource pItemPriceSource, Order pOrder, CommerceItem pCommerceItem, CommerceItem pParentCommerceItem, java.util.Map pExtraParameters)
          Populates the source object by calling populateItemPriceSource on each scheme calculator that implements the handler interface.
 void priceEachItem(java.util.List pPriceQuotes, java.util.List pItems, RepositoryItem pPricingModel, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters)
          Price each of a List of items in a context
 void priceItem(ItemPriceInfo pPriceQuote, CommerceItem pItem, RepositoryItem pPricingModel, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters)
          This method calls the appropriate scheme calculator to price the item.
 void priceItems(java.util.List pPriceQuotes, java.util.List pItems, RepositoryItem pPricingModel, java.util.Locale pLocale, RepositoryItem pProfile, Order pOrder, java.util.Map pExtraParameters)
          Price a List of items together in a context
 void setLoggingIdentifier(java.lang.String pLoggingIdentifier)
          the ID that this class uses to identify itself in logs
 void setNoPriceCalculator(ItemPricingCalculator pNoPriceCalculator)
          Sets the price calculator to use as a fallback when the price is null in the price list.
 void setNoPriceIsError(boolean pNoPriceIsError)
          If this is true, and the price list is null or there is not price in the price list, then an error is thrown.
 void setPriceListManager(PriceListManager pPriceListManager)
          Sets property PriceListManager which handles the operations of the PriceList Note: this property now defaults to pricingTools.priceListManager and it is recommended to use that instead
 void setPricingSchemeNames(java.util.Properties pPricingSchemeNames)
          the key/Value pair for the allowed scheme names and its corresponding Calculator
 void setPricingSchemePropertyName(java.lang.String pPricingSchemePropertyName)
          the name of the property for the PricingScheme
 void setPricingTools(PricingTools pPricingTools)
          Sets property PricingTools which has utility methods for pricing
 void setProfilePriceListPropertyName(java.lang.String pProfilePriceListPropertyName)
          The name of the property in the profile that stores the price list.
 void setUseDefaultPriceList(boolean pUseDefaultPriceList)
          If true and the profiles ProfilePriceListPropertyName is null, then the default price list from the PriceListManager is used.
 boolean shouldConsumeSource(ItemPriceSource pItemPriceSource)
          Returns true if the source's priceListScheme is valued and a scheme calculator that implements ItemPriceSourceHandler is configured.
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, 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, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, 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 final java.lang.String CLASS_VERSION
Class version string

See Also:
Constant Field Values
Constructor Detail

ItemPriceCalculator

public ItemPriceCalculator()
Method Detail

setLoggingIdentifier

public void setLoggingIdentifier(java.lang.String pLoggingIdentifier)
the ID that this class uses to identify itself in logs

Parameters:
pLoggingIdentifier - new value to set

getLoggingIdentifier

public java.lang.String getLoggingIdentifier()
the ID that this class uses to identify itself in logs

Returns:
property LoggingIdentifier

setPricingSchemePropertyName

public void setPricingSchemePropertyName(java.lang.String pPricingSchemePropertyName)
the name of the property for the PricingScheme

Parameters:
pPricingSchemePropertyName - new value to set

getPricingSchemePropertyName

public java.lang.String getPricingSchemePropertyName()
the name of the property for the PricingScheme

Returns:
property PricingSchemePropertyName

setProfilePriceListPropertyName

public void setProfilePriceListPropertyName(java.lang.String pProfilePriceListPropertyName)
The name of the property in the profile that stores the price list.

Parameters:
pProfilePriceListPropertyName - The new value to set

getProfilePriceListPropertyName

public java.lang.String getProfilePriceListPropertyName()
The name of the property in the profile that stores the price list.

Returns:
The name of the property in the profile

setNoPriceIsError

public void setNoPriceIsError(boolean pNoPriceIsError)
If this is true, and the price list is null or there is not price in the price list, then an error is thrown. If this is false and the price list is null, then nothing happens. Default is true.

Parameters:
pNoPriceIsError - The new value to set

isNoPriceIsError

public boolean isNoPriceIsError()
If this is true, and the price list is null or there is not price in the price list, then an error is thrown. If this is false and the price list is null, then nothing happens. Default is true.

Returns:
The value of noPriceIsError

setPriceListManager

public void setPriceListManager(PriceListManager pPriceListManager)
Sets property PriceListManager which handles the operations of the PriceList Note: this property now defaults to pricingTools.priceListManager and it is recommended to use that instead

Parameters:
pPriceListManager - the new value to set

getPriceListManager

public PriceListManager getPriceListManager()
Returns the reference to the PriceListManager which handles the operations of the PriceList Note: this property now defaults to pricingTools.priceListManager and it is recommended to use that instead

Returns:
the reference to the PriceListManager

setPricingTools

public void setPricingTools(PricingTools pPricingTools)
Sets property PricingTools which has utility methods for pricing

Parameters:
pPricingTools - the new value to set

getPricingTools

public PricingTools getPricingTools()
Returns the reference to the PricingTools which has utility methods for pricing

Returns:
the reference to the PricingTools

setUseDefaultPriceList

public void setUseDefaultPriceList(boolean pUseDefaultPriceList)
If true and the profiles ProfilePriceListPropertyName is null, then the default price list from the PriceListManager is used. If false, and ProfilePriceListPropertyName is null, then nothing happens. Defaults to true.

Parameters:
pUseDefaultPriceList - boolean new value to set

isUseDefaultPriceList

public boolean isUseDefaultPriceList()
If true and ProfilePriceListPropertyName is null, then the value of PriceListManager.automaticallyUseDefaultPriceList determines if the default price list is used. If false, then the default price list is never used. The default is true

Returns:
The boolean value of useDefaultPriceList

setPricingSchemeNames

public void setPricingSchemeNames(java.util.Properties pPricingSchemeNames)
the key/Value pair for the allowed scheme names and its corresponding Calculator

Parameters:
pPricingSchemeNames - new value to set

getPricingSchemeNames

public java.util.Properties getPricingSchemeNames()
Returns the key/Value pair for the allowed scheme names and its corresponding Calculator

Returns:
the key/Value pair for the allowed scheme names and its corresponding Calculator

setNoPriceCalculator

public void setNoPriceCalculator(ItemPricingCalculator pNoPriceCalculator)
Sets the price calculator to use as a fallback when the price is null in the price list.

Parameters:
pNoPriceCalculator - The no price calculator

getNoPriceCalculator

public ItemPricingCalculator getNoPriceCalculator()
Gets the price calculator to use as a fallback when the price is null in the price list.

Returns:
The no price calculator.

getPricingScheme

protected java.lang.String getPricingScheme(RepositoryItem pPrice)
                                     throws PricingException
Return the pricing scheme in the Price RepositoryItem

Throws:
PricingException

priceItem

public void priceItem(ItemPriceInfo pPriceQuote,
                      CommerceItem pItem,
                      RepositoryItem pPricingModel,
                      java.util.Locale pLocale,
                      RepositoryItem pProfile,
                      java.util.Map pExtraParameters)
               throws PricingException
This method calls the appropriate scheme calculator to price the item. The correct scheme is determined from one of two sources: ItemPriceSource or the price item from the price list.

If a price source is returned from getItemPriceSource, its priceListScheme value is used to determine which scheme calculator to call. Otherwise, the price item is extracted using the price list. It will use the price list in the profile (most common usage) or the price list in the pExtraParameters map. In either case, it looks for profilePriceListPropertyName.

Specified by:
priceItem in interface ItemPricingCalculator
Parameters:
pPriceQuote - ItemPriceInfo representing the current price quote for the item
pItem - The item to price
pPricingModel - A RepositoryItem representing a PricingModel
pProfile - The user's profile
pExtraParameters - A Map of extra parameters to be used in the pricing, may be null You may override the price list in the profile by providing a price list (or price list id) in this map. Use profilePriceListPropertyName as the key
Throws:
PricingException
See Also:
getItemPriceSource(ItemPriceInfo, CommerceItem, RepositoryItem, Locale, RepositoryItem, Map), shouldConsumeSource(ItemPriceSource)

priceEachItem

public void priceEachItem(java.util.List pPriceQuotes,
                          java.util.List pItems,
                          RepositoryItem pPricingModel,
                          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 ItemPricingCalculator
Parameters:
pPriceQuotes - List of ItemPriceInfo objects representing the current price quotes for each item
pItems - The items to price (individually)
pPricingModel - A RepositoryItem representing a PricingModel
pProfile - The user's profile
pExtraParameters - A Map of extra parameters to be used in the pricing, may be null
Throws:
PricingException

priceItems

public void priceItems(java.util.List pPriceQuotes,
                       java.util.List pItems,
                       RepositoryItem pPricingModel,
                       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 ItemPricingCalculator
Parameters:
pPriceQuotes - List of ItemPriceInfo objects representing the current price quotes for the items
pItems - The items to price
pPricingModel - A RepositoryItem representing a PricingModel
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
Throws:
PricingException

getDifferentPriceList

protected RepositoryItem getDifferentPriceList(ItemPriceInfo pPriceQuote,
                                               CommerceItem pItem,
                                               RepositoryItem pPricingModel,
                                               java.util.Locale pLocale,
                                               RepositoryItem pProfile,
                                               java.util.Map pExtraParameters)
                                        throws PriceListException
Get the price list from the extra parameters. This should return null if you would rather use the price list out of the profile. This implementation only uses pExtraParameters. The rest are passed in just in case you might need them for a subclass. If this method returns null (which is the default) then the profile's priceList is used. This method looks in pExtraParameters for profilePriceListPropertyName. If it is present, then the price list mapped to by that key is returned. If the value in the map is a String, then it is assumed that this is a price list id, and PriceListManager is used to look up the price. Note: this method now delegates the implementation to PricingTools.getPriceListFromParameters method which retains the same logic specified above.

Returns:
a priceList repositoryItem, or null
Throws:
PriceListException

getItemPriceSource

public ItemPriceSource getItemPriceSource(ItemPriceInfo pPriceQuote,
                                          CommerceItem pItem,
                                          RepositoryItem pPricingModel,
                                          java.util.Locale pLocale,
                                          RepositoryItem pProfile,
                                          java.util.Map pExtraParameters)
This method is called by the calculator to get the ItemPriceSource that should be used to price the given CommerceItem

This implemenation returns the matching source from the extra parameters

Specified by:
getItemPriceSource in interface ItemPriceSourceHandler
Parameters:
pPriceQuote - the new ItemPriceInfo for that's being generated in the pricing operation
pItem - the commerce item that's being priced
pPricingModel - the current pricing model
pLocale - the locale
pProfile - the customer profile reference
pExtraParameters - the extra parameter map passed to the pricing operation.
Returns:
If not null, the ItemPriceSource that should be used to price the item.
See Also:
PricingTools.getItemPriceSource(ItemPriceInfo, CommerceItem, RepositoryItem, Locale, RepositoryItem, Map)

populateItemPriceSource

public boolean populateItemPriceSource(ItemPriceSource pItemPriceSource,
                                       Order pOrder,
                                       CommerceItem pCommerceItem,
                                       CommerceItem pParentCommerceItem,
                                       java.util.Map pExtraParameters)
Populates the source object by calling populateItemPriceSource on each scheme calculator that implements the handler interface. The source's price list scheme value is set to the scheme the returns true from populateItemPriceSource

Specified by:
populateItemPriceSource in interface ItemPriceSourceHandler
Parameters:
pItemPriceSource - the source being generated and populated with pricing data.
pOrder - the Order
pCommerceItem - the item for which the source is being created
pParentCommerceItem - the item that contained pCommerceItem
pExtraParameters - a Map of extra parameters objects that was passed to the initial call to generate the source objects.
Returns:
return true if any of the ItemPriceSource properties were updated

shouldConsumeSource

public boolean shouldConsumeSource(ItemPriceSource pItemPriceSource)
Returns true if the source's priceListScheme is valued and a scheme calculator that implements ItemPriceSourceHandler is configured.

A false return causes the calculator to completely bypass its pricing operation and return normally.

Specified by:
shouldConsumeSource in interface ItemPriceSourceHandler
Parameters:
pItemPriceSource -
Returns:
true if the calcualtor should attempt to consume the price source that was provided for the item.