public interface GetContractUnitPriceCmd extends TaskCommand
There are two ways to specify the catalog entries for which prices should be calculated.
For each catalog entry specified, there may be multiple trading agreements used to calculate the price, and so the price for each of these trading agreements is returned. Among these prices, there is a "best" price which is returned as well. The best price is usually the lowest price among all trading agreements for a given catalog entry identifier, but this behavior can be customized.
The information related to price calculations for all catalog entries is returned through the getCatEntryPrices() method. This method will return the correct information regardless of whether single mode or batch mode is used. Each of the returned CatEntryPrices objects contains the relevant information for a single catalog entry. This interface also provides methods to access the same information on the first catalog entry for which prices were calculated. In other words, the first CatEntryPrices object in the array returned by getCatEntryPrices() can be accessed by using the methods on that object, or by calling analogous get methods on this command. This is done mainly for backwards compatibility and compatibility with similar interfaces (see below for similar interfaces).
The table below describes the mapping between methods of this command and those of the first CatEntryPrices returned by getCatEntryPrices():
GetContractUnitPriceCmd method | CatEntryPrices method | Best or All Prices? |
---|---|---|
getTradingId() | CatEntryPrices.getTradingId() | Best |
getTcId() | CatEntryPrices.getTcId() | Best |
getOfferId() | CatEntryPrices.getOfferId() | Best |
getOffer() | CatEntryPrices.getOffer() | Best |
getBasePrice() | CatEntryPrices.getBasePrice() | Best |
getPrice() | CatEntryPrices.getUnitPrice() | Best |
getApplicableTradingIds() | CatEntryPrices.getAllTradingIds() | All |
Not applicable | CatEntryPrices.getTradingTcIds() | All |
Not applicable | CatEntryPrices.getOfferIds() | All |
Not applicable | CatEntryPrices#getOffers() | All |
Not applicable | CatEntryPrices.getTradingBasePrices() | All |
getApplicableTradingUnitPrices() | CatEntryPrices.getTradingUnitPrices() | All |
Note that the methods that return price information per trading agreement (those with the "all" designation) for a catalog entry also include the best price among them.
This command is closely related to GetContractSpecialPriceCmd and GetProductContractUnitPriceCmd. In fact, the default implementation is the same for all three. However, because they are used in different situations, it is possible to customize each situation differently.
To customize price calculations when viewing the shopping cart or current order, register a class that implements this interface (or a subclass of an existing class such as GetContractUnitPriceCmdImpl) in the command registry. The calculations for the other commands will be unaffected.
Modifier and Type | Field and Description |
---|---|
static java.lang.String | COPYRIGHT
IBM copyright notice field.
|
static java.lang.String | NAME
The name of this command.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Long[] | getApplicableTradingIds()
Returns the identifiers of the trading agreements that were used to determine the prices for a catalog entry.
|
MonetaryAmount[] | getApplicableTradingUnitPrices()
Returns the prices that were determined for each of the applied trading agreements for a catalog entry.
|
MonetaryAmount | getBasePrice()
Returns the best price of the input catalog entry before any currency conversions.
|
CatEntryPrices[] | getCatEntryPrices()
Returns the price related information for the input catalog entries.
|
OfferAccessBean | getOffer()
Returns the offer access bean that was used to determine the price.
|
java.lang.Long | getOfferId()
Returns the identifier of the offer that was used to determine the price.
|
MonetaryAmount | getPrice()
Returns the best price of the catalog entry in the requested currency.
|
java.lang.Long | getTcId()
Returns the identifier of the term condition which was used to calculate the best price.
|
java.lang.Long | getTradingId()
Returns the identifier of the trading agreement which was used to calculate the best price.
|
void | reset()
Resets this command so that it is in its default state.
|
void | setCatEntryId(java.lang.Long anCatEntryId)
Sets the identifier of the catalog entry whose price is to be calculated.
|
void | setCatEntryPrices(CatEntryPrices[] aCatEntryPrices)
Sets the information of one or more catalog entries whose prices are to be calculated.
|
void | setCurrency(java.lang.String astrCurrency)
Sets the desired currency to be used for the output price.
|
void | setErrorMode(boolean aErrorMode)
Sets whether an exception will be thrown when the price cannot be found for the input catalog entry.
|
void | setMemberId(java.lang.Long anMemberId)
Sets the member identifier to be used for determining which trading agreements are valid to use to calculate the price.
|
void | setOfferIds(java.lang.Long[] aOfferIds)
Sets the identifiers of the input offers to be used for price.
|
void | setOrganizationId(java.lang.Long anOrganizationId)
Sets the organization identifier to be used in conjunction with the member identifier for verifying and searching for trading agreements.
|
void | setQuantity(QuantityAmount aQuantityAmount)
Sets the quantity of the input catalog entry that is to be priced.
|
void | setStoreId(java.lang.Integer aStoreId)
Sets the identifier of the store to be used for calculating the price.
|
void | setTradingIds(java.lang.Long[] aTradingIds)
Sets the identifiers of the input trading agreements.
|
static final java.lang.String COPYRIGHT
static final java.lang.String NAME
void reset()
The original definition of this method described in com.ibm.websphere.command.Command.reset() requires that this method sets the output properties to the values they had before the execute() method was run. The original definition also requires that after calling this method, isReadyToCallExecute() method returns true.
In addition to the above, this command requires that input parameters must also be set to their original default values. For example, consider the following sequence of calls:
GetContractUnitPriceCmd cmd = ... cmd.setCatEntryId(id); cmd.reset(); cmd.setCatEntryPrices(catEntryPricesArray);After these calls are executed, cmd will behave as though only setCatEntryPrices(CatEntryPrices[]) had been called.
java.lang.Long[] getApplicableTradingIds()
If this command is used in single mode, these identifiers will reflect the trading agreements that were specified for that catalog entry. If this command is used in batch mode, then these identifiers will reflect the trading agreements that were used for the first catalog entry in the input array.
MonetaryAmount[] getApplicableTradingUnitPrices()
If this command is used in single mode, these prices will reflect the prices that were found for the input catalog entry. If this command is used in batch mode, then these prices will reflect the prices that were used for the first catalog entry in the input array.
MonetaryAmount getBasePrice()
If this command is used in single mode, this price will be for the input catalog entry. If this command is used in batch mode, then this price will be for the first catalog entry in the input array.
CatEntryPrices[] getCatEntryPrices()
The following values reflect information about the best price for the catalog entry:
The following values reflect information about all prices for the catalog entry:
If this command is used in single mode, this array will contain one element corresponding to the input catalog entry. If this command is used in batch mode, then this array will contain the same catalog entry information, in the same order, as the input array.
In the latter case, the array itself is not guaranteed to be the same as the input array, and the elements are not guaranteed to be the same as those in the input array. However, for optimization purposes, they may be the same array and elements. In other words, users of this command should make no assumptions that the input array and elements are the same or different from the returned array.
OfferAccessBean getOffer()
If this command is used in single mode, this offer will be for the input catalog entry. If this command is used in batch mode, then this offer will be for the first catalog entry in the input array.
java.lang.Long getOfferId()
If this command is used in single mode, this offer will be for the input catalog entry. If this command is used in batch mode, then this offer will be for the first catalog entry in the input array.
MonetaryAmount getPrice()
If this command is used in single mode, this price will be for the input catalog entry. If this command is used in batch mode, then this price will be for the first catalog entry in the input array.
java.lang.Long getTcId()
If this command is used in single mode, this term condition will be for the input catalog entry. If this command is used in batch mode, then this term condition will be for the first catalog entry in the input array.
java.lang.Long getTradingId()
If this command is used in single mode, this trading agreement will be for the input catalog entry. If this command is used in batch mode, then this trading agreement will be for the first catalog entry in the input array.
void setCatEntryId(java.lang.Long anCatEntryId)
Either this method or setCatEntryPrices(CatEntryPrices[]) must be called with non-null parameters before executing this command. The default value is null.
void setCatEntryPrices(CatEntryPrices[] aCatEntryPrices)
See setTradingIds(Long[]) for a description of how the trading agreements in the CatEntryPrices specified by this method are used to determine price.
Either this method or setCatEntryId(Long) must be called with non-null parameters before executing this command. The default value is null.
void setCurrency(java.lang.String astrCurrency)
This input value is optional. The default value is obtained from another source, such as CurrencyManager.getCurrency(StoreAccessBean, String, Integer). This currency will only be used in conjunction with setCatEntryId(Long).
void setErrorMode(boolean aErrorMode)
This input value is optional. The default value is true.
void setMemberId(java.lang.Long anMemberId)
This input value is optional. The default value is obtained from CommandContext.getUserId().
void setOrganizationId(java.lang.Long anOrganizationId)
This input value is optional. The default value is the EntitlementContext.getActiveOrganizationId().
void setOfferIds(java.lang.Long[] aOfferIds)
This input value is optional. The default value is the list of all qualifying offers. These offers will only be used in conjunction with setCatEntryId(Long).
void setQuantity(QuantityAmount aQuantityAmount)
For example, consider the table below:
Quantity range | Price per unit |
---|---|
1-5 | 10 USD |
6-10 | 9 USD |
If the quantity amount is not specified, then the nominal quantity (rounded up to the nearest multiple as specified in the quantityMultiple attribute) of the Catalog entry is assumed to be the requested quantity. See the CATENTSHIP table for more information. This behavior can be implemented by calling RetrievePricesCmd.
This input value is optional. The default value is the nominal quantity for the catalog entry. This quantity will only be used in conjunction with setCatEntryId(Long).
void setStoreId(java.lang.Integer aStoreId)
This input value is optional. The default value is CommandContext.getStoreId().
void setTradingIds(java.lang.Long[] aTradingIds)
Each member is entitled to a number of trading agreements (possibly zero), depending on the member and store. The trading agreements for each catalog entry are provided in one of three ways (from highest to lowest precedence):
This input value is optional. The default value is null.