edu.rice.rubis.beans
Class CommentBean

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

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

BidBean 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 comments (
   id           INTEGER UNSIGNED NOT NULL UNIQUE,
   from_user_id INTEGER,
   to_user_id   INTEGER,
   item_id      INTEGER,
   rating       INTEGER,
   date         DATETIME,
   comment      TEXT
   PRIMARY KEY(id),
   INDEX from_user (from_user_id),
   INDEX to_user (to_user_id),
   INDEX item (item_id)
 );
 

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

Field Summary
 java.lang.String comment
           
 java.lang.String date
           
 java.lang.Integer fromUserId
           
 java.lang.Integer id
           
 java.lang.Integer itemId
           
 int rating
           
 java.lang.Integer toUserId
           
 
Constructor Summary
CommentBean()
           
 
Method Summary
 void ejbActivate()
          This method is empty because persistence is managed by the container
 CommentPK ejbCreate(java.lang.Integer FromUserId, java.lang.Integer ToUserId, java.lang.Integer ItemId, int Rating, java.lang.String Comment)
          This method is used to create a new Comment 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.Integer FromUserId, java.lang.Integer ToUserId, java.lang.Integer ItemId, int Rating, java.lang.String Comment)
          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
 java.lang.String getComment()
          Get the comment text.
 java.lang.String getDate()
          Time of the Comment in the format 'YYYY-MM-DD hh:mm:ss'
 java.lang.Integer getFromUserId()
          Get the user id of the author of the comment
 java.lang.Integer getId()
          Get comment's id.
 java.lang.Integer getItemId()
          Get the item id which is the primary key in the items table.
 float getRating()
          Get the rating associated to this comment.
 java.lang.Integer getToUserId()
          Get the user id of the user this comment is about.
 boolean isModified()
          Returns true if the beans has been modified.
 java.lang.String printComment(java.lang.String userName)
          Display comment information as an HTML table row
 void setComment(java.lang.String newComment)
          Set a new comment for ToUserId from FromUserId.
 void setDate(java.lang.String newDate)
          Set a new date for this comment
 void setEntityContext(javax.ejb.EntityContext context)
          Sets the associated entity context.
 void setFromUserId(java.lang.Integer id)
          Set a new user identifier for the author of the comment.
 void setItemId(java.lang.Integer id)
          Set a new item identifier.
 void setRating(int Rating)
          Set a new rating for the ToUserId.
 void setToUserId(java.lang.Integer id)
          Set a new user identifier for the user this comment is about.
 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

fromUserId

public java.lang.Integer fromUserId

toUserId

public java.lang.Integer toUserId

itemId

public java.lang.Integer itemId

rating

public int rating

date

public java.lang.String date

comment

public java.lang.String comment
Constructor Detail

CommentBean

public CommentBean()
Method Detail

getId

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

getFromUserId

public java.lang.Integer getFromUserId()
                                throws java.rmi.RemoteException
Get the user id of the author of the comment
Returns:
author user id
Throws:
java.rmi.RemoteException - if an error occurs

getToUserId

public java.lang.Integer getToUserId()
                              throws java.rmi.RemoteException
Get the user id of the user this comment is about.
Returns:
user id this comment is about
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

getRating

public float getRating()
                throws java.rmi.RemoteException
Get the rating associated to this comment.
Returns:
rating
Throws:
java.rmi.RemoteException - if an error occurs

getDate

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

getComment

public java.lang.String getComment()
                            throws java.rmi.RemoteException
Get the comment text.
Returns:
comment text
Throws:
java.rmi.RemoteException - if an error occurs

setFromUserId

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

setToUserId

public void setToUserId(java.lang.Integer id)
                 throws java.rmi.RemoteException
Set a new user identifier for the user this comment is about. This id must match the primary key of the users table.
Parameters:
id - user id comment is about
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

setRating

public void setRating(int Rating)
               throws java.rmi.RemoteException
Set a new rating for the ToUserId.
Parameters:
Rating - an int 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 comment
Parameters:
newDate - comment date
Throws:
java.rmi.RemoteException - if an error occurs

setComment

public void setComment(java.lang.String newComment)
                throws java.rmi.RemoteException
Set a new comment for ToUserId from FromUserId.
Parameters:
newComment - Comment
Throws:
java.rmi.RemoteException - if an error occurs

ejbCreate

public CommentPK ejbCreate(java.lang.Integer FromUserId,
                           java.lang.Integer ToUserId,
                           java.lang.Integer ItemId,
                           int Rating,
                           java.lang.String Comment)
                    throws javax.ejb.CreateException,
                           java.rmi.RemoteException,
                           javax.ejb.RemoveException
This method is used to create a new Comment Bean. The date is automatically set to the current date when the method is called.
Parameters:
FromUserId - user id of the comment author, must match the primary key of table users
ToUserId - user id of the user this comment is about, must match the primary key of table users
ItemId - item id, must match the primary key of table items
Rating - user (ToUserId) rating given by the author (FromUserId)
Comment - comment text
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 FromUserId,
                          java.lang.Integer ToUserId,
                          java.lang.Integer ItemId,
                          int Rating,
                          java.lang.String Comment)
This method just set an internal flag to reload the id generated by the DB

ejbLoad

public void ejbLoad()
             throws java.rmi.RemoteException
Persistence is managed by the container and the bean becomes up to date
Specified by:
ejbLoad in interface javax.ejb.EntityBean

ejbStore

public void ejbStore()
              throws java.rmi.RemoteException
Persistence is managed by the container and the bean becomes up to date
Specified by:
ejbStore in interface javax.ejb.EntityBean

ejbActivate

public void ejbActivate()
                 throws java.rmi.RemoteException
This method is empty because persistence is managed by the container
Specified by:
ejbActivate in interface javax.ejb.EntityBean

ejbPassivate

public void ejbPassivate()
                  throws java.rmi.RemoteException
This method is empty because persistence is managed by the container
Specified by:
ejbPassivate in interface javax.ejb.EntityBean

ejbRemove

public void ejbRemove()
               throws java.rmi.RemoteException,
                      javax.ejb.RemoveException
This method is empty because persistence is managed by the container
Specified by:
ejbRemove in interface javax.ejb.EntityBean

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.

isModified

public boolean isModified()
Returns true if the beans has been modified. It prevents the EJB server from reloading a bean that has not been modified.
Returns:
a boolean value

printComment

public java.lang.String printComment(java.lang.String userName)
                              throws java.rmi.RemoteException
Display comment 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.