com.ibm.commerce.price.commands
Class GetContractUnitPriceCmdImpl

java.lang.Object
  |
  +--CacheableCommandImpl
        |
        +--com.ibm.commerce.command.AbstractECTargetableCommand
              |
              +--com.ibm.commerce.command.TaskCommandImpl
                    |
                    +--com.ibm.commerce.price.commands.GetContractUnitPriceCmdImpl
All Implemented Interfaces:
ECCommand, ECTargetableCommand, 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

This command calls the following TaskCommands:

This command uses the following AccessBeans:
See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.ibm.commerce.command. AbstractECTargetableCommand
commandContext
 
Fields inherited from interface com.ibm.commerce.price.commands. GetContractUnitPriceCmd
COPYRIGHT, NAME
 
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
 
Fields inherited from interface com.ibm.commerce.command. ECTargetableCommand
COPYRIGHT
 
Fields inherited from interface com.ibm.commerce.command. ECCommand
defaultCommandClassName
 
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. AbstractECTargetableCommand
accessControlCheck, checkIsAllowed, checkParameters, checkResourcePermission, createCommandExecutionEvent, execute, finalize, getAccCheck, getCommandContext, getCommandIfName, getCommandName, getCommandStoreId, getDefaultProperties, getResources, getStoreId, getUser, getUserId, isReadyToCallExecute, setAccCheck, setCommandContext, setCommandIfName, setCommandStoreId, setDefaultProperties
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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.
Parameters:
storeId - Integer of the a Store ID
Throws:
ECException

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
Returns:
monetary amount of the base price

getCatEntryPrices

public CatEntryPrices[] getCatEntryPrices()
Returns the price related information of the input catalog entries.
Specified by:
getCatEntryPrices in interface GetContractUnitPriceCmd
Returns:
CatEntryPrices[] return an array of the CatEntryPrices.

getOffer

public OfferAccessBean getOffer()
Returns the offer access bean that was used to determine the price.
Specified by:
getOffer in interface GetContractUnitPriceCmd
Returns:
offer access bean

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
Returns:
an offer ID

getPrice

public MonetaryAmount getPrice()
Returns the actual price of the catalog entry.
Specified by:
getPrice in interface GetContractUnitPriceCmd
Returns:
monetar amount of the price

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
Returns:
term condition ID

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
Returns:
trading ID

performExecute

public void performExecute()
                    throws ECException
Executes main business logic of the command.
Specified by:
performExecute in interface ECCommand
Overrides:
performExecute in class AbstractECTargetableCommand
Throws:
ECException

reset

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

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.
Throws:
ECException

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:
ECException - If no eligible trading agreements can be obtained (ERR_NO_ELIGIBLE_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.
Throws:
ECException

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.
Parameters:
storeId - the store ID
Throws:
ECException

setCatEntryId

public void setCatEntryId(java.lang.Long anCatEntryId)
Sets the id of the input catalog entry.
Specified by:
setCatEntryId in interface GetContractUnitPriceCmd
Parameters:
anCatEntryId - the catEntry ID

setCatEntryPrices

public void setCatEntryPrices(CatEntryPrices[] aCatEntryPrices)
Sets the information of one or more catalog entries (Future Support).
Specified by:
setCatEntryPrices in interface GetContractUnitPriceCmd
Parameters:
aCatEntryPrices - the array of CatEntryPrices

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
Parameters:
astrCurrency - the currency

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
Parameters:
aErrorMode - true if throw exceptions

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
Parameters:
anMemberId - the member ID

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
Parameters:
aOfferIds - all offer IDs

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
Parameters:
aQuantityAmount - the 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
Parameters:
aStoreId - the store ID

setTradingIds

public void setTradingIds(java.lang.Long[] aTradingIds)
Sets the ids of the input trading agreements (Optional).
Specified by:
setTradingIds in interface GetContractUnitPriceCmd
Parameters:
aTradingIds - an array of trading IDs

validateParameters

public void validateParameters()
                        throws ECException
Checks mandatory parameters.
Specified by:
validateParameters in interface ECCommand
Overrides:
validateParameters in class AbstractECTargetableCommand
Throws:
ECException