atg.commerce.pricing
Class ItemPriceCalculator

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.commerce.pricing.ItemPriceCalculator
All Implemented Interfaces:
ItemPriceSourceHandler, ItemPricingCalculator, 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:
ConfigurableItemPriceCalculator, ItemListPriceCalculator, ItemSalePriceCalculator

public abstract class ItemPriceCalculator
extends GenericService
implements ItemPricingCalculator, ItemPriceSourceHandler

Superclass for all CommerceItem calculators. Consolidates functionality that some item price calculators have in common. ItemPriceCalculator extends ApplicationLoggingImpl, so classes that extend this one have access to Nucleus logging services. This class contains a single abstract method: priceItem. Extending classes implement this method to leverage this class's other CommerceItem pricing methods.

Properties:

See Also:
ItemListPriceCalculator, ItemSalePriceCalculator

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
 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
protected  double getPrice(java.lang.Object pPriceSource)
          Return the price that should be used in pricing.
 java.lang.String getPricePropertyName()
          Returns the name of the property of the catalogRef property of CommerceItem which contains the price
protected  java.lang.Object getPriceSource(CommerceItem pItem)
          Return the object which should be used as the source for pricing.
 java.lang.Object getPriceSource(ItemPriceInfo pPriceQuote, CommerceItem pItem, RepositoryItem pPricingModel, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters)
          Returns the object that should be used as a price source for the given commerce item.
 PricingTools getPricingTools()
          pricing tools to help with price calculation
 boolean isPriceFromCatalogRef()
          Returns property PriceFromCatalogRef.
 boolean isRequirePriceValue()
          Returns property RequirePriceValue
 boolean populateItemPriceSource(ItemPriceSource pItemPriceSource, Order pOrder, CommerceItem pCommerceItem, CommerceItem pParentCommerceItem, java.util.Map pExtraParameters)
          This is a no-op implementation that returns false.
 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
protected abstract  void priceItem(double pPrice, ItemPriceInfo pPriceQuote, CommerceItem pItem, RepositoryItem pPricingModel, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters)
          Set the price info given the determined price
 void priceItem(ItemPriceInfo pPriceQuote, CommerceItem pItem, RepositoryItem pPricingModel, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters)
          Price a single item in a context
 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 setPriceFromCatalogRef(boolean pPriceFromCatalogRef)
          Sets property PriceFromCatalogRef
 void setPricePropertyName(java.lang.String pPricePropertyName)
          Returns the name of the property of the catalogRef property of CommerceItem which contains the price
 void setPricingTools(PricingTools pPricingTools)
          pricing tools to help with price calculation
 void setRequirePriceValue(boolean pRequirePriceValue)
          Sets property RequirePriceValue
 boolean shouldConsumeSource(ItemPriceSource pItemPriceSource)
          Determines if the price source should be consumed by the calculator.
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, 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 final java.lang.String CLASS_VERSION
Class version string

See Also:
Constant Field Values
Constructor Detail

ItemPriceCalculator

public ItemPriceCalculator()
Method Detail

setPricingTools

public void setPricingTools(PricingTools pPricingTools)
pricing tools to help with price calculation

Parameters:
pPricingTools - new value to set

getPricingTools

public PricingTools getPricingTools()
pricing tools to help with price calculation

Returns:
property PricingTools

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

setPricePropertyName

public void setPricePropertyName(java.lang.String pPricePropertyName)
Returns the name of the property of the catalogRef property of CommerceItem which contains the price

Parameters:
pPricePropertyName - the new value to set

getPricePropertyName

public java.lang.String getPricePropertyName()
Returns the name of the property of the catalogRef property of CommerceItem which contains the price

Returns:
the property pricePropertyName

setRequirePriceValue

public void setRequirePriceValue(boolean pRequirePriceValue)
Sets property RequirePriceValue


isRequirePriceValue

public boolean isRequirePriceValue()
Returns property RequirePriceValue


setPriceFromCatalogRef

public void setPriceFromCatalogRef(boolean pPriceFromCatalogRef)
Sets property PriceFromCatalogRef


isPriceFromCatalogRef

public boolean isPriceFromCatalogRef()
Returns property PriceFromCatalogRef.

Returns:
true if the price should be extracted from the catalogRef (aka sku). Otherwise extract the price from the product object

getPriceSource

protected java.lang.Object getPriceSource(CommerceItem pItem)
                                   throws PricingException
Return the object which should be used as the source for pricing. This method uses the priceFromCatalogRef property as a switch to determine if the catalogRef or productRef should be returned from the CommerceItem

Throws:
PricingException

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 item's 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)

getPriceSource

public java.lang.Object getPriceSource(ItemPriceInfo pPriceQuote,
                                       CommerceItem pItem,
                                       RepositoryItem pPricingModel,
                                       java.util.Locale pLocale,
                                       RepositoryItem pProfile,
                                       java.util.Map pExtraParameters)
                                throws PricingException
Returns the object that should be used as a price source for the given commerce item. A price source object should have a property with the name defined by the configurable property pricePropertyName.

This implementation first checks for a ItemPriceSource and returns it, if found. Otherwise, it delegates to the getPriceSource(CommerceItem) method

Throws:
PricingException
See Also:
getPriceSource(CommerceItem)

getPrice

protected double getPrice(java.lang.Object pPriceSource)
                   throws PricingException
Return the price that should be used in pricing. Return -1 if no pricing should take place for this object

Throws:
PricingException

priceItem

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

The list price is determined from price source object returned by getPriceSource

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
Throws:
PricingException
See Also:
getPriceSource(ItemPriceInfo, CommerceItem, RepositoryItem, Locale, RepositoryItem, Map)

priceItem

protected abstract void priceItem(double pPrice,
                                  ItemPriceInfo pPriceQuote,
                                  CommerceItem pItem,
                                  RepositoryItem pPricingModel,
                                  java.util.Locale pLocale,
                                  RepositoryItem pProfile,
                                  java.util.Map pExtraParameters)
                           throws PricingException
Set the price info given the determined price

Parameters:
pPrice - the price as extracted from the item
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
Throws:
PricingException

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
pPricingModels - 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

populateItemPriceSource

public boolean populateItemPriceSource(ItemPriceSource pItemPriceSource,
                                       Order pOrder,
                                       CommerceItem pCommerceItem,
                                       CommerceItem pParentCommerceItem,
                                       java.util.Map pExtraParameters)
This is a no-op implementation that returns false. Subclasses override this method to provide calculator specific handling.

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)
Determines if the price source should be consumed by the calculator. A false return value will cause the calculator to complete bypass its processing and return normally.

This implementation always returns false. Subclasses override this method to make a determination based on the contents of the source.

Specified by:
shouldConsumeSource in interface ItemPriceSourceHandler
Parameters:
pItemPriceSource - the source that was given to price the item.
Returns:
true if the source should be consumed by the calculator. false if the calculator should bypass its processing and return normally.