org.opencms.db.generic
Class CmsWorkflowDriver

java.lang.Object
  extended byorg.opencms.db.generic.CmsWorkflowDriver
All Implemented Interfaces:
I_CmsDriver, I_CmsWorkflowDriver
Direct Known Subclasses:
CmsWorkflowDriver, CmsWorkflowDriver, CmsWorkflowDriver, CmsWorkflowDriver, CmsWorkflowDriver

public class CmsWorkflowDriver
extends java.lang.Object
implements I_CmsDriver, I_CmsWorkflowDriver

Generic (ANSI-SQL) database server implementation of the workflow driver methods.

Since:
6.0.0
Version:
$Revision: 1.56 $
Author:
Thomas Weckert, Michael Emmerich

Field Summary
protected  CmsDriverManager m_driverManager
          The driver manager.
protected  CmsSqlManager m_sqlManager
          The SQL manager.
protected static java.lang.String TABLE_TASK
          Table key for tasks.
protected static java.lang.String TABLE_TASKLOG
          Table key for task logs.
protected static java.lang.String TABLE_TASKPAR
          Table key for task par(ameter).
protected static java.lang.String TABLE_TASKTYPE
          Table key for task type.
 
Fields inherited from interface org.opencms.db.I_CmsWorkflowDriver
DRIVER_TYPE_ID
 
Constructor Summary
CmsWorkflowDriver()
           
 
Method Summary
 CmsTask createTask(CmsDbContext dbc, int rootId, int parentId, int tasktype, CmsUUID ownerId, CmsUUID agentId, CmsUUID roleId, java.lang.String taskname, java.sql.Timestamp wakeuptime, java.sql.Timestamp timeout, int priority)
          Creates a new task.
 void destroy()
          Destroys this driver.
 void endTask(CmsDbContext dbc, int taskId)
          Ends a task.
protected  void finalize()
           
 void forwardTask(CmsDbContext dbc, int taskId, CmsUUID newRoleId, CmsUUID newUserId)
          Forwards a task to a new user.
 CmsSqlManager getSqlManager()
          Returns the SqlManager of this driver.
 void init(CmsDbContext dbc, CmsConfigurationManager configurationManager, java.util.List successiveDrivers, CmsDriverManager driverManager)
          Initializes the driver.
 CmsSqlManager initSqlManager(java.lang.String classname)
          Initializes the SQL manager for this driver.
protected  CmsTask internalCreateTask(java.sql.ResultSet res)
          Semi-constructor to create a CmsTask instance from a JDBC result set.
protected  java.lang.String internalReadTaskTypeCondition(boolean first, int tasktype)
          Constructs a sql condition for the given task type.
protected  void internalWriteTaskParameter(CmsDbContext dbc, int parid, java.lang.String parvalue)
          Updates a task parameter.
protected  int internalWriteTaskParameter(CmsDbContext dbc, int taskId, java.lang.String parname, java.lang.String parvalue)
          Adds a task parameter to a task.
protected  void internalWriteTaskType(CmsDbContext dbc, int taskId, int autofinish, int escalationtyperef, java.lang.String htmllink, java.lang.String name, java.lang.String permission, int priorityref, int roleref)
          Updates a task.
protected  int internalWriteTaskType(CmsDbContext dbc, int autofinish, int escalationtyperef, java.lang.String htmllink, java.lang.String name, java.lang.String permission, int priorityref, int roleref)
          Inserts a new task.
 CmsUUID readAgent(CmsDbContext dbc, CmsUUID roleId)
          Finds an agent for a given role (group).
 CmsProject readProject(CmsDbContext dbc, CmsTask task)
          Reads a project of a given task.
 java.util.List readProjectLogs(CmsDbContext dbc, int projectid)
          Reads all task log entries for a project.
 CmsTask readTask(CmsDbContext dbc, int id)
          Reads the task with the given id.
 CmsTaskLog readTaskLog(CmsDbContext dbc, int id)
          Reads a log for a task.
 java.util.List readTaskLogs(CmsDbContext dbc, int taskId)
          Reads log entries for a task.
 java.lang.String readTaskParameter(CmsDbContext dbc, int taskId, java.lang.String parname)
          Returns the value of the given parameter for the given task.
 java.util.List readTasks(CmsDbContext dbc, CmsProject project, CmsUser agent, CmsUser owner, CmsGroup role, int tasktype, java.lang.String orderBy, java.lang.String sort)
          Reads all given tasks from a user for a project.
 int readTaskType(CmsDbContext dbc, java.lang.String taskName)
          Get the template task id fo a given taskname.
 void writeSystemTaskLog(CmsDbContext dbc, int taskid, java.lang.String comment)
          Writes a system task log entry.
 CmsTask writeTask(CmsDbContext dbc, CmsTask task)
          Writes a task.
 void writeTaskLog(CmsDbContext dbc, int taskId, CmsUUID userId, java.sql.Timestamp starttime, java.lang.String comment, int type)
          Writes new log for a task.
 void writeTaskParameter(CmsDbContext dbc, int taskId, java.lang.String parname, java.lang.String parvalue)
          Set a Parameter for a task.
 void writeTaskType(CmsDbContext dbc, int autofinish, int escalationtyperef, java.lang.String htmllink, java.lang.String name, java.lang.String permission, int priorityref, int roleref)
          Creates a new tasktype set in the database.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.opencms.db.I_CmsDriver
toString
 

Field Detail

TABLE_TASK

protected static final java.lang.String TABLE_TASK
Table key for tasks.

See Also:
Constant Field Values

TABLE_TASKLOG

protected static final java.lang.String TABLE_TASKLOG
Table key for task logs.

See Also:
Constant Field Values

TABLE_TASKPAR

protected static final java.lang.String TABLE_TASKPAR
Table key for task par(ameter).

See Also:
Constant Field Values

TABLE_TASKTYPE

protected static final java.lang.String TABLE_TASKTYPE
Table key for task type.

See Also:
Constant Field Values

m_driverManager

protected CmsDriverManager m_driverManager
The driver manager.


m_sqlManager

protected CmsSqlManager m_sqlManager
The SQL manager.

Constructor Detail

CmsWorkflowDriver

public CmsWorkflowDriver()
Method Detail

createTask

public CmsTask createTask(CmsDbContext dbc,
                          int rootId,
                          int parentId,
                          int tasktype,
                          CmsUUID ownerId,
                          CmsUUID agentId,
                          CmsUUID roleId,
                          java.lang.String taskname,
                          java.sql.Timestamp wakeuptime,
                          java.sql.Timestamp timeout,
                          int priority)
                   throws CmsDataAccessException
Description copied from interface: I_CmsWorkflowDriver
Creates a new task.

Specified by:
createTask in interface I_CmsWorkflowDriver
Parameters:
dbc - the current database context
rootId - id of the root task project
parentId - id of the parent task
tasktype - type of the task
ownerId - id of the owner
agentId - id of the agent
roleId - id of the role
taskname - name of the task
wakeuptime - time when the task will be wake up
timeout - time when the task times out
priority - priority of the task
Returns:
the Task object of the generated task
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsWorkflowDriver.createTask(org.opencms.db.CmsDbContext, int, int, int, org.opencms.util.CmsUUID, org.opencms.util.CmsUUID, org.opencms.util.CmsUUID, java.lang.String, java.sql.Timestamp, java.sql.Timestamp, int)

destroy

public void destroy()
             throws java.lang.Throwable
Description copied from interface: I_CmsWorkflowDriver
Destroys this driver.

Specified by:
destroy in interface I_CmsWorkflowDriver
Throws:
java.lang.Throwable - if something goes wrong
See Also:
I_CmsWorkflowDriver.destroy()

endTask

public void endTask(CmsDbContext dbc,
                    int taskId)
             throws CmsDataAccessException
Description copied from interface: I_CmsWorkflowDriver
Ends a task.

Specified by:
endTask in interface I_CmsWorkflowDriver
Parameters:
dbc - the current database context
taskId - Id of the task to end
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsWorkflowDriver.endTask(org.opencms.db.CmsDbContext, int)

forwardTask

public void forwardTask(CmsDbContext dbc,
                        int taskId,
                        CmsUUID newRoleId,
                        CmsUUID newUserId)
                 throws CmsDataAccessException
Description copied from interface: I_CmsWorkflowDriver
Forwards a task to a new user.

Specified by:
forwardTask in interface I_CmsWorkflowDriver
Parameters:
dbc - the current database context
taskId - the Id of the task to forward
newRoleId - the new group name for the task
newUserId - the new user who gets the task
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsWorkflowDriver.forwardTask(org.opencms.db.CmsDbContext, int, org.opencms.util.CmsUUID, org.opencms.util.CmsUUID)

getSqlManager

public CmsSqlManager getSqlManager()
Description copied from interface: I_CmsWorkflowDriver
Returns the SqlManager of this driver.

Specified by:
getSqlManager in interface I_CmsWorkflowDriver
Returns:
the SqlManager of this driver
See Also:
I_CmsWorkflowDriver.getSqlManager()

init

public void init(CmsDbContext dbc,
                 CmsConfigurationManager configurationManager,
                 java.util.List successiveDrivers,
                 CmsDriverManager driverManager)
Description copied from interface: I_CmsDriver
Initializes the driver.

Specified by:
init in interface I_CmsDriver
Parameters:
dbc - the current database context
configurationManager - the configuration manager
successiveDrivers - a list of successive drivers to be initialized
driverManager - the initialized OpenCms driver manager
See Also:
I_CmsDriver.init(org.opencms.db.CmsDbContext, org.opencms.configuration.CmsConfigurationManager, java.util.List, org.opencms.db.CmsDriverManager)

initSqlManager

public CmsSqlManager initSqlManager(java.lang.String classname)
Description copied from interface: I_CmsWorkflowDriver
Initializes the SQL manager for this driver.

To obtain JDBC connections from different pools, further {online|offline|backup} pool Urls have to be specified.

Specified by:
initSqlManager in interface I_CmsWorkflowDriver
Parameters:
classname - the classname of the SQL manager
Returns:
the SQL manager for this driver
See Also:
I_CmsWorkflowDriver.initSqlManager(String)

readAgent

public CmsUUID readAgent(CmsDbContext dbc,
                         CmsUUID roleId)
                  throws CmsDataAccessException
Description copied from interface: I_CmsWorkflowDriver
Finds an agent for a given role (group).

Specified by:
readAgent in interface I_CmsWorkflowDriver
Parameters:
dbc - the current database context
roleId - The Id for the role (group)
Returns:
A vector with the tasks
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsWorkflowDriver.readAgent(org.opencms.db.CmsDbContext, org.opencms.util.CmsUUID)

readProject

public CmsProject readProject(CmsDbContext dbc,
                              CmsTask task)
                       throws CmsDataAccessException
Description copied from interface: I_CmsWorkflowDriver
Reads a project of a given task.

Specified by:
readProject in interface I_CmsWorkflowDriver
Parameters:
dbc - the current database context
task - the task to read the project of
Returns:
the project of the task
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsWorkflowDriver.readProject(org.opencms.db.CmsDbContext, org.opencms.workflow.CmsTask)

readProjectLogs

public java.util.List readProjectLogs(CmsDbContext dbc,
                                      int projectid)
                               throws CmsDataAccessException
Description copied from interface: I_CmsWorkflowDriver
Reads all task log entries for a project.

Specified by:
readProjectLogs in interface I_CmsWorkflowDriver
Parameters:
dbc - the current database context
projectid - the id of the project for which the tasklog will be read
Returns:
a list of CmsTaskLog objects
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsWorkflowDriver.readProjectLogs(org.opencms.db.CmsDbContext, int)

readTask

public CmsTask readTask(CmsDbContext dbc,
                        int id)
                 throws CmsDataAccessException
Description copied from interface: I_CmsWorkflowDriver
Reads the task with the given id.

Specified by:
readTask in interface I_CmsWorkflowDriver
Parameters:
dbc - the current database context
id - the id for the task to read
Returns:
the task with the given id
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsWorkflowDriver.readTask(org.opencms.db.CmsDbContext, int)

readTaskLog

public CmsTaskLog readTaskLog(CmsDbContext dbc,
                              int id)
                       throws CmsDataAccessException
Description copied from interface: I_CmsWorkflowDriver
Reads a log for a task.

Specified by:
readTaskLog in interface I_CmsWorkflowDriver
Parameters:
dbc - the current database context
id - The id for the tasklog
Returns:
a new TaskLog object
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsWorkflowDriver.readTaskLog(org.opencms.db.CmsDbContext, int)

readTaskLogs

public java.util.List readTaskLogs(CmsDbContext dbc,
                                   int taskId)
                            throws CmsDataAccessException
Description copied from interface: I_CmsWorkflowDriver
Reads log entries for a task.

Specified by:
readTaskLogs in interface I_CmsWorkflowDriver
Parameters:
dbc - the current satabase context
taskId - the task for the tasklog to read
Returns:
a list of CmsTaskLog objects
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsWorkflowDriver.readTaskLogs(org.opencms.db.CmsDbContext, int)

readTaskParameter

public java.lang.String readTaskParameter(CmsDbContext dbc,
                                          int taskId,
                                          java.lang.String parname)
                                   throws CmsDataAccessException
Description copied from interface: I_CmsWorkflowDriver
Returns the value of the given parameter for the given task.

Specified by:
readTaskParameter in interface I_CmsWorkflowDriver
Parameters:
dbc - the current database context
taskId - the Id of the task
parname - name of the parameter
Returns:
task parameter value
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsWorkflowDriver.readTaskParameter(org.opencms.db.CmsDbContext, int, java.lang.String)

readTasks

public java.util.List readTasks(CmsDbContext dbc,
                                CmsProject project,
                                CmsUser agent,
                                CmsUser owner,
                                CmsGroup role,
                                int tasktype,
                                java.lang.String orderBy,
                                java.lang.String sort)
                         throws CmsDataAccessException
Description copied from interface: I_CmsWorkflowDriver
Reads all given tasks from a user for a project.

Most parameters can be null, if you do not want to filter the tasks by them. The tasktype parameter will filter the tasks. The possible values for this parameter are:

Specified by:
readTasks in interface I_CmsWorkflowDriver
Parameters:
dbc - the current database context
project - the id of the project in which the tasks are defined
agent - the owner of the task
owner - the owner of the task
role - the owner of the task
tasktype - the type of task you want to read
orderBy - specifies how to order the tasks
sort - sorting of the tasks
Returns:
a list of given CmsTask objects for a user for a project
Throws:
CmsDataAccessException - if operation was not successful
See Also:
I_CmsWorkflowDriver.readTasks(org.opencms.db.CmsDbContext, org.opencms.file.CmsProject, org.opencms.file.CmsUser, org.opencms.file.CmsUser, org.opencms.file.CmsGroup, int, java.lang.String, java.lang.String)

readTaskType

public int readTaskType(CmsDbContext dbc,
                        java.lang.String taskName)
                 throws CmsDataAccessException
Description copied from interface: I_CmsWorkflowDriver
Get the template task id fo a given taskname.

Specified by:
readTaskType in interface I_CmsWorkflowDriver
Parameters:
dbc - the current database context
taskName - Name of the Task
Returns:
id from the task template
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsWorkflowDriver.readTaskType(org.opencms.db.CmsDbContext, java.lang.String)

writeSystemTaskLog

public void writeSystemTaskLog(CmsDbContext dbc,
                               int taskid,
                               java.lang.String comment)
                        throws CmsDataAccessException
Description copied from interface: I_CmsWorkflowDriver
Writes a system task log entry.

Specified by:
writeSystemTaskLog in interface I_CmsWorkflowDriver
Parameters:
dbc - the current database context
taskid - the id of the task
comment - the log entry
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsWorkflowDriver.writeSystemTaskLog(org.opencms.db.CmsDbContext, int, java.lang.String)

writeTask

public CmsTask writeTask(CmsDbContext dbc,
                         CmsTask task)
                  throws CmsDataAccessException
Description copied from interface: I_CmsWorkflowDriver
Writes a task.

Specified by:
writeTask in interface I_CmsWorkflowDriver
Parameters:
dbc - the current database context
task - the task to write
Returns:
written task object
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsWorkflowDriver.writeTask(org.opencms.db.CmsDbContext, org.opencms.workflow.CmsTask)

writeTaskLog

public void writeTaskLog(CmsDbContext dbc,
                         int taskId,
                         CmsUUID userId,
                         java.sql.Timestamp starttime,
                         java.lang.String comment,
                         int type)
                  throws CmsDataAccessException
Description copied from interface: I_CmsWorkflowDriver
Writes new log for a task.

Specified by:
writeTaskLog in interface I_CmsWorkflowDriver
Parameters:
dbc - the current database context
taskId - The id of the task
userId - User who added the Log
starttime - Time when the log is created
comment - Description for the log
type - Type of the log. 0 = Sytem log, 1 = User Log
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsWorkflowDriver.writeTaskLog(org.opencms.db.CmsDbContext, int, org.opencms.util.CmsUUID, java.sql.Timestamp, java.lang.String, int)

writeTaskParameter

public void writeTaskParameter(CmsDbContext dbc,
                               int taskId,
                               java.lang.String parname,
                               java.lang.String parvalue)
                        throws CmsDataAccessException
Description copied from interface: I_CmsWorkflowDriver
Set a Parameter for a task.

Specified by:
writeTaskParameter in interface I_CmsWorkflowDriver
Parameters:
dbc - the current database context
taskId - the task
parname - the name of the parameter
parvalue - the value of the parameter
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsWorkflowDriver.writeTaskParameter(org.opencms.db.CmsDbContext, int, java.lang.String, java.lang.String)

writeTaskType

public void writeTaskType(CmsDbContext dbc,
                          int autofinish,
                          int escalationtyperef,
                          java.lang.String htmllink,
                          java.lang.String name,
                          java.lang.String permission,
                          int priorityref,
                          int roleref)
                   throws CmsDataAccessException
Description copied from interface: I_CmsWorkflowDriver
Creates a new tasktype set in the database.

Specified by:
writeTaskType in interface I_CmsWorkflowDriver
Parameters:
dbc - the current database context
autofinish - tbd
escalationtyperef - tbd
htmllink - tbd
name - tbd
permission - tbd
priorityref - tbd
roleref - tbd
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsWorkflowDriver.writeTaskType(org.opencms.db.CmsDbContext, int, int, java.lang.String, java.lang.String, java.lang.String, int, int)

finalize

protected void finalize()
                 throws java.lang.Throwable
Throws:
java.lang.Throwable
See Also:
Object.finalize()

internalCreateTask

protected CmsTask internalCreateTask(java.sql.ResultSet res)
                              throws java.sql.SQLException
Semi-constructor to create a CmsTask instance from a JDBC result set.

Parameters:
res - the result set from the query
Returns:
the CmsTash created from the data
Throws:
java.sql.SQLException - if something goes wrong

internalReadTaskTypeCondition

protected java.lang.String internalReadTaskTypeCondition(boolean first,
                                                         int tasktype)
Constructs a sql condition for the given task type.

Parameters:
first - flag to indicate the first condition
tasktype - the type to query
Returns:
the sql condition

internalWriteTaskParameter

protected void internalWriteTaskParameter(CmsDbContext dbc,
                                          int parid,
                                          java.lang.String parvalue)
                                   throws CmsDataAccessException
Updates a task parameter.

Parameters:
dbc - the current database context
parid - the id of the parameter
parvalue - the value of the parameter
Throws:
CmsDataAccessException - if something goes wrong

internalWriteTaskParameter

protected int internalWriteTaskParameter(CmsDbContext dbc,
                                         int taskId,
                                         java.lang.String parname,
                                         java.lang.String parvalue)
                                  throws CmsDataAccessException
Adds a task parameter to a task.

Parameters:
dbc - the current database context
taskId - the id of the task
parname - the name of the parameter
parvalue - the value of the parameter
Returns:
the id of the new parameter
Throws:
CmsDataAccessException - if something goes wrong

internalWriteTaskType

protected void internalWriteTaskType(CmsDbContext dbc,
                                     int taskId,
                                     int autofinish,
                                     int escalationtyperef,
                                     java.lang.String htmllink,
                                     java.lang.String name,
                                     java.lang.String permission,
                                     int priorityref,
                                     int roleref)
                              throws CmsDataAccessException
Updates a task.

Parameters:
dbc - the current database context
taskId - the id of the task
autofinish - tbd
escalationtyperef - tbd
htmllink - tbd
name - tbd
permission - tbd
priorityref - tbd
roleref - tbd
Throws:
CmsDataAccessException - if something goes wrong

internalWriteTaskType

protected int internalWriteTaskType(CmsDbContext dbc,
                                    int autofinish,
                                    int escalationtyperef,
                                    java.lang.String htmllink,
                                    java.lang.String name,
                                    java.lang.String permission,
                                    int priorityref,
                                    int roleref)
                             throws CmsDataAccessException
Inserts a new task.

Parameters:
dbc - the current database context
autofinish - tbd
escalationtyperef - tbd
htmllink - tbd
name - tbd
permission - tbd
priorityref - tbd
roleref - tbd
Returns:
tbd
Throws:
CmsDataAccessException - tbd