Workflow Processing to Abort and Start Subprocess

This chapter describes the usage of Stardust API to abort and start subprocesses:

Aborting and Starting a Process

The WorkflowService provides a method spawnPeerProcessInstance, which allows to abort the originating process and start a peer process. The user should have the right to abort the originating process if the abortProcessInstance parameter is set to true, otherwise an IllegalArgumentException occurs. Also, the peer process should be a startable process.

   public ProcessInstance spawnPeerProcessInstance(long processInstanceOid,
         String spawnProcessID, boolean copyData, Map<String, ? extends Serializable> data,
         boolean abortProcessInstance, String comment) throws IllegalOperationException,
         ObjectNotFoundException, InvalidArgumentException;

Parameters are the following:

The required permission to execute this method is spawnPeerProcessInstance.

You can use a generalized implementation of this method in case you like to switch between versions of a process definition and perform relocation in the same step. Refer to the next chapter Relocating Activities for details.

Using the ProcessInstanceQuery class, you can find process instances to which a process instance is linked to via the given link type(s) and direction.

public class ProcessInstanceQuery extends Query
{
   ...

   /**
    * Creates a query for finding process instances the given process instance is linked to via the given link type(s) and direction.
    *
    * @param piOid the OID of the process instance the query should be executed for
    * @param direction the direction of the links that should be taken into account when determining the linked process instances
    * @param linkType the link types that should be taken into account when determining the linked process instances
    * @return ...
    */
   public static ProcessInstanceQuery findLinked(long processInstanceOid, LinkDirection direction, String ... linkType);
}

To specify the direction, use ProcessInstanceDetailsOptions

public enum LinkDirection
{
  TO,
  FROM,
  TO_FROM;
}

To view the linked processes and their details, you need to specify the ProcessInstanceDetailsPolicy and the subsequent enum class ProcessInstanceDetailsOptions.

public enum ProcessInstanceDetailsOptions
{
   ...
	
   /**
   * The process instance details will contain information about the linked process instances.
   */
  WITH_LINK_INFO
}

Note that when using the API to abort and start a process, you may get a ConcurrencyException. In that case, wait for sometime and retry the API call.