Package com.logicaldoc.workflow
Class WorkflowEngine
java.lang.Object
com.logicaldoc.workflow.WorkflowEngine
The class "WorkflowEngine" is the bridge between LogicalDOC and the Activiti
Engine.
- Since:
- 6.8
- Author:
- Marco Meschieri - LogicalDOC
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
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, WorkflowHistory transaction) Ends the task and takes the given transitionvoid
completeTask
(org.activiti.engine.task.Task task, String transitionName, WorkflowHistory transaction) Ends the task and takes the given transitionvoid
void
deleteProcessInstance
(String processInstanceId) Stops and delete a process instance on using the corresponding processiddeployWorkflow
(String workflowName, InputStream processDefinition) Deploying of a workflow-process definition.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> 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> Gets all the process instancesList
<org.activiti.engine.task.Task> This methods is similar to 'getAllActiveTasks()', but also the suspended task instances will be returned.getCandidateGroups
(org.activiti.engine.task.Task task) 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
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) getProcessInstanceIds
(String workflowName) Retrieves the IDs of all the instances of a given workflowgetProcessInstanceVariable
(String processInstanceId, String name) 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> getTasksByProcessInstanceAndName
(String processInstanceId, String taskName) Retrieves the tasks in a given instance that match the name expressionList
<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.getTaskVariable
(String taskId, String name) 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.user.UserDAO userDAO) startProcessInstance
(String workflowName, Map<String, Object> variables, WorkflowHistory transaction) Starts a ProcessInstance by using the deployed definition namevoid
stopProcessInstance
(String processInstanceId) Stops a process instancevoid
unclaimTask
(String taskId) void
undeployWorkflow
(String workflowName) A valid deployed Workflow-Processdefinition gets undeployed.
-
Constructor Details
-
WorkflowEngine
public WorkflowEngine()
-
-
Method Details
-
deployWorkflow
Deploying of a workflow-process definition.- Parameters:
workflowName
- The name of the workflow.processDefinition
- The serialized content of the processedefinition (Activiti BPMN2 standard).- Returns:
- The id of the deployment
-
deployWorkflow
public String deployWorkflow(String workflowName, String processDefinition) throws UnsupportedEncodingException Deploying of a workflow-process definition.- Parameters:
workflowName
- The name of the workflow.processDefinition
- The serialized content of the process definition (Activiti BPMN2 standard).- Returns:
- The id of the deployment
- Throws:
UnsupportedEncodingException
- the process definition is not UTF-8
-
undeployWorkflow
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) throws com.logicaldoc.core.PersistenceExceptionStarts a ProcessInstance by using the deployed definition name- Parameters:
workflowName
- name of the workflow to startvariables
- map of variables to be included in the execution dictionarytransaction
- informations regarding the actual session- Returns:
- The newly started Process Instance ID(aka Workflow Instance)
- Throws:
com.logicaldoc.core.PersistenceException
- error at data layer
-
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
Stops and delete a process instance on using the corresponding processid- Parameters:
processInstanceId
- Id of the ProcessInstance to stop
-
stopProcessInstance
Stops a process instance- Parameters:
processInstanceId
- Id of the ProcessInstance to stop
-
deleteAllActiveProcessInstances
public void deleteAllActiveProcessInstances() -
getAllProcessInstances
Gets all the process instances- Returns:
- list of process instances
-
getAllProcessDefinitions
public List<org.activiti.engine.repository.ProcessDefinition> getAllProcessDefinitions(Long tenantId) throws com.logicaldoc.core.PersistenceException Retrieves all valid deployed ProcessDefinitions- Parameters:
tenantId
- Optional tenant specification- Returns:
- All process-definitions
- Throws:
com.logicaldoc.core.PersistenceException
- Error in the database
-
getTaskById
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
-
getTasksByProcessInstanceAndName
public List<org.activiti.engine.task.Task> getTasksByProcessInstanceAndName(String processInstanceId, String taskName) Retrieves the tasks in a given instance that match the name expression- Parameters:
processInstanceId
- ID of the Process InstancetaskName
- The task name, it may be a like expression- Returns:
- the Tasks that match the name criteria
-
getAllActiveTasks
All current active Tasks will be returned. The suspended task instances will be not returned.- Returns:
- All active Tasks
-
getAllActiveTasksByUser
All the tasks where the given user is assigned- Parameters:
username
- username of a user- Returns:
- list of tasks
-
getAllTasks
This methods is similar to 'getAllActiveTasks()', but also the suspended task instances will be returned.- Returns:
- All TaskInstances
-
getTasksByAssignee
Retrieves user tasks that are assigned to the given user- Parameters:
username
- The Username- Returns:
- List of tasks owned by the user
-
getTasksSuspendedByAssignee
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) throws com.logicaldoc.core.PersistenceException Retrieves the tasks a user can own.- Parameters:
username
- The Username- Returns:
- List of tasks owned by the user
- Throws:
com.logicaldoc.core.PersistenceException
- Error in the data layer
-
getSupervisorWorkflowTasks
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) throws com.logicaldoc.core.PersistenceException Retrieves all the current tasks of the workflows the given user was involved in(at any time)- Parameters:
username
- identifier of the user to check- Returns:
- list of tasks
- Throws:
com.logicaldoc.core.PersistenceException
- Error in the data layer
-
canUserOwnTask
public boolean canUserOwnTask(String username, String taskId) throws com.logicaldoc.core.PersistenceException - Throws:
com.logicaldoc.core.PersistenceException
-
getCandidateUsers
-
getCandidateGroups
-
getTasksByProcessInstance
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) throws com.logicaldoc.core.PersistenceException 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- Throws:
com.logicaldoc.core.PersistenceException
- error at data layer
-
unclaimTask
-
completeTask
public void completeTask(org.activiti.engine.task.Task task, String transitionName, WorkflowHistory transaction) throws WorkflowValidationException Ends the task and takes the given transition- Parameters:
task
- the task to completetransitionName
- ID of the transition to taketransaction
- the session details- Throws:
WorkflowValidationException
- Validation errors
-
completeTask
public void completeTask(String taskId, String transitionName, WorkflowHistory transaction) throws WorkflowValidationException Ends the task and takes the given transition- Parameters:
taskId
- ID of the task to completetransitionName
- ID of the transition to taketransaction
- current session details- Throws:
WorkflowValidationException
- Validation errors
-
getOutgoingTransitions
public List<org.activiti.engine.impl.pvm.PvmTransition> getOutgoingTransitions(org.activiti.engine.task.Task task) -
getOutgoingTransitions
-
getProcessInstanceById
Gets a ProcessInstance by the id- Parameters:
processInstanceId
- the Process Instance ID- Returns:
- object representing the instance
-
getProcessInstanceVariables
-
getProcessInstanceVariable
-
setProcessInstanceVariable
-
getTaskVariable
-
setTaskVariable
-
getActivityHistory
-
getProcessInstanceHistory
public org.activiti.engine.history.HistoricProcessInstance getProcessInstanceHistory(String instanceId) -
getProcessInstanceHistoryByKey
-
getTaskHistory
-
getProcessInstanceIds
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.user.UserDAO userDAO) -
setTemplateDAO
-