Package com.logicaldoc.workflow
Class WorkflowEngine
- java.lang.Object
-
- com.logicaldoc.workflow.WorkflowEngine
-
public class WorkflowEngine extends Object
The class "WorkflowEngine" is the bridge between LogicalDOC and the Activiti Engine.- Since:
- 6.8
- Author:
- Marco Meschieri - LogicalDOC
-
-
Constructor Summary
Constructors Constructor Description WorkflowEngine()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canUserOwnTask(String username, String taskId)
void
claimTask(String taskId, String username, WorkflowHistory transaction)
Assign a task to a specific user.If the task is already claimed you cannot claim again.void
completeTask(String taskId, String transitionName)
Ends the task and takes the given transitionvoid
completeTask(org.activiti.engine.task.Task task, String transitionName)
Ends the task and takes the given transitionvoid
deleteAllActiveProcessInstances()
void
deleteProcessInstance(String processInstanceId)
Stops and delete a process instance on using the corresponding processidString
deployWorkflow(String workflowName, InputStream processDefinition)
Deploying of a workflow-process definition.String
deployWorkflow(String workflowName, String processDefinition)
Deploying of a workflow-process definition.List<org.activiti.engine.history.HistoricActivityInstance>
getActivityHistory(String instanceId)
List<org.activiti.engine.task.Task>
getAllActiveTasks()
All current active Tasks will be returned.List<org.activiti.engine.task.Task>
getAllActiveTasksByUser(String username)
All the tasks where the given user is assignedList<org.activiti.engine.repository.ProcessDefinition>
getAllProcessDefinitions(Long tenantId)
Retrieves all valid deployed ProcessDefinitionsList<org.activiti.engine.runtime.ProcessInstance>
getAllProcessInstances()
Gets all the process instancesList<org.activiti.engine.task.Task>
getAllTasks()
This methods is similar to 'getAllActiveTasks()', but also the suspended task instances will be returned.List<String>
getCandidateGroups(org.activiti.engine.task.Task task)
List<String>
getCandidateUsers(org.activiti.engine.task.Task task)
List<org.activiti.engine.task.Task>
getInvolvedWorkflows(String username)
Retrieves all the current tasks of the workflows the given user was involved in(at any time)List<org.activiti.engine.impl.pvm.PvmTransition>
getOutgoingTransitions(String executionId, String processDefinitionId, String taskDefinitionKey)
List<org.activiti.engine.impl.pvm.PvmTransition>
getOutgoingTransitions(org.activiti.engine.task.Task task)
org.activiti.engine.repository.ProcessDefinition
getProcessDefinition(String processDefinitionId)
Gets the definition of a processorg.activiti.engine.ProcessEngine
getProcessEngine()
org.activiti.engine.runtime.ProcessInstance
getProcessInstanceById(String processInstanceId)
Gets a ProcessInstance by the idorg.activiti.engine.history.HistoricProcessInstance
getProcessInstanceHistory(String instanceId)
List<org.activiti.engine.history.HistoricProcessInstance>
getProcessInstanceHistoryByKey(String processDefinitionKey)
List<String>
getProcessInstanceIds(String workflowName)
Retrieves the IDs of all the instances of a given workflowObject
getProcessInstanceVariable(String processInstanceId, String name)
Map<String,Object>
getProcessInstanceVariables(String processInstanceId)
List<org.activiti.engine.task.Task>
getSupervisorWorkflowTasks(String username)
Retrieves all the tasks of the workflow for which the current user (not administator) is one of the supervisorsorg.activiti.engine.task.Task
getTaskById(String id)
Retrieves a particular Task given by a valid taskid.List<org.activiti.engine.task.Task>
getTaskByProcessDefinitionAndKey(String processDefinitionId, String taskDefinitionKey)
Retrieves tasks given by a key in a specific process definitionorg.activiti.engine.task.Task
getTaskByProcessInstanceAndKey(String processInstanceId, String taskDefinitionKey)
Retrieves a particular Task given by a key in a specific process instanceorg.activiti.engine.history.HistoricTaskInstance
getTaskHistory(String taskId)
List<org.activiti.engine.task.Task>
getTasksByAssignee(String username)
Retrieves user tasks that are assigned to the given userList<org.activiti.engine.task.Task>
getTasksByProcessInstance(String processInstanceId)
Retrieves all Tasks that has been started yet (but must not be ended).List<org.activiti.engine.task.Task>
getTasksSuspendedByAssignee(String username)
Retrieves user tasks that are assigned to the given user but are suspendedList<org.activiti.engine.task.Task>
getTasksUserCanOwn(String username)
Retrieves the tasks a user can own.Object
getTaskVariable(String taskId, String name)
void
setHistoryDAO(WorkflowHistoryDAO historyDAO)
void
setProcessInstanceVariable(String processInstanceId, String name, Object value)
void
setTaskVariable(String taskId, String name, Object value)
void
setTemplateDAO(WorkflowTemplateDAO templateDAO)
void
setUserDAO(com.logicaldoc.core.security.dao.UserDAO userDAO)
String
startProcessInstance(String workflowName, Map<String,Object> variables, WorkflowHistory transaction)
Starts a ProcessInstance by using the deployed definition namevoid
unclaimTask(String taskId)
void
undeployWorkflow(String workflowName)
A valid deployed Workflow-Processdefinition gets undeployed.
-
-
-
Method Detail
-
deployWorkflow
public String deployWorkflow(String workflowName, InputStream processDefinition)
Deploying of a workflow-process definition.- Parameters:
processDefinition
- The serialized content of the processedefinition (Activiti BPMN2 standard).workflowName
- The name of the workflow.- Returns:
- The id of the deployment
-
deployWorkflow
public String deployWorkflow(String workflowName, String processDefinition) throws UnsupportedEncodingException
Deploying of a workflow-process definition.- Parameters:
processDefinition
- The serialized content of the process definition (Activiti BPMN2 standard).workflowName
- The name of the workflow.- Returns:
- The id of the deployment
- Throws:
UnsupportedEncodingException
- the process definition is not UTF-8
-
undeployWorkflow
public void undeployWorkflow(String workflowName)
A valid deployed Workflow-Processdefinition gets undeployed.- Parameters:
workflowName
- The process definition key
-
startProcessInstance
public String startProcessInstance(String workflowName, Map<String,Object> variables, WorkflowHistory transaction)
Starts a ProcessInstance by using the deployed definition name- Parameters:
workflowName
- name of the workflow to starttransaction
- informations regarding the actual sessionvariables
- map of variables to be included in the execution dictionary- Returns:
- The newly started Process Instance ID(aka Workflow Instance)
-
getProcessDefinition
public org.activiti.engine.repository.ProcessDefinition getProcessDefinition(String processDefinitionId)
Gets the definition of a process- Parameters:
processDefinitionId
- Identifier of the process definition- Returns:
- The process definition
-
deleteProcessInstance
public void deleteProcessInstance(String processInstanceId)
Stops and delete a process instance on using the corresponding processid- Parameters:
processInstanceId
- Id of the ProcessInstance to stop
-
deleteAllActiveProcessInstances
public void deleteAllActiveProcessInstances()
-
getAllProcessInstances
public List<org.activiti.engine.runtime.ProcessInstance> getAllProcessInstances()
Gets all the process instances- Returns:
- list of process instances
-
getAllProcessDefinitions
public List<org.activiti.engine.repository.ProcessDefinition> getAllProcessDefinitions(Long tenantId)
Retrieves all valid deployed ProcessDefinitions- Parameters:
tenantId
- Optional tenant specification- Returns:
- All process-definitions
-
getTaskById
public org.activiti.engine.task.Task getTaskById(String id)
Retrieves a particular Task given by a valid taskid.- Parameters:
id
- The TaskId- Returns:
- the Task
-
getTaskByProcessInstanceAndKey
public org.activiti.engine.task.Task getTaskByProcessInstanceAndKey(String processInstanceId, String taskDefinitionKey)
Retrieves a particular Task given by a key in a specific process instance- Parameters:
processInstanceId
- ID of the Process InstancetaskDefinitionKey
- The task definition key- Returns:
- the Task
-
getTaskByProcessDefinitionAndKey
public List<org.activiti.engine.task.Task> getTaskByProcessDefinitionAndKey(String processDefinitionId, String taskDefinitionKey)
Retrieves tasks given by a key in a specific process definition- Parameters:
processDefinitionId
- ID of the Process DefinitiontaskDefinitionKey
- The task definition key- Returns:
- the tasks
-
getAllActiveTasks
public List<org.activiti.engine.task.Task> getAllActiveTasks()
All current active Tasks will be returned. The suspended task instances will be not returned.- Returns:
- All active Tasks
-
getAllActiveTasksByUser
public List<org.activiti.engine.task.Task> getAllActiveTasksByUser(String username)
All the tasks where the given user is assigned- Parameters:
username
- username of a user- Returns:
- list of tasks
-
getAllTasks
public List<org.activiti.engine.task.Task> getAllTasks()
This methods is similar to 'getAllActiveTasks()', but also the suspended task instances will be returned.- Returns:
- All TaskInstances
-
getTasksByAssignee
public List<org.activiti.engine.task.Task> getTasksByAssignee(String username)
Retrieves user tasks that are assigned to the given user- Parameters:
username
- The Username- Returns:
- List of tasks owned by the user
-
getTasksSuspendedByAssignee
public List<org.activiti.engine.task.Task> getTasksSuspendedByAssignee(String username)
Retrieves user tasks that are assigned to the given user but are suspended- Parameters:
username
- The Username- Returns:
- List of tasks owned by the user
-
getTasksUserCanOwn
public List<org.activiti.engine.task.Task> getTasksUserCanOwn(String username)
Retrieves the tasks a user can own.- Parameters:
username
- The Username- Returns:
- List of tasks owned by the user
-
getSupervisorWorkflowTasks
public List<org.activiti.engine.task.Task> getSupervisorWorkflowTasks(String username)
Retrieves all the tasks of the workflow for which the current user (not administator) is one of the supervisors- Parameters:
username
- username of a supervisor- Returns:
- list of tasks
-
getInvolvedWorkflows
public List<org.activiti.engine.task.Task> getInvolvedWorkflows(String username)
Retrieves all the current tasks of the workflows the given user was involved in(at any time)- Parameters:
username
- username of a workflow- Returns:
- list of tasks
-
getTasksByProcessInstance
public List<org.activiti.engine.task.Task> getTasksByProcessInstance(String processInstanceId)
Retrieves all Tasks that has been started yet (but must not be ended).- Parameters:
processInstanceId
- identifier of the process instance- Returns:
- List of TaskInstances
-
claimTask
public void claimTask(String taskId, String username, WorkflowHistory transaction)
Assign a task to a specific user.If the task is already claimed you cannot claim again.- Parameters:
taskId
- the task identifierusername
- the user that must be assignedtransaction
- informations regarding the actual session
-
unclaimTask
public void unclaimTask(String taskId)
-
completeTask
public void completeTask(org.activiti.engine.task.Task task, String transitionName)
Ends the task and takes the given transition- Parameters:
task
- the task to completetransitionName
- ID of the transition to take
-
completeTask
public void completeTask(String taskId, String transitionName)
Ends the task and takes the given transition- Parameters:
taskId
- ID of the task to completetransitionName
- ID of the transition to take
-
getOutgoingTransitions
public List<org.activiti.engine.impl.pvm.PvmTransition> getOutgoingTransitions(org.activiti.engine.task.Task task)
-
getOutgoingTransitions
public List<org.activiti.engine.impl.pvm.PvmTransition> getOutgoingTransitions(String executionId, String processDefinitionId, String taskDefinitionKey)
-
getProcessInstanceById
public org.activiti.engine.runtime.ProcessInstance getProcessInstanceById(String processInstanceId)
Gets a ProcessInstance by the id- Parameters:
processInstanceId
- the Process Instance ID- Returns:
- object representing the instance
-
getProcessInstanceVariables
public Map<String,Object> getProcessInstanceVariables(String processInstanceId)
-
getProcessInstanceVariable
public Object getProcessInstanceVariable(String processInstanceId, String name)
-
setProcessInstanceVariable
public void setProcessInstanceVariable(String processInstanceId, String name, Object value)
-
getActivityHistory
public List<org.activiti.engine.history.HistoricActivityInstance> getActivityHistory(String instanceId)
-
getProcessInstanceHistory
public org.activiti.engine.history.HistoricProcessInstance getProcessInstanceHistory(String instanceId)
-
getProcessInstanceHistoryByKey
public List<org.activiti.engine.history.HistoricProcessInstance> getProcessInstanceHistoryByKey(String processDefinitionKey)
-
getTaskHistory
public org.activiti.engine.history.HistoricTaskInstance getTaskHistory(String taskId)
-
getProcessInstanceIds
public List<String> getProcessInstanceIds(String workflowName)
Retrieves the IDs of all the instances of a given workflow- Parameters:
workflowName
- The process definition key- Returns:
- The list of process instance IDs
-
getProcessEngine
public org.activiti.engine.ProcessEngine getProcessEngine()
-
setUserDAO
public void setUserDAO(com.logicaldoc.core.security.dao.UserDAO userDAO)
-
setHistoryDAO
public void setHistoryDAO(WorkflowHistoryDAO historyDAO)
-
setTemplateDAO
public void setTemplateDAO(WorkflowTemplateDAO templateDAO)
-
-