com.ora.jsp.beans.emp
Class EmployeeRegistryBean

java.lang.Object
  extended bycom.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:
2.0
Author:
Hans Bergsten, Gefion software
See Also:
Serialized Form

Field Summary
private  javax.sql.DataSource dataSource
           
 
Constructor Summary
EmployeeRegistryBean()
           
 
Method Summary
 EmployeeBean authenticate(java.lang.String userName, java.lang.String password)
          Returns an EmployeeBean if the specified user name and password match an employee in the database, otherwise null.
 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.Map[] getProjects(java.lang.String userName, java.sql.Connection conn)
          Returns a Map[] with a Map per project for the specified employee, or null if not found.
private  java.util.Map getSingleValueProps(java.lang.String userName, java.sql.Connection conn)
          Returns a Map 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.lang.String[] toProjectsArray(java.util.Map[] 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, 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 EmployeeBean authenticate(java.lang.String userName,
                                 java.lang.String password)
                          throws java.sql.SQLException
Returns an EmployeeBean if the specified user name and password match an employee in the database, otherwise null.

Throws:
java.sql.SQLException

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.

Throws:
java.sql.SQLException

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.

Throws:
java.sql.SQLException

getSingleValueProps

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

Throws:
java.sql.SQLException

getProjects

private java.util.Map[] getProjects(java.lang.String userName,
                                    java.sql.Connection conn)
                             throws java.sql.SQLException
Returns a Map[] with a Map per project for the specified employee, or null if not found.

Throws:
java.sql.SQLException

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.

Throws:
java.sql.SQLException

saveProjects

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

Throws:
java.sql.SQLException

toProjectsArray

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