org.opencms.workflow
Class CmsTaskService

java.lang.Object
  extended byorg.opencms.workflow.CmsTaskService

public class CmsTaskService
extends java.lang.Object

Just a convenience wrapper for workflow related methods.

Since:
6.0.0
Version:
$Revision: 1.11 $
Author:
Michael Moossen

Field Summary
protected  CmsRequestContext m_context
          The request context.
protected  CmsSecurityManager m_securityManager
          The security manager to access the cms.
static java.lang.String TASK_FILTER
          Task preferences filter.
static java.lang.String TASK_MESSAGES
          Task preferences message flags.
static int TASK_MESSAGES_ACCEPTED
          state values of task messages when accepted.
static int TASK_MESSAGES_COMPLETED
          state values of task messages when completed.
static int TASK_MESSAGES_FORWARDED
          state values of task messages when forwarded.
static int TASK_MESSAGES_MEMBERS
          state values of task messages when members.
static int TASK_PRIORITY_HIGH
          Task priority high.
static int TASK_PRIORITY_LOW
          Task priority low.
static int TASK_PRIORITY_NORMAL
          Task priority normal.
static int TASK_STATE_ENDED
          state values of a task ended.
static int TASK_STATE_HALTED
          state values of a task halted.
static int TASK_STATE_NOTENDED
          state values of a task ready to end.
static int TASK_STATE_PREPARE
          state values of a task prepared to start.
static int TASK_STATE_START
          state values of a task ready to start.
static int TASK_STATE_STARTED
          state values of a task started.
static int TASKLOG_SYSTEM
          System type values for the task log.
static int TASKLOG_USER
          User type value for the task log.
static int TASKS_ACTIVE
          Task type value of getting active tasks.
static int TASKS_ALL
          Task type value of getting all tasks.
static int TASKS_DONE
          Task type value of getting done tasks.
static int TASKS_NEW
          Task type value of getting new tasks.
static int TASKS_OPEN
          Task type value of getting open tasks.
 
Constructor Summary
CmsTaskService(CmsRequestContext context, CmsSecurityManager securityManager)
          Creates a new CmsTaskService.
 
Method Summary
 void acceptTask(int taskId)
          Updates the state of the given task as accepted by the current user.
 CmsTask createTask(int projectid, java.lang.String agentName, java.lang.String roleName, java.lang.String taskname, java.lang.String taskcomment, int tasktype, long timeout, int priority)
          Creates a new task.
 CmsTask createTask(java.lang.String agentName, java.lang.String roleName, java.lang.String taskname, long timeout, int priority)
          Creates a new task.
 void endTask(int taskid)
          Ends a task.
 void forwardTask(int taskid, java.lang.String newRoleName, java.lang.String newUserName)
          Forwards a task to a new user.
 java.lang.String getTaskPar(int taskid, java.lang.String parname)
          Returns the value of the given parameter for the given task.
 int getTaskType(java.lang.String taskname)
          Returns the template task id for a given taskname.
 void reactivateTask(int taskId)
          Reactivates a task.
 CmsUser readAgent(CmsTask task)
          Reads the agent of a task.
 java.util.List readGivenTasks(int projectId, java.lang.String ownerName, int taskType, java.lang.String orderBy, java.lang.String sort)
          Reads all given tasks from a user for a project.
 CmsGroup readGroup(CmsTask task)
          Reads the group (role) of a task.
 CmsUser readOriginalAgent(CmsTask task)
          Reads the original agent of a task.
 CmsUser readOwner(CmsTask task)
          Reads the owner (initiator) of a task.
 CmsUser readOwner(CmsTaskLog log)
          Reads the owner of a task log.
 CmsProject readProject(CmsTask task)
          Reads a project of a given task.
 java.util.List readProjectLogs(int projectId)
          Reads all task log entries for a project.
 CmsTask readTask(int id)
          Reads the task with the given id.
 java.util.List readTaskLogs(int taskid)
          Reads log entries for a task.
 java.util.List readTasksForProject(int projectId, int tasktype, java.lang.String orderBy, java.lang.String sort)
          Reads all tasks for a project.
 java.util.List readTasksForRole(int projectId, java.lang.String roleName, int tasktype, java.lang.String orderBy, java.lang.String sort)
          Reads all tasks for a role in a project.
 java.util.List readTasksForUser(int projectId, java.lang.String userName, int tasktype, java.lang.String orderBy, java.lang.String sort)
          Reads all tasks for a user in a project.
 void setName(int taskId, java.lang.String name)
          Sets a new name for a task.
 void setPriority(int taskId, int priority)
          Sets the priority of a task.
 void setTaskPar(int taskid, java.lang.String parname, java.lang.String parvalue)
          Sets a parameter for a task.
 void setTimeout(int taskId, long timeout)
          Sets the timeout of a task.
 void writeTaskLog(int taskid, java.lang.String comment)
          Writes a new user tasklog for a task.
 void writeTaskLog(int taskId, java.lang.String comment, int taskType)
          Writes a new user tasklog for a task.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TASK_FILTER

public static final java.lang.String TASK_FILTER
Task preferences filter.

See Also:
Constant Field Values

TASK_MESSAGES

public static final java.lang.String TASK_MESSAGES
Task preferences message flags.

See Also:
Constant Field Values

TASK_MESSAGES_ACCEPTED

public static final int TASK_MESSAGES_ACCEPTED
state values of task messages when accepted.

See Also:
Constant Field Values

TASK_MESSAGES_COMPLETED

public static final int TASK_MESSAGES_COMPLETED
state values of task messages when completed.

See Also:
Constant Field Values

TASK_MESSAGES_FORWARDED

public static final int TASK_MESSAGES_FORWARDED
state values of task messages when forwarded.

See Also:
Constant Field Values

TASK_MESSAGES_MEMBERS

public static final int TASK_MESSAGES_MEMBERS
state values of task messages when members.

See Also:
Constant Field Values

TASK_PRIORITY_HIGH

public static final int TASK_PRIORITY_HIGH
Task priority high.

See Also:
Constant Field Values

TASK_PRIORITY_LOW

public static final int TASK_PRIORITY_LOW
Task priority low.

See Also:
Constant Field Values

TASK_PRIORITY_NORMAL

public static final int TASK_PRIORITY_NORMAL
Task priority normal.

See Also:
Constant Field Values

TASK_STATE_ENDED

public static final int TASK_STATE_ENDED
state values of a task ended.

See Also:
Constant Field Values

TASK_STATE_HALTED

public static final int TASK_STATE_HALTED
state values of a task halted.

See Also:
Constant Field Values

TASK_STATE_NOTENDED

public static final int TASK_STATE_NOTENDED
state values of a task ready to end.

See Also:
Constant Field Values

TASK_STATE_PREPARE

public static final int TASK_STATE_PREPARE
state values of a task prepared to start.

See Also:
Constant Field Values

TASK_STATE_START

public static final int TASK_STATE_START
state values of a task ready to start.

See Also:
Constant Field Values

TASK_STATE_STARTED

public static final int TASK_STATE_STARTED
state values of a task started.

See Also:
Constant Field Values

TASKLOG_SYSTEM

public static final int TASKLOG_SYSTEM
System type values for the task log.

See Also:
Constant Field Values

TASKLOG_USER

public static final int TASKLOG_USER
User type value for the task log.

See Also:
Constant Field Values

TASKS_ACTIVE

public static final int TASKS_ACTIVE
Task type value of getting active tasks.

See Also:
Constant Field Values

TASKS_ALL

public static final int TASKS_ALL
Task type value of getting all tasks.

See Also:
Constant Field Values

TASKS_DONE

public static final int TASKS_DONE
Task type value of getting done tasks.

See Also:
Constant Field Values

TASKS_NEW

public static final int TASKS_NEW
Task type value of getting new tasks.

See Also:
Constant Field Values

TASKS_OPEN

public static final int TASKS_OPEN
Task type value of getting open tasks.

See Also:
Constant Field Values

m_context

protected CmsRequestContext m_context
The request context.


m_securityManager

protected CmsSecurityManager m_securityManager
The security manager to access the cms.

Constructor Detail

CmsTaskService

public CmsTaskService(CmsRequestContext context,
                      CmsSecurityManager securityManager)
Creates a new CmsTaskService.

Parameters:
context - the request context that contains the user authentification
securityManager - the security manager
Method Detail

acceptTask

public void acceptTask(int taskId)
                throws CmsException
Updates the state of the given task as accepted by the current user.

Parameters:
taskId - the id of the task to accept
Throws:
CmsException - if operation was not successful

createTask

public CmsTask createTask(int projectid,
                          java.lang.String agentName,
                          java.lang.String roleName,
                          java.lang.String taskname,
                          java.lang.String taskcomment,
                          int tasktype,
                          long timeout,
                          int priority)
                   throws CmsException
Creates a new task.

Parameters:
projectid - the id of the current project task of the user
agentName - the user who will edit the task
roleName - a usergroup for the task
taskname - a name of the task
tasktype - the type of the task
taskcomment - a description of the task, which is written as task log entry
timeout - the time when the task must finished
priority - the id for the priority of the task
Returns:
the created task
Throws:
CmsException - if something goes wrong

createTask

public CmsTask createTask(java.lang.String agentName,
                          java.lang.String roleName,
                          java.lang.String taskname,
                          long timeout,
                          int priority)
                   throws CmsException
Creates a new task.

This is just a more limited version of the createTask(int, String, String, String, String, int, long, int) method, where:

Parameters:
agentName - the user who will edit the task
roleName - a usergroup for the task
taskname - the name of the task
timeout - the time when the task must finished
priority - the id for the priority of the task
Returns:
the created task
Throws:
CmsException - if something goes wrong

endTask

public void endTask(int taskid)
             throws CmsException
Ends a task.

Parameters:
taskid - the id of the task to end
Throws:
CmsException - if operation was not successful

forwardTask

public void forwardTask(int taskid,
                        java.lang.String newRoleName,
                        java.lang.String newUserName)
                 throws CmsException
Forwards a task to a new user.

Parameters:
taskid - the id of the task which will be forwarded
newRoleName - the new group for the task
newUserName - the new user who gets the task. if it is empty, a new agent will automatic selected
Throws:
CmsException - if operation was not successful

getTaskPar

public java.lang.String getTaskPar(int taskid,
                                   java.lang.String parname)
                            throws CmsException
Returns the value of the given parameter for the given task.

Parameters:
taskid - the id of the task
parname - the name of the parameter
Returns:
the parameter value
Throws:
CmsException - if operation was not successful

getTaskType

public int getTaskType(java.lang.String taskname)
                throws CmsException
Returns the template task id for a given taskname.

Parameters:
taskname - the name of the task
Returns:
the id of the task template
Throws:
CmsException - if operation was not successful

reactivateTask

public void reactivateTask(int taskId)
                    throws CmsException
Reactivates a task.

Setting its state to TASK_STATE_STARTED and the percentage to zero.

Parameters:
taskId - the id of the task to reactivate
Throws:
CmsException - if something goes wrong

readAgent

public CmsUser readAgent(CmsTask task)
                  throws CmsException
Reads the agent of a task.

Parameters:
task - the task to read the agent from
Returns:
the agent of a task
Throws:
CmsException - if something goes wrong

readGivenTasks

public java.util.List readGivenTasks(int projectId,
                                     java.lang.String ownerName,
                                     int taskType,
                                     java.lang.String orderBy,
                                     java.lang.String sort)
                              throws CmsException
Reads all given tasks from a user for a project.

The tasktype parameter will filter the tasks. The possible values for this parameter are:

Parameters:
projectId - the id of the project in which the tasks are defined
ownerName - 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:
CmsException - if operation was not successful

readGroup

public CmsGroup readGroup(CmsTask task)
                   throws CmsException
Reads the group (role) of a task.

Parameters:
task - the task to read the group (role) from
Returns:
the group (role) of the task
Throws:
CmsException - if something goes wrong

readOriginalAgent

public CmsUser readOriginalAgent(CmsTask task)
                          throws CmsException
Reads the original agent of a task.

Parameters:
task - the task to read the original agent from
Returns:
the original agent of the task
Throws:
CmsException - if something goes wrong

readOwner

public CmsUser readOwner(CmsTask task)
                  throws CmsException
Reads the owner (initiator) of a task.

Parameters:
task - the task to read the owner from
Returns:
the owner of the task
Throws:
CmsException - if something goes wrong

readOwner

public CmsUser readOwner(CmsTaskLog log)
                  throws CmsException
Reads the owner of a task log.

Parameters:
log - the task log
Returns:
the owner of the task log
Throws:
CmsException - if something goes wrong

readProject

public CmsProject readProject(CmsTask task)
                       throws CmsException
Reads a project of a given task.

Parameters:
task - the task for which the project will be read
Returns:
the project of the task
Throws:
CmsException - if operation was not successful

readProjectLogs

public java.util.List readProjectLogs(int projectId)
                               throws CmsException
Reads all task log entries for a project.

Parameters:
projectId - the id of the project for which the tasklog will be read
Returns:
a list of CmsTaskLog objects
Throws:
CmsException - if operation was not successful

readTask

public CmsTask readTask(int id)
                 throws CmsException
Reads the task with the given id.

Parameters:
id - the id of the task to be read
Returns:
the task with the given id
Throws:
CmsException - if operation was not successful

readTaskLogs

public java.util.List readTaskLogs(int taskid)
                            throws CmsException
Reads log entries for a task.

Parameters:
taskid - the task for which the tasklog will be read
Returns:
a list of CmsTaskLog objects
Throws:
CmsException - if operation was not successful

readTasksForProject

public java.util.List readTasksForProject(int projectId,
                                          int tasktype,
                                          java.lang.String orderBy,
                                          java.lang.String sort)
                                   throws CmsException
Reads all tasks for a project.

The tasktype parameter will filter the tasks. The possible values are:

Parameters:
projectId - the id of the project in which the tasks are defined. Can be null to select all tasks
tasktype - the type of task you want to read
orderBy - specifies how to order the tasks
sort - sort order: C_SORT_ASC, C_SORT_DESC, or null
Returns:
a list of CmsTask objects for the project
Throws:
CmsException - if operation was not successful

readTasksForRole

public java.util.List readTasksForRole(int projectId,
                                       java.lang.String roleName,
                                       int tasktype,
                                       java.lang.String orderBy,
                                       java.lang.String sort)
                                throws CmsException
Reads all tasks for a role in a project.

The tasktype parameter will filter the tasks. The possible values for this parameter are:

Parameters:
projectId - the id of the Project in which the tasks are defined
roleName - the role who has to process the task
tasktype - the type of task you want to read
orderBy - specifies how to order the tasks
sort - sort order C_SORT_ASC, C_SORT_DESC, or null
Returns:
list of CmsTask objects for the role
Throws:
CmsException - if operation was not successful

readTasksForUser

public java.util.List readTasksForUser(int projectId,
                                       java.lang.String userName,
                                       int tasktype,
                                       java.lang.String orderBy,
                                       java.lang.String sort)
                                throws CmsException
Reads all tasks for a user in a project.

The tasktype parameter will filter the tasks. The possible values for this parameter are:

Parameters:
projectId - the id of the Project in which the tasks are defined
userName - the user who has to process the task
tasktype - the type of task you want to read
orderBy - specifies how to order the tasks
sort - sort order C_SORT_ASC, C_SORT_DESC, or null
Returns:
a list of CmsTask objects for the user
Throws:
CmsException - if operation was not successful

setName

public void setName(int taskId,
                    java.lang.String name)
             throws CmsException
Sets a new name for a task.

Parameters:
taskId - the id of the task
name - the new name of the task
Throws:
CmsException - if something goes wrong

setPriority

public void setPriority(int taskId,
                        int priority)
                 throws CmsException
Sets the priority of a task.

Parameters:
taskId - the id of the task
priority - the new priority value
Throws:
CmsException - if something goes wrong

setTaskPar

public void setTaskPar(int taskid,
                       java.lang.String parname,
                       java.lang.String parvalue)
                throws CmsException
Sets a parameter for a task.

Parameters:
taskid - the id of the task
parname - the name of the parameter
parvalue - the value of the parameter
Throws:
CmsException - if something goes wrong

setTimeout

public void setTimeout(int taskId,
                       long timeout)
                throws CmsException
Sets the timeout of a task.

Parameters:
taskId - the id of the task
timeout - the new timeout value
Throws:
CmsException - if something goes wrong

writeTaskLog

public void writeTaskLog(int taskid,
                         java.lang.String comment)
                  throws CmsException
Writes a new user tasklog for a task.

Parameters:
taskid - the Id of the task
comment - the description for the log
Throws:
CmsException - if operation was not successful

writeTaskLog

public void writeTaskLog(int taskId,
                         java.lang.String comment,
                         int taskType)
                  throws CmsException
Writes a new user tasklog for a task.

Parameters:
taskId - the id of the task
comment - the description for the log
taskType - the type of the tasklog, user task types must be greater than 100
Throws:
CmsException - if something goes wrong