|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.rice.rubis.beans.ItemBean
ItemBean is an entity bean with "container managed persistence". The state of an instance is stored into a relational database. The following table should exist:
CREATE TABLE items ( id INTEGER UNSIGNED NOT NULL UNIQUE, name VARCHAR(100), description TEXT, initial_price FLOAT UNSIGNED NOT NULL, quantity INTEGER UNSIGNED NOT NULL, reserve_price FLOAT UNSIGNED DEFAULT 0, buy_now FLOAT UNSIGNED DEFAULT 0, nb_of_bids INTEGER UNSIGNED DEFAULT 0, max_bid FLOAT UNSIGNED DEFAULT 0, start_date DATETIME, end_date DATETIME, seller INTEGER, category INTEGER, PRIMARY KEY(id), INDEX seller_id (seller), INDEX category_id (category) );
Field Summary | |
float |
buyNow
|
java.lang.Integer |
categoryId
|
java.lang.String |
description
|
java.lang.String |
endDate
|
java.lang.Integer |
id
|
float |
initialPrice
|
float |
maxBid
|
java.lang.String |
name
|
int |
nbOfBids
|
int |
quantity
|
float |
reservePrice
|
java.lang.Integer |
sellerId
|
java.lang.String |
startDate
|
Constructor Summary | |
ItemBean()
|
Method Summary | |
void |
addOneBid()
Add one bid for this item |
void |
ejbActivate()
This method is empty because persistence is managed by the container |
ItemPK |
ejbCreate(java.lang.String itemName,
java.lang.String itemDescription,
float itemInitialPrice,
int itemQuantity,
float itemReservePrice,
float itemBuyNow,
int duration,
java.lang.Integer itemSellerId,
java.lang.Integer itemCategoryId)
This method is used to create a new Item Bean. |
void |
ejbLoad()
Persistence is managed by the container and the bean becomes up to date |
void |
ejbPassivate()
This method is empty because persistence is managed by the container |
void |
ejbPostCreate(java.lang.String itemName,
java.lang.String itemDescription,
float itemInitialPrice,
int itemQuantity,
float itemReservePrice,
float itemBuyNow,
int duration,
java.lang.Integer itemSellerId,
java.lang.Integer itemCategoryId)
This method just set an internal flag to reload the id generated by the DB |
void |
ejbRemove()
This method is empty because persistence is managed by the container |
void |
ejbStore()
Persistence is managed by the container and the bean becomes up to date |
float |
getBuyNow()
Get item Buy Now price set by the seller. |
java.lang.Integer |
getCategoryId()
Give the category id of the item |
java.lang.String |
getCategoryName()
Get the category name by finding the Bean corresponding to the category Id. |
java.lang.String |
getDescription()
Get item description . |
java.lang.String |
getEndDate()
End date of the auction in the format 'YYYY-MM-DD hh:mm:ss' |
java.lang.Integer |
getId()
Get item id. |
float |
getInitialPrice()
Get item initial price set by the seller. |
float |
getMaxBid()
Get item maximum bid (if any) for this item. |
java.lang.String |
getName()
Get item name. |
int |
getNbOfBids()
Get number of bids for this item. |
int |
getQuantity()
Get how many of this item are to be sold. |
float |
getReservePrice()
Get item reserve price set by the seller. |
java.lang.Integer |
getSellerId()
Give the user id of the seller |
java.lang.String |
getSellerNickname()
Get the seller's nickname by finding the Bean corresponding to the user. |
java.lang.String |
getStartDate()
Start date of the auction in the format 'YYYY-MM-DD hh:mm:ss' |
boolean |
isModified()
Returns true if the beans has been modified. |
java.lang.String |
printItem()
Display item information as an HTML table row |
java.lang.String |
printItemDescriptionToBuyNow(int userId)
Display item information for the Buy Now servlet |
java.lang.String |
printItemUserHasBidOn(float bidMaxBid)
Display item information for the AboutMe servlet |
java.lang.String |
printSell()
Display item information as an HTML table row |
java.lang.String |
printUserBoughtItem(int qty)
Display item information for the AboutMe servlet |
java.lang.String |
printUserWonItem()
Display item information for the AboutMe servlet |
void |
setBuyNow(float newBuyNow)
Set a new Buy Now price for the item |
void |
setCategoryId(java.lang.Integer id)
Set a new category identifier. |
void |
setDescription(java.lang.String newDescription)
Set a new item description |
void |
setEndDate(java.lang.String newDate)
Set a new ending date for the auction |
void |
setEntityContext(javax.ejb.EntityContext context)
Sets the associated entity context. |
void |
setInitialPrice(float newInitialPrice)
Set a new initial price for the item |
void |
setMaxBid(float newMaxBid)
Set item maximum bid. |
void |
setName(java.lang.String newName)
Set a new item name |
void |
setNbOfBids(int newNbOfBids)
Set the number of bids for this item |
void |
setQuantity(int qty)
Set a new item quantity |
void |
setReservePrice(float newReservePrice)
Set a new reserve price for the item |
void |
setSellerId(java.lang.Integer id)
Set a new seller identifier. |
void |
setStartDate(java.lang.String newDate)
Set a new beginning date for the auction |
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 |
public java.lang.Integer id
public java.lang.String name
public java.lang.String description
public float initialPrice
public int quantity
public float reservePrice
public float buyNow
public int nbOfBids
public float maxBid
public java.lang.String startDate
public java.lang.String endDate
public java.lang.Integer sellerId
public java.lang.Integer categoryId
Constructor Detail |
public ItemBean()
Method Detail |
public java.lang.Integer getId()
public java.lang.String getName()
public java.lang.String getDescription()
public float getInitialPrice()
public int getQuantity()
public float getReservePrice()
public float getBuyNow()
public float getMaxBid()
SELECT MAX(bid) FROM bids WHERE item_id=?
public int getNbOfBids()
SELECT COUNT(*) FROM bids WHERE item_id=?
public java.lang.String getStartDate()
public java.lang.String getEndDate()
public java.lang.Integer getSellerId()
public java.lang.Integer getCategoryId()
public java.lang.String getSellerNickname()
public java.lang.String getCategoryName()
public void setName(java.lang.String newName)
newName
- item namepublic void setDescription(java.lang.String newDescription)
newDescription
- item descriptionpublic void setInitialPrice(float newInitialPrice)
newInitialPrice
- item initial pricepublic void setQuantity(int qty)
qty
- item quantitypublic void setReservePrice(float newReservePrice)
newReservePrice
- item reserve pricepublic void setBuyNow(float newBuyNow)
newBuyNow
- item Buy Now pricepublic void setMaxBid(float newMaxBid)
newMaxBid
- new maximum bidpublic void setNbOfBids(int newNbOfBids)
newNbOfBids
- new number of bidspublic void addOneBid()
public void setStartDate(java.lang.String newDate)
newDate
- auction new beginning datepublic void setEndDate(java.lang.String newDate)
newDate
- auction new ending datepublic void setSellerId(java.lang.Integer id)
id
- seller idpublic void setCategoryId(java.lang.Integer id)
id
- category idpublic ItemPK ejbCreate(java.lang.String itemName, java.lang.String itemDescription, float itemInitialPrice, int itemQuantity, float itemReservePrice, float itemBuyNow, int duration, java.lang.Integer itemSellerId, java.lang.Integer itemCategoryId) throws javax.ejb.CreateException
itemName
- short item designationitemDescription
- long item description, usually an HTML fileitemInitialPrice
- initial price fixed by the selleritemQuantity
- number to sell (of this item)itemReservePrice
- reserve price (minimum price the seller really wants to sell)itemBuyNow
- price if a user wants to buy the item immediatlyduration
- duration of the auction in days (start date is when the method is called and end date is computed according to the duration)itemSellerId
- seller id, must match the primary key of table usersitemCategoryId
- category id, must match the primary key of table categoriesjavax.ejb.CreateException
- if an error occurspublic void ejbPostCreate(java.lang.String itemName, java.lang.String itemDescription, float itemInitialPrice, int itemQuantity, float itemReservePrice, float itemBuyNow, int duration, java.lang.Integer itemSellerId, java.lang.Integer itemCategoryId)
public void ejbLoad() throws java.rmi.RemoteException
ejbLoad
in interface javax.ejb.EntityBean
public void ejbStore() throws java.rmi.RemoteException
ejbStore
in interface javax.ejb.EntityBean
public void ejbActivate()
ejbActivate
in interface javax.ejb.EntityBean
public void ejbPassivate()
ejbPassivate
in interface javax.ejb.EntityBean
public void ejbRemove()
ejbRemove
in interface javax.ejb.EntityBean
public void setEntityContext(javax.ejb.EntityContext context)
setEntityContext
in interface javax.ejb.EntityBean
context
- An EntityContext interface for the instance. The instance should
store the reference to the context in an instance variable.javax.ejb.EJBException
- Thrown by the method to indicate a failure
caused by a system-level error.public void unsetEntityContext()
unsetEntityContext
in interface javax.ejb.EntityBean
javax.ejb.EJBException
- Thrown by the method to indicate a failure
caused by a system-level error.public boolean isModified()
boolean
valuepublic java.lang.String printItem()
String
containing HTML codepublic java.lang.String printUserBoughtItem(int qty) throws java.rmi.RemoteException
String
containing HTML codejava.rmi.RemoteException
- if an error occurspublic java.lang.String printItemUserHasBidOn(float bidMaxBid)
String
containing HTML code (Warning last link must be completed by servlet)public java.lang.String printSell()
String
containing HTML codepublic java.lang.String printUserWonItem()
String
containing HTML codepublic java.lang.String printItemDescriptionToBuyNow(int userId)
String
containing HTML code
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |