public class ItemPriceCalculator extends GenericService implements ItemPricingCalculator, ItemPriceSourceHandler
Properties:
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.
ItemPricingCalculator
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_VERSION
Class version string
|
SERVICE_INFO_KEY
DEFAULT_LOG_TRACE_STATUS
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
Constructor and Description |
---|
ItemPriceCalculator() |
Modifier and Type | Method and Description |
---|---|
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. |
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
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
public static final java.lang.String CLASS_VERSION
public void setLoggingIdentifier(java.lang.String pLoggingIdentifier)
pLoggingIdentifier
- new value to setpublic java.lang.String getLoggingIdentifier()
public void setPricingSchemePropertyName(java.lang.String pPricingSchemePropertyName)
pPricingSchemePropertyName
- new value to setpublic java.lang.String getPricingSchemePropertyName()
public void setProfilePriceListPropertyName(java.lang.String pProfilePriceListPropertyName)
pProfilePriceListPropertyName
- The new value to setpublic java.lang.String getProfilePriceListPropertyName()
public void setNoPriceIsError(boolean pNoPriceIsError)
pNoPriceIsError
- The new value to setpublic boolean isNoPriceIsError()
public void setPriceListManager(PriceListManager pPriceListManager)
pPriceListManager
- the new value to setpublic PriceListManager getPriceListManager()
public void setPricingTools(PricingTools pPricingTools)
pPricingTools
- the new value to setpublic PricingTools getPricingTools()
public void setUseDefaultPriceList(boolean pUseDefaultPriceList)
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.pUseDefaultPriceList
- boolean new value to setpublic boolean isUseDefaultPriceList()
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 truepublic void setPricingSchemeNames(java.util.Properties pPricingSchemeNames)
pPricingSchemeNames
- new value to setpublic java.util.Properties getPricingSchemeNames()
public void setNoPriceCalculator(ItemPricingCalculator pNoPriceCalculator)
pNoPriceCalculator
- The no price calculatorpublic ItemPricingCalculator getNoPriceCalculator()
protected java.lang.String getPricingScheme(RepositoryItem pPrice) throws PricingException
PricingException
public void priceItem(ItemPriceInfo pPriceQuote, CommerceItem pItem, RepositoryItem pPricingModel, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters) throws PricingException
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
.
priceItem
in interface ItemPricingCalculator
pPriceQuote
- ItemPriceInfo representing the current price quote for the itempItem
- The item to pricepPricingModel
- A RepositoryItem representing a PricingModelpProfile
- The user's profilepExtraParameters
- 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 keyPricingException
getItemPriceSource(ItemPriceInfo, CommerceItem, RepositoryItem, Locale, RepositoryItem, Map)
,
shouldConsumeSource(ItemPriceSource)
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
priceEachItem
in interface ItemPricingCalculator
pPriceQuotes
- List of ItemPriceInfo objects representing the current price quotes for each itempItems
- The items to price (individually)pPricingModel
- A RepositoryItem representing a PricingModelpProfile
- The user's profilepExtraParameters
- A Map of extra parameters to be used in the pricing, may be nullPricingException
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
priceItems
in interface ItemPricingCalculator
pPriceQuotes
- List of ItemPriceInfo objects representing the current price quotes for the itemspItems
- The items to pricepPricingModel
- A RepositoryItem representing a PricingModelpProfile
- The user's profilepOrder
- The Order object of which the List of items are a part, may be nullpExtraParameters
- A Map of extra parameters to be used in the pricing, may be nullPricingException
protected RepositoryItem getDifferentPriceList(ItemPriceInfo pPriceQuote, CommerceItem pItem, RepositoryItem pPricingModel, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters) throws PriceListException
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.PriceListException
public ItemPriceSource getItemPriceSource(ItemPriceInfo pPriceQuote, CommerceItem pItem, RepositoryItem pPricingModel, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters)
ItemPriceSource
that
should be used to price the given CommerceItem
This implemenation returns the matching source from the extra parameters
getItemPriceSource
in interface ItemPriceSourceHandler
pPriceQuote
- the new ItemPriceInfo for that's being generated in the pricing operationpItem
- the commerce item that's being pricedpPricingModel
- the current pricing modelpLocale
- the localepProfile
- the customer profile referencepExtraParameters
- the extra parameter map passed to the pricing operation.PricingTools.getItemPriceSource(ItemPriceInfo, CommerceItem, RepositoryItem, Locale, RepositoryItem, Map)
public boolean populateItemPriceSource(ItemPriceSource pItemPriceSource, Order pOrder, CommerceItem pCommerceItem, CommerceItem pParentCommerceItem, java.util.Map pExtraParameters)
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
populateItemPriceSource
in interface ItemPriceSourceHandler
pItemPriceSource
- the source being generated and populated with pricing data.pOrder
- the OrderpCommerceItem
- the item for which the source is being createdpParentCommerceItem
- the item that contained pCommerceItempExtraParameters
- a Map of extra parameters objects that was passed to the initial call to generate the source objects.ItemPriceSource
properties were updatedpublic boolean shouldConsumeSource(ItemPriceSource pItemPriceSource)
ItemPriceSourceHandler
is configured.
A false return causes the calculator to completely bypass its pricing operation and return normally.
shouldConsumeSource
in interface ItemPriceSourceHandler
pItemPriceSource
-