}
public static void addDynamicSubProcess(
DynamicNodeInstance dynamicContext, ProcessRuntime ksession,
String processId, Map<String, Object> parameters) {
WorkflowProcessInstance processInstance = dynamicContext.getProcessInstance();
SubProcessNodeInstance subProcessNodeInstance = new SubProcessNodeInstance();
subProcessNodeInstance.setNodeInstanceContainer(dynamicContext);
subProcessNodeInstance.setProcessInstance(processInstance);
InternalWorkingMemory workingMemory = ((StatefulKnowledgeSessionImpl) ksession).session;
Process process = ((InternalRuleBase) workingMemory.getRuleBase()).getProcess(processId);
if (process == null) {
System.err.println("Could not find process " + processId);
System.err.println("Aborting process");
processInstance.setState(ProcessInstance.STATE_ABORTED);
} else {
((EventSupport) workingMemory).getRuleFlowEventSupport().fireBeforeRuleFlowNodeTriggered(subProcessNodeInstance, workingMemory);
ProcessInstance subProcessInstance = (ProcessInstance)
workingMemory.startProcess(processId, parameters);
((EventSupport) workingMemory).getRuleFlowEventSupport().fireAfterRuleFlowNodeTriggered(subProcessNodeInstance, (InternalWorkingMemory) workingMemory);