-
1. Re: can subprocess get its father process's parameter?
calca Aug 7, 2013 10:09 PM (in response to wangtrash)You have to:
- Create the variables in the subprocess.
- Use the parameters mapping to pass copy variables/expressions from parent process to subprocess.
http://docs.jboss.org/jbpm/v5.4/userguide/ch.core-basics.html#d0e1827
-
2. Re: can subprocess get its father process's parameter?
wangtrash Aug 9, 2013 4:48 AM (in response to calca)thank for your answer. but actually, I want to know how I can get the relationship between the processes in running. for example, in one workerItem handler, I can get current processID. how can I get this process's father's processID, or his father's father process ID?
-
3. Re: can subprocess get its father process's parameter?
calca Aug 9, 2013 4:14 PM (in response to wangtrash)You can also do it.
Starting from jbpm 5.4, you have the parent process id in audit tables:
At runtime, the processInstanceImpl class has the parent it in the metadata too, which is put when starting the subprocess
I think you should use the first option, but it depends on what you are trying to achieve.
-
4. Re: Re: can subprocess get its father process's parameter?
kornilovs Sep 6, 2013 6:28 AM (in response to wangtrash)for jbpm5.4
processInstance metaData contains key "ParentProcessInstanceId", but it work only for one iteration. You can't get parentparentProcessInstanceId but you can copy this parameter into process variable, like there:
create processInstanceListener and override beforeProcessStarted
@Override public void beforeProcessStarted(ProcessStartedEvent event) { Map<String, Object> metaData = ((WorkflowProcessInstanceImpl) event.getProcessInstance()).getMetaData(); if (metaData.containsKey("ParentProcessInstanceId")) { ((WorkflowProcessInstanceImpl) event.getProcessInstance()).setVariable( "ParentProcessInstanceId", metaData.get("ParentProcessInstanceId")); } } // getVariable from process instance public Object getVariable(long processInstanceId, String name) { ProcessInstance instance = ksession.getProcessInstance(processInstanceId); try { return ((WorkflowProcessInstanceImpl) instance).getVariable(name); } catch (Exception e) { logger.error("variable: " + name + " does not exist."); } return null; } public long getParentProcessInstanceId(long processInstanceId) { Long parentProcessInstanceId = (Long) getVariable(processInstanceId, "ParentProcessInstanceId"); return parentProcessInstanceId == null ? -1 : parentProcessInstanceId.longValue(); } public long getMainProcessInstanceId(long processInstanceId) { long parentProcessInstanceId = processInstanceId; while (getParentProcessInstanceId(parentProcessInstanceId) > 0) { parentProcessInstanceId = getParentProcessInstanceId(parentProcessInstanceId); } if (parentProcessInstanceId == processInstanceId) { return -1; } return parentProcessInstanceId; }