edu.rice.rubis.beans
Class BidBean

java.lang.Object
  |
  +--edu.rice.rubis.beans.BidBean
All Implemented Interfaces:
javax.ejb.EnterpriseBean, javax.ejb.EntityBean, java.io.Serializable

public class BidBean
extends java.lang.Object
implements javax.ejb.EntityBean

BidBean is an entity bean with "bean managed persistence". The state of an instance is stored into a relational database. The following table should exist:

 CREATE TABLE bids (
    id      INTEGER UNSIGNED NOT NULL UNIQUE,
    user_id INTEGER,
    item_id INTEGER,
    qty     INTEGER,
    bid     FLOAT UNSIGNED NOT NULL,
    max_bid FLOAT UNSIGNED NOT NULL,
    date    DATETIME
   INDEX item (item_id),
   INDEX user (user_id)
 );
 

Version:
1.0
Author:
Emmanuel Cecchet and Julie Marguerite
See Also:
Serialized Form

Field Summary
 float bid
           
 java.lang.String date
           
 java.lang.Integer id
           
 java.lang.Integer itemId
           
 float maxBid
           
 int qty
           
 java.lang.Integer userId
           
 
Constructor Summary
BidBean()
           
 
Method Summary
 void ejbActivate()
          Mandatory methods
 BidPK ejbCreate(java.lang.Integer bidUserId, java.lang.Integer bidItemId, float userBid, float userMaxBid, int quantity)
          This method is used to create a new Bid Bean.
 java.util.Collection ejbFindAllBids()
          This method is used to retrieve all bids from the database!
 java.util.Collection ejbFindByItem(java.lang.Integer id)
          This method is used to retrieve all Bid Beans related to one item.
 BidPK ejbFindByPrimaryKey(BidPK id)
          This method is used to retrieve a Bid Bean from its primary key, that is to say its id.
 java.util.Collection ejbFindByUser(java.lang.Integer id)
          This method is used to retrieve all Bid Beans belonging to a specific user.
 void ejbLoad()
          Read the reccord from the database and update the bean.
 void ejbPassivate()
           
 void ejbPostCreate(java.lang.Integer bidUserId, java.lang.Integer bidItemId, float userBid, float userMaxBid, int quantity)
          This method does currently nothing
 void ejbRemove()
          This method delete the record from the database.
 void ejbStore()
          Update the record.
 float getBid()
          Get the bid of the user.
 java.lang.String getBidderNickName()
          Give the nick name of the bidder
 java.sql.Connection getConnection()
          Retieve a connection..
 java.lang.String getDate()
          Time of the Bid in the format 'YYYY-MM-DD hh:mm:ss'
 java.lang.Integer getId()
          Get bid's id.
 java.lang.Integer getItemId()
          Get the item id which is the primary key in the items table.
 float getMaxBid()
          Get the maximum bid wanted by the user.
 int getQuantity()
          Get how many of this item the user wants.
 java.lang.Integer getUserId()
          Get the user id which is the primary key in the users table.
 java.lang.String printBidHistory()
          Display bid history information as an HTML table row
 void setBid(float newBid)
          Set a new bid on the item for the user.
 void setDate(java.lang.String newDate)
          Set a new date for this bid
 void setEntityContext(javax.ejb.EntityContext context)
          Sets the associated entity context.
 void setItemId(java.lang.Integer id)
          Set a new item identifier.
 void setMaxBid(float newBid)
          Set a new maximum bid on the item for the user
 void setQuantity(int Qty)
          Set a new quantity for this bid
 void setUserId(java.lang.Integer id)
          Set a new user identifier.
 void unsetEntityContext()
          Unsets the associated entity context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

public java.lang.Integer id

userId

public java.lang.Integer userId

itemId

public java.lang.Integer itemId

qty

public int qty

bid

public float bid

maxBid

public float maxBid

date

public java.lang.String date
Constructor Detail

BidBean

public BidBean()
Method Detail

getId

public java.lang.Integer getId()
                        throws java.rmi.RemoteException
Get bid's id.
Returns:
bid id
Throws:
java.rmi.RemoteException - if an error occurs

getUserId

public java.lang.Integer getUserId()
                            throws java.rmi.RemoteException
Get the user id which is the primary key in the users table.
Returns:
user id
Throws:
java.rmi.RemoteException - if an error occurs

getItemId

public java.lang.Integer getItemId()
                            throws java.rmi.RemoteException
Get the item id which is the primary key in the items table.
Returns:
item id
Throws:
java.rmi.RemoteException - if an error occurs

getQuantity

public int getQuantity()
                throws java.rmi.RemoteException
Get how many of this item the user wants.
Returns:
quantity of items for this bid.
Throws:
java.rmi.RemoteException - if an error occurs

getBid

public float getBid()
             throws java.rmi.RemoteException
Get the bid of the user.
Returns:
user's bid
Throws:
java.rmi.RemoteException - if an error occurs

getMaxBid

public float getMaxBid()
                throws java.rmi.RemoteException
Get the maximum bid wanted by the user.
Returns:
user's maximum bid
Throws:
java.rmi.RemoteException - if an error occurs

getDate

public java.lang.String getDate()
                         throws java.rmi.RemoteException
Time of the Bid in the format 'YYYY-MM-DD hh:mm:ss'
Returns:
bid time
Throws:
java.rmi.RemoteException - if an error occurs

getBidderNickName

public java.lang.String getBidderNickName()
                                   throws java.rmi.RemoteException
Give the nick name of the bidder
Returns:
bidder's nick name
Throws:
java.rmi.RemoteException - if an error occurs

setUserId

public void setUserId(java.lang.Integer id)
               throws java.rmi.RemoteException
Set a new user identifier. This id must match the primary key of the users table.
Parameters:
id - user id
Throws:
java.rmi.RemoteException - if an error occurs

setItemId

public void setItemId(java.lang.Integer id)
               throws java.rmi.RemoteException
Set a new item identifier. This id must match the primary key of the items table.
Parameters:
id - item id
Throws:
java.rmi.RemoteException - if an error occurs

setQuantity

public void setQuantity(int Qty)
                 throws java.rmi.RemoteException
Set a new quantity for this bid
Parameters:
Qty - quantity
Throws:
java.rmi.RemoteException - if an error occurs

setBid

public void setBid(float newBid)
            throws java.rmi.RemoteException
Set a new bid on the item for the user.
 Warning! This method does not update the maxBid value in the items table
 
Parameters:
newBid - a float value
Throws:
java.rmi.RemoteException - if an error occurs

setMaxBid

public void setMaxBid(float newBid)
               throws java.rmi.RemoteException
Set a new maximum bid on the item for the user
Parameters:
newBid - a float value
Throws:
java.rmi.RemoteException - if an error occurs

setDate

public void setDate(java.lang.String newDate)
             throws java.rmi.RemoteException
Set a new date for this bid
Parameters:
newDate - bid date
Throws:
java.rmi.RemoteException - if an error occurs

getConnection

public java.sql.Connection getConnection()
                                  throws java.lang.Exception
Retieve a connection..
Returns:
connection
Throws:
java.lang.Exception - if an error occurs

ejbFindByPrimaryKey

public BidPK ejbFindByPrimaryKey(BidPK id)
                          throws javax.ejb.FinderException,
                                 java.rmi.RemoteException
This method is used to retrieve a Bid Bean from its primary key, that is to say its id.
Parameters:
id - Bid id (primary key)
Returns:
the Bid primary key if found else null
Throws:
javax.ejb.FinderException - if an error occurs
java.rmi.RemoteException - if an error occurs

ejbFindByItem

public java.util.Collection ejbFindByItem(java.lang.Integer id)
                                   throws javax.ejb.FinderException,
                                          java.rmi.RemoteException
This method is used to retrieve all Bid Beans related to one item. You must provide the item id.
Parameters:
id - item id
Returns:
List of Bids primary keys found (eventually empty)
Throws:
javax.ejb.FinderException - if an error occurs
java.rmi.RemoteException - if an error occurs

ejbFindByUser

public java.util.Collection ejbFindByUser(java.lang.Integer id)
                                   throws javax.ejb.FinderException,
                                          java.rmi.RemoteException
This method is used to retrieve all Bid Beans belonging to a specific user. You must provide the user id.
Parameters:
id - user id
Returns:
List of Bids primary keys found (eventually empty)
Throws:
javax.ejb.FinderException - if an error occurs
java.rmi.RemoteException - if an error occurs

ejbFindAllBids

public java.util.Collection ejbFindAllBids()
                                    throws java.rmi.RemoteException,
                                           javax.ejb.FinderException
This method is used to retrieve all bids from the database!
Returns:
List of all bids primary keys (eventually empty)
Throws:
java.rmi.RemoteException - if an error occurs
javax.ejb.FinderException - if an error occurs

ejbCreate

public BidPK ejbCreate(java.lang.Integer bidUserId,
                       java.lang.Integer bidItemId,
                       float userBid,
                       float userMaxBid,
                       int quantity)
                throws javax.ejb.CreateException,
                       java.rmi.RemoteException,
                       javax.ejb.RemoveException
This method is used to create a new Bid Bean. The date is automatically set to the current date when the method is called.
Parameters:
bidUserId - user id of the bidder, must match the primary key of table users
bidItemId - item id, must match the primary key of table items
userBid - the amount of the user bid
userMaxBid - the maximum amount the user wants to bid
quantity - number of items the user wants to buy
Returns:
pk primary key set to null
Throws:
javax.ejb.CreateException - if an error occurs
java.rmi.RemoteException - if an error occurs
javax.ejb.RemoveException - if an error occurs

ejbPostCreate

public void ejbPostCreate(java.lang.Integer bidUserId,
                          java.lang.Integer bidItemId,
                          float userBid,
                          float userMaxBid,
                          int quantity)
This method does currently nothing

ejbActivate

public void ejbActivate()
                 throws java.rmi.RemoteException
Mandatory methods
Specified by:
ejbActivate in interface javax.ejb.EntityBean

ejbPassivate

public void ejbPassivate()
                  throws java.rmi.RemoteException
Specified by:
ejbPassivate in interface javax.ejb.EntityBean

ejbRemove

public void ejbRemove()
               throws java.rmi.RemoteException,
                      javax.ejb.RemoveException
This method delete the record from the database.
Specified by:
ejbRemove in interface javax.ejb.EntityBean
Throws:
java.rmi.RemoteException - if an error occurs
javax.ejb.RemoveException - if an error occurs

ejbStore

public void ejbStore()
              throws java.rmi.RemoteException
Update the record.
Specified by:
ejbStore in interface javax.ejb.EntityBean
Throws:
java.rmi.RemoteException - if an error occurs

ejbLoad

public void ejbLoad()
             throws java.rmi.RemoteException
Read the reccord from the database and update the bean.
Specified by:
ejbLoad in interface javax.ejb.EntityBean
Throws:
java.rmi.RemoteException - if an error occurs

setEntityContext

public void setEntityContext(javax.ejb.EntityContext context)
                      throws java.rmi.RemoteException
Sets the associated entity context. The container invokes this method on an instance after the instance has been created. This method is called in an unspecified transaction context.
Specified by:
setEntityContext in interface javax.ejb.EntityBean
Parameters:
context - An EntityContext interface for the instance. The instance should store the reference to the context in an instance variable.
Throws:
javax.ejb.EJBException - Thrown by the method to indicate a failure caused by a system-level error.
java.rmi.RemoteException - - This exception is defined in the method signature to provide backward compatibility for enterprise beans written for the EJB 1.0 specification. Enterprise beans written for the EJB 1.1 and higher specification should throw the javax.ejb.EJBException instead of this exception.

unsetEntityContext

public void unsetEntityContext()
                        throws java.rmi.RemoteException
Unsets the associated entity context. The container calls this method before removing the instance. This is the last method that the container invokes on the instance. The Java garbage collector will eventually invoke the finalize() method on the instance. This method is called in an unspecified transaction context.
Specified by:
unsetEntityContext in interface javax.ejb.EntityBean
Throws:
javax.ejb.EJBException - Thrown by the method to indicate a failure caused by a system-level error.
java.rmi.RemoteException - - This exception is defined in the method signature to provide backward compatibility for enterprise beans written for the EJB 1.0 specification. Enterprise beans written for the EJB 1.1 and higher specification should throw the javax.ejb.EJBException instead of this exception.

printBidHistory

public java.lang.String printBidHistory()
                                 throws java.rmi.RemoteException
Display bid history information as an HTML table row
Returns:
a String containing HTML code
Throws:
java.rmi.RemoteException - if an error occurs
Since:
1.0


Copyright © 2003 - ObjectWeb Consortium - All Rights Reserved.