com.ora.jsp.beans.emp
Class EmployeeRegistryBean

java.lang.Object
  |
  +--com.ora.jsp.beans.emp.EmployeeRegistryBean
All Implemented Interfaces:
java.io.Serializable

public class EmployeeRegistryBean
extends java.lang.Object
implements java.io.Serializable

This class is an example of an application specific interface to a database. It contains methods for authenticating a user, and retrieving and updating user information.

Version:
1.0
Author:
Hans Bergsten, Gefion software
See Also:
Serialized Form

Field Summary
private  javax.sql.DataSource dataSource
           
 
Constructor Summary
EmployeeRegistryBean()
           
 
Method Summary
 boolean authenticate(java.lang.String userName, java.lang.String password)
          Returns true if the specified user name and password match an employee in the database.
 EmployeeBean getEmployee(java.lang.String userName)
          Returns an EmployeeBean initialized with the information found in the database for the specified employee, or null if not found.
private  java.util.Vector getProjects(java.lang.String userName, java.sql.Connection conn)
          Returns a Vector with Row objects describing all projects for the specified employee, or null if not found.
private  Row getSingleValueProps(java.lang.String userName, java.sql.Connection conn)
          Returns a Row with all information about the specified employee except the project list, or null if not found.
 void saveEmployee(EmployeeBean empInfo)
          Inserts the information about the specified employee, or updates the information if it's already defined.
private  void saveProjects(EmployeeBean empInfo, java.sql.Connection conn)
          Updates or inserts project information for the specified employee.
private  void saveSingleValueProps(EmployeeBean empInfo, java.sql.Connection conn)
          Inserts the information about the specified employee (except projects), or updates the information if it's already defined.
 void setDataSource(javax.sql.DataSource dataSource)
          Sets the dataSource property value.
private  java.sql.Date toDate(java.lang.String dateString)
          Converts a date string in the format "yyyy-MM-dd" to a Date object.
private  java.lang.String[] toProjectsArray(java.util.Vector projectRows)
          Converts a Vector with Row elements containing a ProjectName column to a String[] with the project names.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

dataSource

private javax.sql.DataSource dataSource
Constructor Detail

EmployeeRegistryBean

public EmployeeRegistryBean()
Method Detail

setDataSource

public void setDataSource(javax.sql.DataSource dataSource)
Sets the dataSource property value.

authenticate

public boolean authenticate(java.lang.String userName,
                            java.lang.String password)
                     throws java.sql.SQLException
Returns true if the specified user name and password match an employee in the database.

getEmployee

public EmployeeBean getEmployee(java.lang.String userName)
                         throws java.sql.SQLException
Returns an EmployeeBean initialized with the information found in the database for the specified employee, or null if not found.

saveEmployee

public void saveEmployee(EmployeeBean empInfo)
                  throws java.sql.SQLException
Inserts the information about the specified employee, or updates the information if it's already defined.

getSingleValueProps

private Row getSingleValueProps(java.lang.String userName,
                                java.sql.Connection conn)
                         throws java.sql.SQLException
Returns a Row with all information about the specified employee except the project list, or null if not found.

getProjects

private java.util.Vector getProjects(java.lang.String userName,
                                     java.sql.Connection conn)
                              throws java.sql.SQLException
Returns a Vector with Row objects describing all projects for the specified employee, or null if not found.

saveSingleValueProps

private void saveSingleValueProps(EmployeeBean empInfo,
                                  java.sql.Connection conn)
                           throws java.sql.SQLException
Inserts the information about the specified employee (except projects), or updates the information if it's already defined.

saveProjects

private void saveProjects(EmployeeBean empInfo,
                          java.sql.Connection conn)
                   throws java.sql.SQLException
Updates or inserts project information for the specified employee.

toProjectsArray

private java.lang.String[] toProjectsArray(java.util.Vector projectRows)
Converts a Vector with Row elements containing a ProjectName column to a String[] with the project names.

toDate

private java.sql.Date toDate(java.lang.String dateString)
Converts a date string in the format "yyyy-MM-dd" to a Date object.