Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: for the plan.

Jump to: navigation, search

Stardust/Knowledge Base/Java API/Reading Process Data

Reading Process Data of a Process Instance from outside its Context

(Versions: 5.3.17)
Assuming you have a

  • process instance with the OID 175 using
  • a structured data with the id CAData,
  • a primitive data of type Sting with the id ISINData

and want to read the data values of those two data from within the context of another process instance or from client code that is running completely outside any process context.

Within the context of a process instance we can inject process data to an activity instance via in data mappings that are mapped to the setter methods of our code. However, when data needs to be accessed from outside the context of its process instance, e.g. from within another unrelated process instance, then this is not possible. Process data is scoped per process instance. Code that is not executed within the context of an activity instance of the same process instance needs to use process data paths to access a process instance's data. The example below illustrates how this is done. The required process data paths have to be previously declared on the process definition of the target process instance.

In this example two data mappings on process definition level exist:

  • a data mapping with the id CorporateAction which is mapped to a structured data
  • a data mapping with the id ISIN that is mapped to data (field) of type String
Note that the code uses only the data mappings and their ids to fetch the data. The data mappings encapsulate the actual data access. The ids of the process data are not used in the code. The data mappings could be mapped to other process data or other fields in a structured data without breaking the code. Only the data mapping id needs to remain unchanged.
package test;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ag.carnot.error.ObjectNotFoundException;
import ag.carnot.workflow.runtime.ServiceFactory;
import ag.carnot.workflow.runtime.ServiceFactoryLocator;
import ag.carnot.workflow.runtime.WorkflowService;
public class QueryTest {
	public static final Logger log = LoggerFactory.getLogger(QueryTest.class);
	 * @param args
	public static void main(String[] args) {
		ServiceFactory sf = ServiceFactoryLocator.get("motu", "motu");
		WorkflowService wfs = sf.getWorkflowService();
		long oid = 175;
		// null in the second parameter fetches all datapaths.
		// You should limit this to the data you actually need!
		// Map<String, Serializable> dpaths = wfs.getInDataPaths(oid, null);
		Set<String> datapthIds = new HashSet<String>(Arrays
				.asList(new String[] { "CorporateAction", "ISIN" }));
		try {
			Map<String, Serializable> dpaths = wfs.getInDataPaths(oid,
			for (Iterator itr = dpaths.keySet().iterator(); itr.hasNext();) {
				String id = (String);
				Serializable dataValue = (Serializable) dpaths.get(id);
				if (dataValue instanceof Map) {"Data: " + id);
					Map<String, Serializable> sdata = (Map<String, Serializable>) dataValue;
					for (Map.Entry<String, Serializable> entry : sdata
							.entrySet()) {"   field: " + entry.getKey() + " = "
								+ entry.getValue());
				} else"Data: " + id + " value: " + dataValue);
		} catch (ObjectNotFoundException e) {
			log.error("The process definition does not have that data path");

Back to the top