The ProcessDefinitionQuery class is provided for building queries on process definitions. The following sections describes available methods for specific requirements.
Method findAll() retrieves all process definitions from an active model.
public static ProcessDefinitionQuery findAll()
{
return new ProcessDefinitionQuery();
}
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:
In case you like to retrieve all manually startable processes, use method
findStartable().
public static ProcessDefinitionQuery findStartable()
{
return findStartable("manual");
}
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;
}
ProcessDefinitions pds = qs.getProcessDefinitions(ProcessDefinitionQuery.findStartable(pInstance.getModelOID()))
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:
manual - for manual triggersjms - for JMS triggerstimer - for timer based triggersmail - for mail triggersAlso trigger types from product integrations are supported, please check for available types.
ProcessDefinitions pds = qs.getProcessDefinitions(ProcessDefinitionQuery.findStartable("manual"))
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:
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));