Interface ProcessInstance<T>

All Known Subinterfaces:
CaseInstance<T>

public interface ProcessInstance<T>
  • Field Details

  • Method Details

    • process

      Process<T> process()
      Returns process definition associated with this process instance
      Returns:
      process definition of this process instance
    • start

      void start()
      Starts process instance
    • start

      void start(String trigger, String referenceId, Object data)
      Starts process instance with trigger
      Parameters:
      trigger - name of the trigger that will indicate what start node to trigger
      referenceId - optional reference id that points to a another component triggering this instance
    • startFrom

      void startFrom(String nodeId)
      Starts process instance from given node
      Parameters:
      nodeId - node id that should be used as the first node
    • startFrom

      void startFrom(String nodeId, String referenceId)
      Starts process instance from given node
      Parameters:
      nodeId - node id that should be used as the first node
      referenceId - optional reference id that points to a another component triggering this instance
    • send

      <S> void send(Signal<S> signal)
      Sends given signal into this process instance
      Parameters:
      signal - signal to be processed
    • abort

      void abort()
      Aborts this process instance
    • variables

      T variables()
      Returns process variables of this process instance
      Returns:
      variables of the process instance
    • updateVariables

      void updateVariables(T updates)
      Updates process variables of this process instance
    • status

      int status()
      Returns current status of this process instance
      Returns:
      the current status
    • subprocesses

      Collection<ProcessInstance<? extends Model>> subprocesses()
      Returns collection of currently active subprocess instances where this process instance is the parent;
      Returns:
      all active subprocesses if any or empty collection
    • subprocesses

      Collection<ProcessInstance<? extends Model>> subprocesses(ProcessInstanceReadMode mode)
      Returns collection of currently active subprocess instances where this process instance is the parent;
      Parameters:
      mode - mode that process instance should be loaded with
      Returns:
      all active subprocesses if any or empty collection
    • completeWorkItem

      void completeWorkItem(String id, Map<String,Object> variables, Policy<?>... policies)
      Completes work item belonging to this process instance with given variables
      Parameters:
      id - id of the work item to complete
      variables - optional variables
      policies - optional list of policies to be enforced
      Throws:
      WorkItemNotFoundException - in case work item with given id does not exist
    • abortWorkItem

      void abortWorkItem(String id, Policy<?>... policies)
      Aborts work item belonging to this process instance
      Parameters:
      id - id of the work item to complete
      policies - optional list of policies to be enforced
      Throws:
      WorkItemNotFoundException - in case work item with given id does not exist
    • failWorkItem

      void failWorkItem(String id, Throwable error)
      Marks work item as failure to allow triggering of error handling routines if any
      Parameters:
      id - id of the work item to complete
      error - actual error that happened during execution
      Throws:
      WorkItemNotFoundException - in case work item with given id does not exist
    • transitionWorkItem

      void transitionWorkItem(String id, Transition<?> transition)
      Transition work item belonging to this process instance not another life cycle phase
      Parameters:
      id - id of the work item to complete
      transition - target transition including phase, identity and data
      Throws:
      WorkItemNotFoundException - in case work item with given id does not exist
    • workItem

      WorkItem workItem(String workItemId, Policy<?>... policies)
      Returns work item identified by given id if found
      Parameters:
      workItemId - id of the work item
      policies - optional list of policies to be enforced
      Returns:
      work item with its parameters if found
      Throws:
      WorkItemNotFoundException - in case work item with given id does not exist
    • workItems

      List<WorkItem> workItems(Policy<?>... policies)
      Returns list of currently active work items.
      Parameters:
      policies - optional list of policies to be enforced
      Returns:
      non empty list of identifiers of currently active tasks.
    • id

      String id()
      Returns identifier of this process instance
      Returns:
      id of the process instance
    • businessKey

      String businessKey()
      Returns optional business key associated with this process instance
      Returns:
      business key if available otherwise null
    • description

      String description()
      Returns optional description of this process instance
      Returns:
      description of the process instance
    • parentProcessInstanceId

      String parentProcessInstanceId()
      Returns id of the parent process instance if this instance was started as subprocess
      Returns:
      instance id of the parent instance if available otherwise null
    • rootProcessInstanceId

      String rootProcessInstanceId()
      Returns id of the root process instance that this instance belongs to, if null it is then root instance itself
      Returns:
      instance id of the root instance if available otherwise null
    • rootProcessId

      String rootProcessId()
      Returns id of the root process definition that this instance belongs to, if null it is then root instance itself
      Returns:
      definition id of the root process if available otherwise null
    • startDate

      Date startDate()
      Returns startDate of this process instance
      Returns:
      date when this instance started
    • endDate

      Date endDate()
      Returns endDate of this process instance
      Returns:
      end date (completed or aborted) of this instance or null if this instance is not yet ended
    • expiresAtDate

      Date expiresAtDate()
      Returns optional expiresAtDate of this process instance
      Returns:
      calculated date when this instance expires or null
    • errors

      Returns process errors in case process instance is in error state.
      Returns:
      returns process errors
    • initiator

      Optional<String> initiator()
      Returns optional initiator of the process instance
      Returns:
      initiator (user id) if present
    • abortCode

      String abortCode()
      Returns abort code in case process instance was aborted
      Returns:
      error code that led to aborting of the instance
    • abortData

      Object abortData()
      Returns optional data associated with abort of the instance caused by error
      Returns:
      data associated with the error that led to aborting of the instance
    • tags

      Tags tags()
      Returns tags associated with this process instances
      Returns:
      currently associated tags
    • metadata

      default InstanceMetadata metadata()
      Returns instance metadata information
      Returns:
      metadata information about this instance
    • triggerNode

      void triggerNode(String nodeId)
      Triggers a node with given id to perform its associated logic
      Parameters:
      nodeId - unique id of the node to trigger
    • cancelNodeInstance

      void cancelNodeInstance(String nodeInstanceId)
      Cancels node instance with given nodeInstanceId which results in abort of any work being done by this node instance
      Parameters:
      nodeInstanceId - unique id of the node instance to be cancelled
    • retriggerNodeInstance

      void retriggerNodeInstance(String nodeInstanceId)
      Retriggers (canceling and triggering again) node instance with given nodeInstanceId This results in redoing the logic associated with given node instance
      Parameters:
      nodeInstanceId - unique id of the node instance to be cancelled
    • events

      Set<EventDescription<?>> events()
      Returns all active events that this process instance is capable of acting on.
      Returns:
      set of event descriptions for this process instance
    • milestones

      Collection<Milestone> milestones()
      Returns the process milestones
      Returns:
      All the process milestones with their current status
    • adHocFragments

      Collection<AdHocFragment> adHocFragments()
      Returns the process adHocFragments
      Returns:
      All the AdHocFragment in the process
    • disconnect

      void disconnect()
      Allows manually disconnect process instance to free up any taken resources. It is only required if unit of work is not used.
    • image

      String image(String path)
      Returns process image annotated with active nodes
      Parameters:
      path - current path that allows to build image links
      Returns:
      annotated process instance image
    • archive

      Archives this process instance by collecting all relevant information of it.
      Parameters:
      builder - an archive build implementation
      Returns:
      returns archived representation of this process instance