openfuture.bugbase.domain
Class Persistency

java.lang.Object
  |
  +--openfuture.bugbase.domain.Persistency

public class Persistency
extends java.lang.Object

Persistency Layer implementing the database access.

Created: Tue Feb 08 06:04:19 2000

Version:
$Revision: 1.11 $
Author:
Wolfgang Reissenberger

Constructor Summary
Persistency(java.lang.String dbServerClass, java.lang.String url, java.lang.String user, java.lang.String password)
          Creates a new Persistency instance.
 
Method Summary
 void addAttachment(java.lang.Integer reportID, java.lang.String attachmentPath)
          add an attachment to an existing bug report
 java.lang.Integer addBugReport(BugReport report)
          Add a new bug report for the given project
 User adminLogin(Login login)
          Login into the bug database as administrator.
 boolean changePassword(Login login, java.lang.String newPassword)
          Change the current users password.
 void createTable(java.lang.String tableName, java.util.LinkedList columns, java.util.LinkedList dataTypes, java.util.LinkedList constraints)
          Creates a database table.
 User doctorLogin(Login login)
          Login into the bug database as doctor.
 java.util.LinkedList executeQuery(java.lang.String command)
          Execute a SQL query.
 BugReport getBugReport(java.lang.Integer id, java.util.LinkedList groups)
          Retrieve a single bug report.
 java.util.LinkedList getBugReportList(java.lang.String project, java.lang.Boolean filterReported, java.lang.Boolean filterStarted, java.lang.Boolean filterFixed, java.lang.Boolean filterRejected, java.lang.String searchString, java.lang.String reporterId, java.lang.String doctorId, java.util.LinkedList groups)
          Get the list of bug reports for the given project selecting only those which match the given filters.
 java.util.LinkedList getDoctors()
          Extract those users belonging to the group 'doctors'.
 java.util.LinkedList getGroups()
          Retrieves the list of all group IDs
 Version getObjectVersion(java.lang.String name)
          Get the version of a persinstency object.
 java.util.LinkedList getPackages(java.lang.String project)
          Get the value of packages.
 Version getPersistencyVersion()
          Get the persistency version.
 java.util.LinkedList getProjects()
          Get the value of projects.
 DBServer getSqlServer()
          Get the value of sqlServer.
 User getUser(java.lang.String userid)
          Retrieve the user with the given user ID.
 java.util.LinkedList getUserData()
          Retrieves user data from the database
 void init()
          Initialize the database
 User login(Login login)
          Login into the bug database.
 void saveUserData(java.util.LinkedList users, java.util.LinkedList deleted)
          Save user data.
 void setObjectVersion(java.lang.String name, Version version)
          Set the version of a persinstency object.
 void setPackages(java.lang.String project, java.util.LinkedList v)
          Set the value of packages.
 void setPersistencyVersion(Version version)
          Set persistency version.
 void setProjects(java.util.LinkedList v)
          Retrieve the list of all projects available.
 void setSqlServer(DBServer v)
          Set the value of sqlServer.
protected  java.lang.String sqlToString(java.lang.String s)
          Convert an SQL string into its Java representation.
static java.lang.String stringToSql(java.lang.Object o)
          Convert an object into a SQL compatible string.
protected  boolean tableExists(java.lang.String name, java.sql.Connection con)
          Check, if the given table exists.
 void updateBugReport(BugReport report)
          Update an existing bug report.
 void updateBugReports(java.util.LinkedList reports)
          Update existing bug reports.
 boolean validAdminUser(User user)
          Check, if the user belongs to the group 'admin'.
 boolean validDoctorUser(User user)
          Check, if the user belongs to the group 'doctors'.
 boolean validUser(Login login)
          Check, if the given login is valid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Persistency

public Persistency(java.lang.String dbServerClass,
                   java.lang.String url,
                   java.lang.String user,
                   java.lang.String password)
            throws I18NException
Creates a new Persistency instance.
Parameters:
dbServerClass - class name of the database server
url - URL of the database connection
user - user name, for which a connection is established
password - user's pasword
Throws:
I18NException - if an error occurs
Method Detail

changePassword

public boolean changePassword(Login login,
                              java.lang.String newPassword)
                       throws I18NException
Change the current users password.
Parameters:
login - a user login object
newPassword - new password
Returns:
true, if the password change succeeds.
Throws:
I18NException - if an error occurs

getBugReport

public BugReport getBugReport(java.lang.Integer id,
                              java.util.LinkedList groups)
                       throws I18NException
Retrieve a single bug report.
Parameters:
id - ID of the bug report.
groups - a LinkedList value
Returns:
bug report matching the given ID
Throws:
I18NException - if an error occurs

getBugReportList

public java.util.LinkedList getBugReportList(java.lang.String project,
                                             java.lang.Boolean filterReported,
                                             java.lang.Boolean filterStarted,
                                             java.lang.Boolean filterFixed,
                                             java.lang.Boolean filterRejected,
                                             java.lang.String searchString,
                                             java.lang.String reporterId,
                                             java.lang.String doctorId,
                                             java.util.LinkedList groups)
                                      throws I18NException
Get the list of bug reports for the given project selecting only those which match the given filters. If some filter is true, the bug report must be of that state, if the filter was false, the bug report mus NOT be of that state, and if null, this state is ignored.
Parameters:
project - project name
filterReported - filter state = reported
filterStarted - filter state = started
filterFixed - filter state = fixed
filterRejected - filter state = rejected
searchString - string that should occur either in the title or in the description
reporterId - user ID of the bug reporter
doctorId - user ID of the bug doctor
groups - list of groups the report may belong to
Returns:
a list of bug reports
Throws:
I18NException - if an error occurs

addBugReport

public java.lang.Integer addBugReport(BugReport report)
                               throws I18NException
Add a new bug report for the given project
Parameters:
report - new Bug Report
Returns:
number of the bug report.
Throws:
I18NException - if an error occurs

updateBugReports

public void updateBugReports(java.util.LinkedList reports)
                      throws I18NException
Update existing bug reports.
Parameters:
reports - existing bug reports
Throws:
I18NException - if an error occurs

updateBugReport

public void updateBugReport(BugReport report)
                     throws I18NException
Update an existing bug report.
Parameters:
report - existing bug report
Throws:
I18NException - if an error occurs

getProjects

public java.util.LinkedList getProjects()
                                 throws I18NException
Get the value of projects.
Returns:
Value of projects.
Throws:
I18NException - if an error occurs

setProjects

public void setProjects(java.util.LinkedList v)
                 throws I18NException
Retrieve the list of all projects available.
Parameters:
v - Value to assign to projects.
Throws:
I18NException - if an error occurs

getDoctors

public java.util.LinkedList getDoctors()
                                throws I18NException
Extract those users belonging to the group 'doctors'.
Returns:
list of user data
Throws:
I18NException - if an error occurs
See Also:
User

getPackages

public java.util.LinkedList getPackages(java.lang.String project)
                                 throws I18NException
Get the value of packages.
Parameters:
project - project name
Returns:
Value of packages.
Throws:
I18NException - if an error occurs

setPackages

public void setPackages(java.lang.String project,
                        java.util.LinkedList v)
                 throws I18NException
Set the value of packages.
Parameters:
project - project name
v - Value to assign to packages.
Throws:
I18NException - if an error occurs

getPersistencyVersion

public Version getPersistencyVersion()
                              throws I18NException
Get the persistency version.
Returns:
persistency version
Throws:
I18NException - if an error occurs

setPersistencyVersion

public void setPersistencyVersion(Version version)
                           throws I18NException
Set persistency version.
Parameters:
version - persistency version
Throws:
I18NException - if an error occurs

getObjectVersion

public Version getObjectVersion(java.lang.String name)
                         throws I18NException
Get the version of a persinstency object.
Parameters:
name - name of the object
Returns:
version of the object
Throws:
I18NException - if an error occurs

setObjectVersion

public void setObjectVersion(java.lang.String name,
                             Version version)
                      throws I18NException
Set the version of a persinstency object.
Parameters:
name - name of the object
version - of the object
Throws:
I18NException - if an error occurs

getUserData

public java.util.LinkedList getUserData()
                                 throws I18NException
Retrieves user data from the database
Returns:
list of user data
Throws:
I18NException - if an error occurs
See Also:
User

getUser

public User getUser(java.lang.String userid)
             throws I18NException
Retrieve the user with the given user ID. If no matching user can be found, null is returned.
Parameters:
userid - user ID of the user
Returns:
a value of type 'User'
Throws:
I18NException - if an error occurs

validUser

public boolean validUser(Login login)
                  throws I18NException
Check, if the given login is valid.
Parameters:
login - user login
Returns:
true, if user exists and the password is correct.
Throws:
I18NException - if an error occurs

validAdminUser

public boolean validAdminUser(User user)
                       throws I18NException
Check, if the user belongs to the group 'admin'.
Parameters:
user - user data
Returns:
true, if the user is an bugbase administrator
Throws:
I18NException - if an error occurs

validDoctorUser

public boolean validDoctorUser(User user)
                        throws I18NException
Check, if the user belongs to the group 'doctors'.
Parameters:
user - user data
Returns:
true, if the user is an bugbase doctoristrator
Throws:
I18NException - if an error occurs

login

public User login(Login login)
           throws I18NException
Login into the bug database. If the login succeeds, the user data is returned. Otherwise, null is returned.
Parameters:
login - Login object
Returns:
a value of type 'User'
Throws:
I18NException - if an error occurs

adminLogin

public User adminLogin(Login login)
                throws I18NException
Login into the bug database as administrator. If the login succeeds, the user data is returned. Otherwise, null is returned.
Parameters:
login - a Login value
Returns:
user data
Throws:
I18NException - if an error occurs

doctorLogin

public User doctorLogin(Login login)
                 throws I18NException
Login into the bug database as doctor. If the login succeeds, the user data is returned. Otherwise, null is returned.
Parameters:
login - a Login value
Returns:
user data
Throws:
I18NException - if an error occurs

getGroups

public java.util.LinkedList getGroups()
                               throws I18NException
Retrieves the list of all group IDs
Returns:
list of all group IDs
Throws:
I18NException - if an error occurs

saveUserData

public void saveUserData(java.util.LinkedList users,
                         java.util.LinkedList deleted)
                  throws I18NException
Save user data. Update only dirty users. The users from deleted are deleted.
Parameters:
users - list of users to be updated
deleted - list of users to be deleted
Throws:
I18NException - if an error occurs
See Also:
User

addAttachment

public void addAttachment(java.lang.Integer reportID,
                          java.lang.String attachmentPath)
                   throws I18NException
add an attachment to an existing bug report
Parameters:
reportID - bug report ID
attachmentPath - relative path to the attachment
Throws:
I18NException - if an error occurs

init

public void init()
          throws I18NException
Initialize the database
Throws:
I18NException - if an error occurs

createTable

public void createTable(java.lang.String tableName,
                        java.util.LinkedList columns,
                        java.util.LinkedList dataTypes,
                        java.util.LinkedList constraints)
                 throws I18NException
Creates a database table.
Parameters:
tableName - name of the table
columns - list of strings of column names
dataTypes - list of datatypes of the columns
constraints - list of constraints
Throws:
I18NException - if an error occurs

executeQuery

public java.util.LinkedList executeQuery(java.lang.String command)
Execute a SQL query.
Parameters:
command - SQL command
Returns:
list of results

getSqlServer

public DBServer getSqlServer()
Get the value of sqlServer.
Returns:
Value of sqlServer.

setSqlServer

public void setSqlServer(DBServer v)
Set the value of sqlServer.
Parameters:
v - Value to assign to sqlServer.

tableExists

protected boolean tableExists(java.lang.String name,
                              java.sql.Connection con)
Check, if the given table exists.
Parameters:
name - table name
con - the current database connection
Returns:
true, if the table exists.

stringToSql

public static java.lang.String stringToSql(java.lang.Object o)
Convert an object into a SQL compatible string.
Parameters:
o - object to be converted into a string
Returns:
string representation
See Also:
StringUtility.escapeChar(String,char,char), StringUtility.dateToTimestamp(java.util.Date)

sqlToString

protected java.lang.String sqlToString(java.lang.String s)
Convert an SQL string into its Java representation. Currently no modification is made.
Parameters:
s - SQL string
Returns:
Java string representation


Copyright © 2000 -- 2003 openfuture.de. All Rights Reserved.