com.ibm.commerce.price.commands
Class GetContractUnitPriceCmdImpl

java.lang.Object
  |
  +--com.ibm.commerce.command.AbstractECCommand
        |
        +--com.ibm.commerce.command.TaskCommandImpl
              |
              +--com.ibm.commerce.price.commands.GetContractUnitPriceCmdImpl
All Implemented Interfaces:
ECCommand, GetContractSpecialPriceCmd, GetContractUnitPriceCmd, GetProductContractUnitPriceCmd, TaskCommand

public class GetContractUnitPriceCmdImpl
extends TaskCommandImpl
implements GetContractUnitPriceCmd, GetContractSpecialPriceCmd, GetProductContractUnitPriceCmd

This GetContractUnitPriceCmd Task Command Implementation can be called by several commands such as ProductDisplayCmd, OrderItemAddCmd, OrderItemUpdateCmd, OrderItemDisplayCmd and OrderPrepareCmd,Controller Command to calculate the best contract price for a catalog entry given a list of trading agreements (and offers) and also for each of these trading agreements, obtain its best contract price.

If the command is successful retrieving the price, it will return the best price, the offer id and access bean, the T&C id and the trading agreement id that determined the price.

If unsuccessful, the command throws the ECApplicationException specifying an Error Message (ERR_RETRIEVE_PRICE), an Error Code (ERR_CODE_NO_PRICE) and the Error View (RetrievePriceErrorView).

Behaviour

Obtain all the qualified offers for the input catalog entry, each offer to be retrieved to find the price of a catalog entry must satisfy the following criteria (Invoke CalculateContractPricesCmd):

Get the best price among all the qualified offers for the input catalog entry (Invoke SelectContractPricesCmd):

Exception Conditions


Fields inherited from class com.ibm.commerce.command.AbstractECCommand
commandContext
 
Fields inherited from interface com.ibm.commerce.price.commands.GetContractUnitPriceCmd
COPYRIGHT, NAME
 
Fields inherited from interface com.ibm.commerce.command.ECCommand
defaultCommandClassName
 
Fields inherited from interface com.ibm.commerce.price.commands.GetContractSpecialPriceCmd
COPYRIGHT, NAME
 
Fields inherited from interface com.ibm.commerce.price.commands.GetProductContractUnitPriceCmd
COPYRIGHT, defaultCommandClassName, NAME
 
Constructor Summary
GetContractUnitPriceCmdImpl()
          GetBaseUnitPriceCmdImpl constructor.
 
Method Summary
protected  void calculatePrices(java.lang.Integer storeId)
          Retrieves all the qualified offers for the input catalog entry in that each offer must meet a list of criteria.
 java.lang.Long[] getApplicableTradingIds()
          Returns the ids of the trading agreements that are used to determine the prices.
 MonetaryAmount[] getApplicableTradingUnitPrices()
          Returns the unit prices of a catentry that were determined for each of the applied trading agreements.
 MonetaryAmount getBasePrice()
          Returns the base price of the input catalog entry.
 CatEntryPrices[] getCatEntryPrices()
          Returns the price related information of the input catalog entries.
 OfferAccessBean getOffer()
          Returns the offer access bean that was used to determine the price.
 java.lang.Long getOfferId()
          Returns the id of the output offer id that was used to determine the price.
 MonetaryAmount getPrice()
          Returns the actual price of the catalog entry.
 java.lang.Long getTcId()
          Returns the id of the output T&C id which was associated with the offer that supplied the price.
 java.lang.Long getTradingId()
          Returns the id of the output trading agreement id which was associated with the offer that supplied the price.
 void performExecute()
          Executes main business logic of the command.
 void reset()
          reset the command.
protected  java.util.Hashtable resolvePriceLists(BusinessPolicyAccessBean[] pricePolicyABs)
          Resolve the price lists referenced by a list of price business policies.
protected  boolean resolveTradingAgreements()
          Verifies and resolves a list of eligible trading agreements for the user.
protected  void retrievePrices()
          Retrieves all the qualified offers for the input catalog entry in that each offer must meet a list of criteria.
protected  void selectPrices(java.lang.Integer storeId)
          Selects the best offer for the input catalog entry among a list of qualified offers.
 void setCatEntryId(java.lang.Long anCatEntryId)
          Sets the id of the input catalog entry.
 void setCatEntryPrices(CatEntryPrices[] aCatEntryPrices)
          Sets the information of one or more catalog entries (Future Support).
 void setCurrency(java.lang.String astrCurrency)
          Sets the currency to be used for finding the price (Optional).
 void setErrorMode(boolean aErrorMode)
          Sets the flag to indicate if exception will be thrown when the price cannot be found for the input catentry (Optional).
 void setMemberId(java.lang.Long anMemberId)
          Sets the member id to be used for verifying and searching the trading agreements (Optional).
 void setOfferIds(java.lang.Long[] aOfferIds)
          Sets the ids of the input offers to be used for price (Optional).
 void setOrderItemAccessBean(OrderItemAccessBean aOrderItemAB)
          Sets the orderitem Access Bean.
 void setQuantity(QuantityAmount aQuantityAmount)
          Sets the quantity amount of the input catalog entry that is to be priced (Optional).
 void setStoreId(java.lang.Integer aStoreId)
          Sets the id of the input store to be used for calculating the price (Optional).
 void setTradingIds(java.lang.Long[] aTradingIds)
          Sets the ids of the input trading agreements (Optional).
 void validateParameters()
          Checks mandatory parameters.
 
Methods inherited from class com.ibm.commerce.command.AbstractECCommand
accessControlCheck, checkIsAllowed, checkResourcePermission, execute, finalize, getAccCheck, getCommandContext, getCommandIfName, getCommandName, getDefaultProperties, getResources, getStoreId, getUser, getUserId, isReadyToCallExecute, setAccCheck, setCommandContext, setCommandIfName, setDefaultProperties
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.ibm.commerce.command.ECCommand
checkIsAllowed, checkResourcePermission, execute, getAccCheck, getCommandContext, getCommandIfName, getCommandName, getDefaultProperties, getResources, getStoreId, getUser, getUserId, setAccCheck, setCommandContext, setCommandIfName, setDefaultProperties
 

Constructor Detail

GetContractUnitPriceCmdImpl

public GetContractUnitPriceCmdImpl()
GetBaseUnitPriceCmdImpl constructor.
Method Detail

calculatePrices

protected void calculatePrices(java.lang.Integer storeId)
                        throws ECException
Retrieves all the qualified offers for the input catalog entry in that each offer must meet a list of criteria. Selects the best adjustment provided by the Ts&Cs and applies the adjustment on the offer prices.

getApplicableTradingIds

public java.lang.Long[] getApplicableTradingIds()
Returns the ids of the trading agreements that are used to determine the prices.

Specified by:
getApplicableTradingIds in interface GetContractUnitPriceCmd
Returns:
A list of trading agreement ids for determining the prices.

getApplicableTradingUnitPrices

public MonetaryAmount[] getApplicableTradingUnitPrices()
Returns the unit prices of a catentry that were determined for each of the applied trading agreements.

Specified by:
getApplicableTradingUnitPrices in interface GetContractUnitPriceCmd
Returns:
A list of unit prices of a catentry for each of the applied trading agreements.

getBasePrice

public MonetaryAmount getBasePrice()
Returns the base price of the input catalog entry.
Specified by:
getBasePrice in interface GetContractUnitPriceCmd
Following copied from interface: com.ibm.commerce.price.commands.GetContractUnitPriceCmd
Returns:
The base price monetary amount (and currency) found for the catalog entry before any conversion. This is only set when the requested currency is different from the base currency. The base price must be converted to the requested price.

getCatEntryPrices

public CatEntryPrices[] getCatEntryPrices()
Returns the price related information of the input catalog entries.
Specified by:
getCatEntryPrices in interface GetContractUnitPriceCmd
Following copied from interface: com.ibm.commerce.price.commands.GetContractUnitPriceCmd
Returns:
The price related information of the input catalog entries.

getOffer

public OfferAccessBean getOffer()
Returns the offer access bean that was used to determine the price.
Specified by:
getOffer in interface GetContractUnitPriceCmd
Following copied from interface: com.ibm.commerce.price.commands.GetContractUnitPriceCmd
Returns:
The offer access bean associated with the offer that was used to determine the price.

getOfferId

public java.lang.Long getOfferId()
Returns the id of the output offer id that was used to determine the price.
Specified by:
getOfferId in interface GetContractUnitPriceCmd
Following copied from interface: com.ibm.commerce.price.commands.GetContractUnitPriceCmd
Returns:
The reference number of the offer that was used to determine the price.

getPrice

public MonetaryAmount getPrice()
Returns the actual price of the catalog entry.
Specified by:
getPrice in interface GetContractUnitPriceCmd
Following copied from interface: com.ibm.commerce.price.commands.GetContractUnitPriceCmd
Returns:
The actual price of the catalog entry in the requested currency of the shopper.

getTcId

public java.lang.Long getTcId()
Returns the id of the output T&C id which was associated with the offer that supplied the price.
Specified by:
getTcId in interface GetContractUnitPriceCmd
Following copied from interface: com.ibm.commerce.price.commands.GetContractUnitPriceCmd
Returns:
The reference number of the T&C that was used to determine the price.

getTradingId

public java.lang.Long getTradingId()
Returns the id of the output trading agreement id which was associated with the offer that supplied the price.
Specified by:
getTradingId in interface GetContractUnitPriceCmd
Following copied from interface: com.ibm.commerce.price.commands.GetContractUnitPriceCmd
Returns:
The reference number of the trading agreement that was used to determine the price.

performExecute

public void performExecute()
                    throws ECException
Executes main business logic of the command.
Specified by:
performExecute in interface ECCommand
Overrides:
performExecute in class AbstractECCommand
Following copied from interface: com.ibm.commerce.command.ECCommand
Throws:
com.ibm.commerce.command.CommandException - The superclass for all ECExceptions.

reset

public void reset()
reset the command.
Overrides:
reset in class AbstractECCommand

resolvePriceLists

protected java.util.Hashtable resolvePriceLists(BusinessPolicyAccessBean[] pricePolicyABs)
                                         throws ECException
Resolve the price lists referenced by a list of price business policies.
Parameters:
pricePolicyABs - the access beans of price business policies.

Returns:
A list of price lists associated with each of the input price policies.

resolveTradingAgreements

protected boolean resolveTradingAgreements()
                                    throws ECException
Verifies and resolves a list of eligible trading agreements for the user.

If trading agreements are specified, the input list will be verified against the eligible list when the member id is provided. The eligible list of trading agreements can be obtained from the Command Context if the input member id is the one in Command Context.

If trading agreements are not specified, the list may be obtained directly from the Command Context (if no member id is provided or the input member id is the one in Command Context) or retrieved by means of the member id (if the id is provided and is different from that in the Command Context).

Returns:
true if valid trading agreements can be resolved.

Throws:
ECApplicationException - If no eligible trading agreements can be obtained (ERR_NO_ELIGIBLE_TRADING).
ECApplicationException - If the specified trading agreement is not valid (ERR_NO_VALID_TRADING).

retrievePrices

protected void retrievePrices()
                       throws ECException
Retrieves all the qualified offers for the input catalog entry in that each offer must meet a list of criteria.

selectPrices

protected void selectPrices(java.lang.Integer storeId)
                     throws ECException
Selects the best offer for the input catalog entry among a list of qualified offers.

setCatEntryId

public void setCatEntryId(java.lang.Long anCatEntryId)
Sets the id of the input catalog entry.
Specified by:
setCatEntryId in interface GetContractUnitPriceCmd
Following copied from interface: com.ibm.commerce.price.commands.GetContractUnitPriceCmd
Parameters:
anCatEntryId - The reference number of a catalog entry whose price is to be retrieved and calculated.

setCatEntryPrices

public void setCatEntryPrices(CatEntryPrices[] aCatEntryPrices)
Sets the information of one or more catalog entries (Future Support).
Specified by:
setCatEntryPrices in interface GetContractUnitPriceCmd
Following copied from interface: com.ibm.commerce.price.commands.GetContractUnitPriceCmd
Parameters:
aCatEntryPrices - The information of one or more catalog entries whose prices are To be retrieved.

setCurrency

public void setCurrency(java.lang.String astrCurrency)
Sets the currency to be used for finding the price (Optional).
Specified by:
setCurrency in interface GetContractUnitPriceCmd
Following copied from interface: com.ibm.commerce.price.commands.GetContractUnitPriceCmd
Parameters:
astrCurrency - The currency to look up the price. If the currency is not specified then the "negotiated" currency is used for the store Id and shopper's preferred currency. (The negotiated currency is the currency returned from the getCurrency() method of the currency manager).

setErrorMode

public void setErrorMode(boolean aErrorMode)
Sets the flag to indicate if exception will be thrown when the price cannot be found for the input catentry (Optional).
Specified by:
setErrorMode in interface GetContractUnitPriceCmd
Following copied from interface: com.ibm.commerce.price.commands.GetContractUnitPriceCmd
Parameters:
aErrorMode - The indicator to decide if an exception will be thrown when the price cannot be found. A true value (default) means throw exception. A false value means do not throw exception and returns a null value price

setMemberId

public void setMemberId(java.lang.Long anMemberId)
Sets the member id to be used for verifying and searching the trading agreements (Optional).
Specified by:
setMemberId in interface GetContractUnitPriceCmd
Following copied from interface: com.ibm.commerce.price.commands.GetContractUnitPriceCmd
Parameters:
anMemberId - The member id to be used to verify the input list of trading agreements, if provided. The input list of trading agreements, will be validated against the eligible list which can be either obtained directly from the Command Context or looked up by means of the member id if such id is different from the one in the Command Context. If no trading agreement is input, the member id will then be used to look up the list of trading agreements.

setOfferIds

public void setOfferIds(java.lang.Long[] aOfferIds)
Sets the ids of the input offers to be used for price (Optional).
Specified by:
setOfferIds in interface GetContractUnitPriceCmd
Following copied from interface: com.ibm.commerce.price.commands.GetContractUnitPriceCmd
Parameters:
aOfferIds - The reference number of one or more offers that are Sto be used for determining the price. If no offer ids are supplied, then the "best" of all qualifying offers will be used. Otherwise, the "best" of the specified offers will be returned.

setOrderItemAccessBean

public void setOrderItemAccessBean(OrderItemAccessBean aOrderItemAB)
Sets the orderitem Access Bean.
Specified by:
setOrderItemAccessBean in interface GetContractSpecialPriceCmd
Parameters:
aOrderItemAB - an order item access bean.

setQuantity

public void setQuantity(QuantityAmount aQuantityAmount)
Sets the quantity amount of the input catalog entry that is to be priced (Optional).
Specified by:
setQuantity in interface GetContractUnitPriceCmd
Following copied from interface: com.ibm.commerce.price.commands.GetContractUnitPriceCmd
Parameters:
aQuantityAmount - The quantity amount of the catalog entry. The quantity amount helps determine which offers are valid. 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.

setStoreId

public void setStoreId(java.lang.Integer aStoreId)
Sets the id of the input store to be used for calculating the price (Optional).
Specified by:
setStoreId in interface GetContractUnitPriceCmd
Following copied from interface: com.ibm.commerce.price.commands.GetContractUnitPriceCmd
Parameters:
aStoreId - The reference number of a store to be used for calculating the price. If the store id is not specified then the store id of the command context will be used.

setTradingIds

public void setTradingIds(java.lang.Long[] aTradingIds)
Sets the ids of the input trading agreements (Optional).
Specified by:
setTradingIds in interface GetContractUnitPriceCmd
Following copied from interface: com.ibm.commerce.price.commands.GetContractUnitPriceCmd
Parameters:
aTradingIds - The reference numbers of a list of trading agreements to be used to determine the offers that will supply the prices and the adjustments to be applied to the prices.

validateParameters

public void validateParameters()
                        throws ECException
Checks mandatory parameters.
Specified by:
validateParameters in interface ECCommand
Overrides:
validateParameters in class AbstractECCommand
Following copied from interface: com.ibm.commerce.command.ECCommand
Throws:
ECException. -