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 SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionbooleancanUserOwnTask(String username, String taskId) voidclaimTask(String taskId, String username, WorkflowHistory transaction) Assign a task to a specific user.If the task is already claimed you cannot claim again.voidcompleteTask(String taskId, String transitionName, WorkflowHistory transaction) Ends the task and takes the given transitionvoidcompleteTask(org.activiti.engine.task.Task task, String transitionName, WorkflowHistory transaction) Ends the task and takes the given transitionvoidvoiddeleteProcessInstance(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.ProcessDefinitiongetProcessDefinition(String processDefinitionId) Gets the definition of a processorg.activiti.engine.ProcessEngineorg.activiti.engine.runtime.ProcessInstancegetProcessInstanceById(String processInstanceId) Gets a ProcessInstance by the idorg.activiti.engine.history.HistoricProcessInstancegetProcessInstanceHistory(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.TaskgetTaskById(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.TaskgetTaskByProcessInstanceAndKey(String processInstanceId, String taskDefinitionKey) Retrieves a particular Task given by a key in a specific process instanceorg.activiti.engine.history.HistoricTaskInstancegetTaskHistory(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) voidsetProcessInstanceVariable(String processInstanceId, String name, Object value) voidsetTaskVariable(String taskId, String name, Object value) voidsetTemplateDAO(WorkflowTemplateDAO templateDAO) voidsetUserDAO(com.logicaldoc.core.security.user.UserDAO userDAO) startProcessInstance(String workflowName, Map<String, Object> variables, WorkflowHistory transaction) Starts a ProcessInstance by using the deployed definition namevoidstopProcessInstance(String processInstanceId) Stops a process instancevoidunclaimTask(String taskId) voidundeployWorkflow(String workflowName) A valid deployed Workflow-Processdefinition gets undeployed.
- 
Constructor Details- 
WorkflowEnginepublic WorkflowEngine()
 
- 
- 
Method Details- 
deployWorkflowDeploying 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
 
- 
deployWorkflowpublic 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
 
- 
undeployWorkflowA valid deployed Workflow-Processdefinition gets undeployed.- Parameters:
- workflowName- The process definition key
 
- 
startProcessInstancepublic 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 start
- variables- map of variables to be included in the execution dictionary
- transaction- informations regarding the actual session
- Returns:
- The newly started Process Instance ID(aka Workflow Instance)
- Throws:
- com.logicaldoc.core.PersistenceException- error at data layer
 
- 
getProcessDefinitionpublic 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
 
- 
deleteProcessInstanceStops and delete a process instance on using the corresponding processid- Parameters:
- processInstanceId- Id of the ProcessInstance to stop
 
- 
stopProcessInstanceStops a process instance- Parameters:
- processInstanceId- Id of the ProcessInstance to stop
 
- 
deleteAllActiveProcessInstancespublic void deleteAllActiveProcessInstances()
- 
getAllProcessInstancesGets all the process instances- Returns:
- list of process instances
 
- 
getAllProcessDefinitionspublic 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
 
- 
getTaskByIdRetrieves a particular Task given by a valid taskid.- Parameters:
- id- The TaskId
- Returns:
- the Task
 
- 
getTaskByProcessInstanceAndKeypublic 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 Instance
- taskDefinitionKey- The task definition key
- Returns:
- the Task
 
- 
getTaskByProcessDefinitionAndKeypublic 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 Definition
- taskDefinitionKey- The task definition key
- Returns:
- the tasks
 
- 
getTasksByProcessInstanceAndNamepublic 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 Instance
- taskName- The task name, it may be a like expression
- Returns:
- the Tasks that match the name criteria
 
- 
getAllActiveTasksAll current active Tasks will be returned. The suspended task instances will be not returned.- Returns:
- All active Tasks
 
- 
getAllActiveTasksByUserAll the tasks where the given user is assigned- Parameters:
- username- username of a user
- Returns:
- list of tasks
 
- 
getAllTasksThis methods is similar to 'getAllActiveTasks()', but also the suspended task instances will be returned.- Returns:
- All TaskInstances
 
- 
getTasksByAssigneeRetrieves user tasks that are assigned to the given user- Parameters:
- username- The Username
- Returns:
- List of tasks owned by the user
 
- 
getTasksSuspendedByAssigneeRetrieves user tasks that are assigned to the given user but are suspended- Parameters:
- username- The Username
- Returns:
- List of tasks owned by the user
 
- 
getTasksUserCanOwnpublic 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
 
- 
getSupervisorWorkflowTasksRetrieves 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
 
- 
getInvolvedWorkflowspublic 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
 
- 
canUserOwnTaskpublic boolean canUserOwnTask(String username, String taskId) throws com.logicaldoc.core.PersistenceException - Throws:
- com.logicaldoc.core.PersistenceException
 
- 
getCandidateUsers
- 
getCandidateGroups
- 
getTasksByProcessInstanceRetrieves all Tasks that has been started yet (but must not be ended).- Parameters:
- processInstanceId- identifier of the process instance
- Returns:
- List of TaskInstances
 
- 
claimTaskpublic 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 identifier
- username- the user that must be assigned
- transaction- informations regarding the actual session
- Throws:
- com.logicaldoc.core.PersistenceException- error at data layer
 
- 
unclaimTask
- 
completeTaskpublic 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 complete
- transitionName- ID of the transition to take
- transaction- the session details
- Throws:
- WorkflowValidationException- Validation errors
 
- 
completeTaskpublic 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 complete
- transitionName- ID of the transition to take
- transaction- current session details
- Throws:
- WorkflowValidationException- Validation errors
 
- 
getOutgoingTransitionspublic List<org.activiti.engine.impl.pvm.PvmTransition> getOutgoingTransitions(org.activiti.engine.task.Task task) 
- 
getOutgoingTransitions
- 
getProcessInstanceByIdGets a ProcessInstance by the id- Parameters:
- processInstanceId- the Process Instance ID
- Returns:
- object representing the instance
 
- 
getProcessInstanceVariables
- 
getProcessInstanceVariable
- 
setProcessInstanceVariable
- 
getTaskVariable
- 
setTaskVariable
- 
getActivityHistory
- 
getProcessInstanceHistorypublic org.activiti.engine.history.HistoricProcessInstance getProcessInstanceHistory(String instanceId) 
- 
getProcessInstanceHistoryByKey
- 
getTaskHistory
- 
getProcessInstanceIdsRetrieves the IDs of all the instances of a given workflow- Parameters:
- workflowName- The process definition key
- Returns:
- The list of process instance IDs
 
- 
getProcessEnginepublic org.activiti.engine.ProcessEngine getProcessEngine()
- 
setUserDAOpublic void setUserDAO(com.logicaldoc.core.security.user.UserDAO userDAO) 
- 
setTemplateDAO
 
-