Querying Process Definition Details

The ProcessDefinitionQuery class is provided for building queries on process definitions. The following sections describes available methods for specific requirements.

Finding all Process Definitions from Active Model

Method findAll() retrieves all process definitions from an active model.

   public static ProcessDefinitionQuery findAll()
   {
      return new ProcessDefinitionQuery();
   }

Example Usage

The following example demonstrates how to use the API to retrieve all process definitions from all active models.

import org.eclipse.stardust.engine.api.ejb2.ServiceFactoryLocator;
import org.eclipse.stardust.engine.api.model.ProcessDefinition;
import org.eclipse.stardust.engine.api.query.ProcessDefinitionQuery;
import org.eclipse.stardust.engine.api.runtime.ProcessDefinitions;
import org.eclipse.stardust.engine.api.runtime.QueryService;
import org.eclipse.stardust.engine.api.runtime.ServiceFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
 
public class PDList {
 
   public static void main(String[] args) {
 
       final Logger log = LoggerFactory.getLogger(PDList.class);
 
      ServiceFactory sf = ServiceFactoryLocator.get("motu","motu");
      QueryService qs = sf.getQueryService();
      ProcessDefinitions pds = qs.getProcessDefinitions(ProcessDefinitionQuery.findAll());
 
      for (ProcessDefinition pd : pds) {
         log.info(pd.getQualifiedId());
      }
      sf.close();
   }
}

For details on further API used in the code above refer to the according Javadoc:

Finding all manually startable Processes

In case you like to retrieve all manually startable processes, use method findStartable().

   public static ProcessDefinitionQuery findStartable()
   {
      return findStartable("manual");
   }

Finding all manually startable Processes contained in a specific Model

Use method findStartable(long modelOID) to retrieve all manually startable processes that are contained in a model with a specific OID.

   public static ProcessDefinitionQuery findStartable(long modelOID)
   {
      ProcessDefinitionQuery query = findStartable("manual");
      query.where(MODEL_OID.isEqual(modelOID));
      return query;
   }

Example Usage

ProcessDefinitions pds = qs.getProcessDefinitions(ProcessDefinitionQuery.findStartable(pInstance.getModelOID()))

Finding the active deployed Model with specific Trigger Type

To retrieve the active deployed model with a specific trigger type, use method findStartable(String triggerType).

   public static ProcessDefinitionQuery findStartable(String triggerType)
   {
      ProcessDefinitionQuery query = new ProcessDefinitionQuery();
      query.where(TRIGGER_TYPE.isEqual(triggerType));
      return query;
   }

Trigger types could be one of the following:

Also trigger types from product integrations are supported, please check for available types.

Example Usage

ProcessDefinitions pds = qs.getProcessDefinitions(ProcessDefinitionQuery.findStartable("manual"))

Retrieving all Process Definitions providing a Process Interface with given Invocation Type

To retrieve all process definitions, which provide a process interface with a given particular invocation type, use the following method:

public static ProcessDefinitionQuery findProcessInterface(String invocationType)
   {
      ProcessDefinitionQuery query = new ProcessDefinitionQuery();
      query.where(INVOCATION_TYPE.isEqual(invocationType));
      return query;
   }

Hereby, parameter invocationType represents a String identifying the type of invocation for the process interface. It can have one of the following values, which are predefined filters matching process definition interfaces defining the according invocation type:

Example Usage

ProcessDefinitions pds = qs.getProcessDefinitions(ProcessDefinitionQuery.findProcessInterface(ProcessDefinitionQuery.SOAP_INVOCATION));
ProcessDefinitions pds = qs.getProcessDefinitions(ProcessDefinitionQuery.findProcessInterface(ProcessDefinitionQuery.REST_INVOCATION));
ProcessDefinitions pds = qs.getProcessDefinitions(ProcessDefinitionQuery.findProcessInterface(ProcessDefinitionQuery.BOTH_INVOCATION));