dataabstraction
Class PersistentUser

java.lang.Object
  |
  +--businessmodel.User
        |
        +--dataabstraction.PersistentUser

public class PersistentUser
extends User
implements Persistent, Testable

The PersistentUser class provides the object-relational / relational-object mapping for User objects in the BugTracker application. It handles all persistence issues for User objects. The User objects that are remoted to the BugTracker application and servlet are of the PersistentUser class.


Field Summary
static java.lang.String DROPBYKEY
           
static java.lang.String GETUSERIDS
           
static java.lang.String INSERTUSER
           
static java.lang.String QUERYBYKEY
           
static java.lang.String UPDATEUSER
           
 
Fields inherited from class businessmodel.User
m_emailAddress, m_faxNumber, m_firstName, m_lastName, m_phoneNumber, m_privLevel, m_userID
 
Constructor Summary
PersistentUser()
          Default constructor.
PersistentUser(java.lang.String uid)
          Constructor.
 
Method Summary
 void commit(java.lang.String userid)
          Attempt to store updates made to a user record
 void drop()
          Delete the data from the persistent store for this user.
 void fetch()
          Fetch the user object from the persistent store based on the user id
protected  void getDatabaseConnection()
          This method ensures that the JDBC driver is loaded and we have a connection to the database.
 java.lang.String[] getUserIDList()
          get all user ids
 void insert()
          Insert the user information into the database as a new user
 boolean rowExists()
          indicates whether the user is stored in the database or not
 boolean TestUnit()
          TestUnit implemented to support test harness
 java.lang.String toString()
          Debug method; provides a text representation of the internal User state
 void update()
          Update the user information in the database
 
Methods inherited from class businessmodel.User
getEmail, getFax, getFirstName, getLastName, getPhone, getPriv, getUserID, setEmail, setFax, setFirstName, setLastName, setPhone, setPriv, setUserID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

QUERYBYKEY

public static final java.lang.String QUERYBYKEY

DROPBYKEY

public static final java.lang.String DROPBYKEY

INSERTUSER

public static final java.lang.String INSERTUSER

UPDATEUSER

public static final java.lang.String UPDATEUSER

GETUSERIDS

public static final java.lang.String GETUSERIDS
Constructor Detail

PersistentUser

public PersistentUser()
Default constructor. Ensures that there is a connection to the data source.

PersistentUser

public PersistentUser(java.lang.String uid)
Constructor. Assigns user id, ensures that there is a connection to the data source.
Method Detail

getDatabaseConnection

protected void getDatabaseConnection()
                              throws java.sql.SQLException
This method ensures that the JDBC driver is loaded and we have a connection to the database. The first time it's called, it gets the driver name and datasource URL from the application properties and loads the database connection. Subsequent calls to this method are essentially no-ops since the connection has already been established.

fetch

public void fetch()
           throws java.sql.SQLException
Fetch the user object from the persistent store based on the user id
Specified by:
fetch in interface Persistent
Throws:
java.sql.SQLException -  

drop

public void drop()
          throws java.sql.SQLException
Delete the data from the persistent store for this user. exception java.sql.SQLException
Specified by:
drop in interface Persistent

insert

public void insert()
            throws java.sql.SQLException
Insert the user information into the database as a new user
Specified by:
insert in interface Persistent
Throws:
java.sql.SQLException -  

update

public void update()
            throws java.sql.SQLException
Update the user information in the database
Specified by:
update in interface Persistent
Throws:
java.sql.SQLException -  

rowExists

public boolean rowExists()
indicates whether the user is stored in the database or not
Specified by:
rowExists in interface Persistent
Returns:
boolean value indicating whether the user exists in the database or not

commit

public void commit(java.lang.String userid)
            throws UpdateException,
                   AppSecurityException
Attempt to store updates made to a user record
Parameters:
userid - the identity of the user requesting the change to be made
Throws:
UpdateException - thrown if the data can't be written
AppSecurityException - thrown if the user doesn't have administration privileges
Overrides:
commit in class User

getUserIDList

public java.lang.String[] getUserIDList()
get all user ids
Returns:
returns a String array containing all user ids

toString

public java.lang.String toString()
Debug method; provides a text representation of the internal User state
Overrides:
toString in class User

TestUnit

public boolean TestUnit()
TestUnit implemented to support test harness
Specified by:
TestUnit in interface Testable
Overrides:
TestUnit in class User