Class 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 Detail

      • WorkflowEngine

        public WorkflowEngine()
    • 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)
                                    throws com.logicaldoc.core.PersistenceException
        Starts a ProcessInstance by using the deployed definition name
        Parameters:
        workflowName - name of the workflow to start
        transaction - informations regarding the actual session
        variables - map of variables to be included in the execution dictionary
        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

        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 Instance
        taskDefinitionKey - 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 Definition
        taskDefinitionKey - 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 - identifier of the user to check
        Returns:
        list of tasks
      • canUserOwnTask

        public boolean canUserOwnTask​(String username,
                                      String taskId)
      • getCandidateUsers

        public List<String> getCandidateUsers​(org.activiti.engine.task.Task task)
      • getCandidateGroups

        public List<String> getCandidateGroups​(org.activiti.engine.task.Task task)
      • 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)
                       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

        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 complete
        transitionName - 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 complete
        transitionName - 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)
      • setTaskVariable

        public void setTaskVariable​(String taskId,
                                    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)