edu.rice.rubis.beans
Class UserBean

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

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

UserBean 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 users (
    id            INTEGER UNSIGNED NOT NULL UNIQUE,
    firstname     VARCHAR(20),
    lastname      VARCHAR(20),
    nickname      VARCHAR(20) NOT NULL UNIQUE,
    password      VARCHAR(20) NOT NULL,
    email         VARCHAR(50) NOT NULL,
    rating        INTEGER,
    balance       FLOAT,
    creation_date DATETIME,
    region        INTEGER,
    PRIMARY KEY(id),
    INDEX auth (nickname,password),
    INDEX region_id (region)
 );
 

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

Field Summary
 float balance
           
 java.lang.String creationDate
           
 java.lang.String email
           
protected  javax.ejb.EntityContext entityContext
           
 java.lang.String firstName
           
 java.lang.Integer id
           
 java.lang.String lastName
           
 java.lang.String nickName
           
 java.lang.String password
           
 int rating
           
 java.lang.Integer regionId
           
 
Constructor Summary
UserBean()
           
 
Method Summary
 void ejbActivate()
          This method is empty because persistence is managed by the container
 UserPK ejbCreate(java.lang.String userFirstName, java.lang.String userLastName, java.lang.String userNickName, java.lang.String userEmail, java.lang.String userPassword, java.lang.Integer userRegionId)
          This method is used to create a new User 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 userFirstName, java.lang.String userLastName, java.lang.String userNickName, java.lang.String userEmail, java.lang.String userPassword, java.lang.Integer userRegionId)
          This method does currently nothing
 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 getBalance()
          Get user's account current balance.
 java.lang.String getCreationDate()
          Get user creation date.
 java.lang.String getEmail()
          Get user email address.
 java.lang.String getFirstName()
          Get user first name.
 java.lang.String getHTMLGeneralUserInformation()
          Returns a string displaying general information about the user.
 java.lang.Integer getId()
          Get user's id.
 java.lang.String getLastName()
          Get user last name.
 java.lang.String getNickName()
          Get user nick name.
 java.lang.String getPassword()
          Get user password.
 int getRating()
          Get user rating.
 java.lang.Integer getRegionId()
          Get region identifier of user's region.
 boolean isModified()
          Returns true if the beans has been modified.
 void setBalance(float newBalance)
          Set user's account current balance.
 void setCreationDate(java.lang.String newCreationDate)
          Set a new creation date for this user account
 void setEmail(java.lang.String newEmail)
          Set user's email address
 void setEntityContext(javax.ejb.EntityContext context)
          Sets the associated entity context.
 void setFirstName(java.lang.String newName)
          Set user's first name
 void setLastName(java.lang.String newName)
          Set user's last name
 void setNickName(java.lang.String newName)
          Set user's nick name
 void setPassword(java.lang.String newPassword)
          Set user's password
 void setRating(int newRating)
          Set user rating.
 void setRegionId(java.lang.Integer id)
          Set a new region identifier.
 void unsetEntityContext()
          Unsets the associated entity context.
 void updateRating(int diff)
          Update the current rating by adding a new value to it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

entityContext

protected javax.ejb.EntityContext entityContext

id

public java.lang.Integer id

firstName

public java.lang.String firstName

lastName

public java.lang.String lastName

nickName

public java.lang.String nickName

password

public java.lang.String password

email

public java.lang.String email

rating

public int rating

balance

public float balance

creationDate

public java.lang.String creationDate

regionId

public java.lang.Integer regionId
Constructor Detail

UserBean

public UserBean()
Method Detail

getId

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

getFirstName

public java.lang.String getFirstName()
                              throws java.rmi.RemoteException
Get user first name.
Returns:
user first name
Throws:
java.rmi.RemoteException - if an error occurs

getLastName

public java.lang.String getLastName()
                             throws java.rmi.RemoteException
Get user last name.
Returns:
user last name
Throws:
java.rmi.RemoteException - if an error occurs

getNickName

public java.lang.String getNickName()
                             throws java.rmi.RemoteException
Get user nick name. This name is unique for each user and is used for login.
Returns:
user nick name
Throws:
java.rmi.RemoteException - if an error occurs

getPassword

public java.lang.String getPassword()
                             throws java.rmi.RemoteException
Get user password.
Returns:
user password
Throws:
java.rmi.RemoteException - if an error occurs

getEmail

public java.lang.String getEmail()
                          throws java.rmi.RemoteException
Get user email address.
Returns:
user email address
Throws:
java.rmi.RemoteException - if an error occurs

getRating

public int getRating()
              throws java.rmi.RemoteException
Get user rating. The higher the rating is, the most reliable the user is.
Returns:
user rating
Throws:
java.rmi.RemoteException - if an error occurs

getBalance

public float getBalance()
                 throws java.rmi.RemoteException
Get user's account current balance. This account is used when a user want to sell items. There is a charge for each item to sell.
Returns:
user's account current balance
Throws:
java.rmi.RemoteException - if an error occurs

getCreationDate

public java.lang.String getCreationDate()
                                 throws java.rmi.RemoteException
Get user creation date.
Returns:
user creation date
Throws:
java.rmi.RemoteException - if an error occurs

getRegionId

public java.lang.Integer getRegionId()
                              throws java.rmi.RemoteException
Get region identifier of user's region.
Returns:
region id of the user
Throws:
java.rmi.RemoteException - if an error occurs

setFirstName

public void setFirstName(java.lang.String newName)
                  throws java.rmi.RemoteException
Set user's first name
Parameters:
newName - user first name
Throws:
java.rmi.RemoteException - if an error occurs

setLastName

public void setLastName(java.lang.String newName)
                 throws java.rmi.RemoteException
Set user's last name
Parameters:
newName - user last name
Throws:
java.rmi.RemoteException - if an error occurs

setNickName

public void setNickName(java.lang.String newName)
                 throws java.rmi.RemoteException
Set user's nick name
Parameters:
newName - user nick name
Throws:
java.rmi.RemoteException - if an error occurs

setPassword

public void setPassword(java.lang.String newPassword)
                 throws java.rmi.RemoteException
Set user's password
Parameters:
newPassword - a String value
Throws:
java.rmi.RemoteException - if an error occurs

setEmail

public void setEmail(java.lang.String newEmail)
              throws java.rmi.RemoteException
Set user's email address
Parameters:
newEmail - a String value
Throws:
java.rmi.RemoteException - if an error occurs

setCreationDate

public void setCreationDate(java.lang.String newCreationDate)
                     throws java.rmi.RemoteException
Set a new creation date for this user account
Parameters:
newCreationDate - a String value
Throws:
java.rmi.RemoteException - if an error occurs

setRegionId

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

setRating

public void setRating(int newRating)
               throws java.rmi.RemoteException
Set user rating. The higher the rating is, the most reliable the user is.
Parameters:
newRating - new user rating
Throws:
java.rmi.RemoteException - if an error occurs

updateRating

public void updateRating(int diff)
                  throws java.rmi.RemoteException
Update the current rating by adding a new value to it. This value can be negative if someone wants to decrease the user rating.
Parameters:
diff - value to add to the rating
Throws:
java.rmi.RemoteException - if an error occurs

setBalance

public void setBalance(float newBalance)
                throws java.rmi.RemoteException
Set user's account current balance. This account is used when a user want to sell items. There is a charge for each sold item.
Parameters:
newBalance - set user's account current balance
Throws:
java.rmi.RemoteException - if an error occurs

getHTMLGeneralUserInformation

public java.lang.String getHTMLGeneralUserInformation()
                                               throws java.rmi.RemoteException
Returns a string displaying general information about the user. The string contains HTML tags.
Returns:
string containing general user information
Throws:
java.rmi.RemoteException - if an error occurs

ejbCreate

public UserPK ejbCreate(java.lang.String userFirstName,
                        java.lang.String userLastName,
                        java.lang.String userNickName,
                        java.lang.String userEmail,
                        java.lang.String userPassword,
                        java.lang.Integer userRegionId)
                 throws javax.ejb.CreateException,
                        java.rmi.RemoteException,
                        javax.ejb.RemoveException
This method is used to create a new User Bean. The user id and the creationDate are automatically set by the system.
Parameters:
userFirstName - user's first name
userLastName - user's last name
userNickName - user's nick name
userEmail - email address of the user
userPassword - user's password
userRegionId - region id where the user lives
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.String userFirstName,
                          java.lang.String userLastName,
                          java.lang.String userNickName,
                          java.lang.String userEmail,
                          java.lang.String userPassword,
                          java.lang.Integer userRegionId)
This method does currently nothing

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

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

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

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


Copyright © 2003 - ObjectWeb Consortium - All Rights Reserved.