com.ibm.commerce.negotiation.commands
Class DetermineWinnersCmdImpl

com.ibm.commerce.negotiation.commands.DetermineWinnersCmdImpl
All Implemented Interfaces:
DetermineWinnersCmd, ECCommand

public class DetermineWinnersCmdImpl
implements DetermineWinnersCmd

Determines the winning auto-bids's next bidding price for an auction.


Field Summary
static java.lang.String COPYRIGHT
           
protected  java.util.Vector winners
           
 
Fields inherited from interface com.ibm.commerce.negotiation.commands.DetermineWinnersCmd
defaultCommandClassName, NAME
 
Constructor Summary
DetermineWinnersCmdImpl()
          DetermineWinnersCmdImpl default constructor.
 
Method Summary
protected  java.math.BigDecimal calculateNextBidValue(java.math.BigDecimal currMaxBidValue)
          Calculates the next bid value based on the current maximum bid value and the bid rule range/increment.
protected  com.ibm.commerce.negotiation.commands.BidDataLight findNextLoser(int start, double availQuant)
          Given the index of a winning auto bid, to find the closest loser(the runner-up) which is defined as the bid that is going to win if this winning autobid doesn't exist.
protected  java.util.Vector getActiveBids()
          Get the list of active bids for processing.
protected  ControlRuleAccessBean getBidRule()
          A singleton method for retrieving Control Rule Access Bean.
protected  java.lang.Long getBidRuleId()
          Gets the auction's Bid Rule Id.
protected  java.math.BigDecimal getDefaultBidIncrement()
          Return a default bid increment value.
protected  java.math.BigDecimal getDefaultMinBidValue()
          Return a default minimum bid value.
protected  java.lang.String getErrorTaskName()
          returns error task name that will be returned by the exceptions.
protected  java.lang.Double getQuantityOnAuction()
          Get the quantity available for auction.
 java.util.Vector getWinners()
          Get the list of auto bids that are winning.
protected  void handleException(java.lang.Exception e)
          Formats an ECException based on the input exception value.
 boolean isReadyToCallExecute()
          Verifies that the this command is ready to be executed.
 void performExecute()
          For all active auto bids, determine if a new bid value should be submitted on behalf of the auto bid, in order to put the auto bid in a winning position.
 void reset()
          Resets this command to allow for future reuse.
 void setActiveBids(java.util.Vector bids)
          Sets the list of active bids to be processed.
 void setBidRuleId(java.lang.Long id)
          Sets the auction Bid Rule id
 void setErrorTaskName(java.lang.String errorTaskName)
          Set error task name that will be returned by the exceptions.
 void setQuantityOnAuction(java.lang.Double quantity)
          Set the quantity available for auction.
 void setWinners(java.util.Vector newWinners)
          Set the list of autobids that are currently winning.
static java.lang.String traceBid(com.ibm.commerce.negotiation.commands.BidDataLight bid)
          Return a string that shows the information about a bid.
 
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, validateParameters
 

Field Detail

COPYRIGHT

public static final java.lang.String COPYRIGHT

winners

protected java.util.Vector winners
Constructor Detail

DetermineWinnersCmdImpl

public DetermineWinnersCmdImpl()
DetermineWinnersCmdImpl default constructor.
Method Detail

calculateNextBidValue

protected java.math.BigDecimal calculateNextBidValue(java.math.BigDecimal currMaxBidValue)
                                              throws ECException
Calculates the next bid value based on the current maximum bid value and the bid rule range/increment.
Parameters:
BigDecimal - currMaxBidValue - Current maximum bid value.
Returns:
BigDecimal - Calculated next bid value
Throws:
ECException - - Invalid input bid value or, error during bid control rule bean lookup.

findNextLoser

protected com.ibm.commerce.negotiation.commands.BidDataLight findNextLoser(int start,
                                                                           double availQuant)
Given the index of a winning auto bid, to find the closest loser(the runner-up) which is defined as the bid that is going to win if this winning autobid doesn't exist.
Parameters:
start - int
availQuant - double
Returns:
com.ibm.commerce.negotiation.objimpl.BidDataLight

getActiveBids

protected java.util.Vector getActiveBids()
Get the list of active bids for processing.
Returns:
java.util.Vector

getBidRule

protected ControlRuleAccessBean getBidRule()
                                    throws java.lang.Exception
A singleton method for retrieving Control Rule Access Bean.
Returns:
ControlRuleAccessBean - Control rule access bean, or null if current bid rule id is invalid.
Throws:
java.lang.Exception - - FinderException or data base retrieval exception.

getBidRuleId

protected java.lang.Long getBidRuleId()
Gets the auction's Bid Rule Id.
Parameters:
Long - - Bid rule Id.

getDefaultBidIncrement

protected java.math.BigDecimal getDefaultBidIncrement()
Return a default bid increment value. This method should be overrided if the the returned default value is not acceptable.
Returns:
java.math.BigDecimal

getDefaultMinBidValue

protected java.math.BigDecimal getDefaultMinBidValue()
Return a default minimum bid value. This method should be overrided if the the returned default value is not acceptable.
Returns:
java.math.BigDecimal

getErrorTaskName

protected java.lang.String getErrorTaskName()
returns error task name that will be returned by the exceptions.
Returns:
java.lang.String - Error task name

getQuantityOnAuction

protected java.lang.Double getQuantityOnAuction()
Get the quantity available for auction.
Returns:
Double - Quantity on auction.

getWinners

public java.util.Vector getWinners()
Get the list of auto bids that are winning.
Returns:
java.util.Vector

handleException

protected void handleException(java.lang.Exception e)
                        throws ECException
Formats an ECException based on the input exception value.
Parameters:
e - Exception - The exception instance to be formatted.
Throws:
ECException -  

isReadyToCallExecute

public boolean isReadyToCallExecute()
Verifies that the this command is ready to be executed.
Returns:
boolean =true if command is ready, otherwise false.

performExecute

public void performExecute()
                    throws ECException
For all active auto bids, determine if a new bid value should be submitted on behalf of the auto bid, in order to put the auto bid in a winning position.
Specified by:
performExecute in interface ECCommand
Following copied from interface: com.ibm.commerce.command.ECCommand
Throws:
com.ibm.commerce.command.CommandException - The superclass for all ECExceptions.

reset

public void reset()
Resets this command to allow for future reuse.

setActiveBids

public void setActiveBids(java.util.Vector bids)
Sets the list of active bids to be processed.
Specified by:
setActiveBids in interface DetermineWinnersCmd
Parameters:
bids - Vector - Active bids list

setBidRuleId

public void setBidRuleId(java.lang.Long id)
Sets the auction Bid Rule id
Specified by:
setBidRuleId in interface DetermineWinnersCmd
Parameters:
id - Long - Bid rule id

setErrorTaskName

public void setErrorTaskName(java.lang.String errorTaskName)
Set error task name that will be returned by the exceptions.
Specified by:
setErrorTaskName in interface DetermineWinnersCmd
Parameters:
errorTaskName - java.lang.String

setQuantityOnAuction

public void setQuantityOnAuction(java.lang.Double quantity)
Set the quantity available for auction.
Specified by:
setQuantityOnAuction in interface DetermineWinnersCmd
Parameters:
quantity - Double - Quantity available for auction.

setWinners

public void setWinners(java.util.Vector newWinners)
Set the list of autobids that are currently winning.
Specified by:
setWinners in interface DetermineWinnersCmd
Parameters:
newWinners - java.util.Vector

traceBid

public static java.lang.String traceBid(com.ibm.commerce.negotiation.commands.BidDataLight bid)
Return a string that shows the information about a bid.
Parameters:
bid - BidDataLight
Returns:
String