use of io.automatiko.engine.api.definition.process.Process in project automatiko-engine by automatiko-io.
the class DynamicUtils method executeSubProcess.
private static String executeSubProcess(InternalProcessRuntime runtime, String processId, Map<String, Object> parameters, ProcessInstance processInstance, SubProcessNodeInstance subProcessNodeInstance) {
Process process = runtime.getProcess(processId);
if (process == null) {
logger.error("Could not find process {}", processId);
throw new IllegalArgumentException("No process definition found with id: " + processId);
} else {
ProcessEventSupport eventSupport = runtime.getProcessEventSupport();
eventSupport.fireBeforeNodeTriggered(subProcessNodeInstance, runtime);
ProcessInstance subProcessInstance = null;
if (((WorkflowProcessInstanceImpl) processInstance).getCorrelationKey() != null) {
List<String> businessKeys = new ArrayList<>();
businessKeys.add(((WorkflowProcessInstanceImpl) processInstance).getCorrelationKey());
businessKeys.add(processId);
businessKeys.add(String.valueOf(System.currentTimeMillis()));
CorrelationKey subProcessCorrelationKey = new StringCorrelationKey(businessKeys.stream().collect(Collectors.joining(":")));
subProcessInstance = (ProcessInstance) runtime.createProcessInstance(processId, subProcessCorrelationKey, parameters);
} else {
subProcessInstance = (ProcessInstance) runtime.createProcessInstance(processId, parameters);
}
((ProcessInstanceImpl) subProcessInstance).setMetaData("ParentProcessInstanceId", processInstance.getId());
((ProcessInstanceImpl) subProcessInstance).setParentProcessInstanceId(processInstance.getId());
subProcessInstance = (ProcessInstance) runtime.startProcessInstance(subProcessInstance.getId());
subProcessNodeInstance.internalSetProcessInstanceId(subProcessInstance.getId());
eventSupport.fireAfterNodeTriggered(subProcessNodeInstance, runtime);
if (subProcessInstance.getState() == io.automatiko.engine.api.runtime.process.ProcessInstance.STATE_COMPLETED) {
subProcessNodeInstance.triggerCompleted();
} else {
subProcessNodeInstance.addEventListeners();
}
return subProcessInstance.getId();
}
}
use of io.automatiko.engine.api.definition.process.Process in project automatiko-engine by automatiko-io.
the class DefinitionsHandler method end.
public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
final Element element = parser.endElementBuilder();
Definitions definitions = (Definitions) parser.getCurrent();
String namespace = element.getAttribute("targetNamespace");
List<Process> processes = ((ProcessBuildData) parser.getData()).getProcesses();
Map<String, ItemDefinition> itemDefinitions = (Map<String, ItemDefinition>) ((ProcessBuildData) parser.getData()).getMetaData("ItemDefinitions");
List<Interface> interfaces = (List<Interface>) ((ProcessBuildData) parser.getData()).getMetaData("Interfaces");
for (Process process : processes) {
ExecutableProcess ruleFlowProcess = (ExecutableProcess) process;
ruleFlowProcess.setMetaData("TargetNamespace", namespace);
postProcessItemDefinitions(ruleFlowProcess, itemDefinitions, parser.getClassLoader());
postProcessInterfaces(ruleFlowProcess, interfaces);
postProcessNodes(ruleFlowProcess, Collections.emptyList(), parser);
}
definitions.setTargetNamespace(namespace);
return definitions;
}
use of io.automatiko.engine.api.definition.process.Process in project automatiko-engine by automatiko-io.
the class XmlBPMNProcessDumper method readProcess.
@Override
public Process readProcess(String processXml) {
SemanticModules semanticModules = new SemanticModules();
semanticModules.addSemanticModule(new BPMNSemanticModule());
semanticModules.addSemanticModule(new BPMNExtensionsSemanticModule());
semanticModules.addSemanticModule(new BPMNDISemanticModule());
XmlProcessReader xmlReader = new XmlProcessReader(semanticModules, Thread.currentThread().getContextClassLoader());
try {
List<Process> processes = xmlReader.read(new StringReader(processXml));
return processes.get(0);
} catch (Throwable t) {
t.printStackTrace();
return null;
}
}
use of io.automatiko.engine.api.definition.process.Process in project automatiko-engine by automatiko-io.
the class XmlBPMNProcessDumper method visitHeader.
protected void visitHeader(WorkflowProcess process, StringBuilder xmlDump, int metaDataType) {
Map<String, Object> metaData = getMetaData(process.getMetaData());
Set<String> imports = ((io.automatiko.engine.workflow.base.core.Process) process).getImports();
Map<String, String> globals = ((io.automatiko.engine.workflow.base.core.Process) process).getGlobals();
if ((imports != null && !imports.isEmpty()) || (globals != null && globals.size() > 0) || !metaData.isEmpty()) {
xmlDump.append(" <extensionElements>" + EOL);
if (imports != null) {
for (String s : imports) {
xmlDump.append(" <tns:import name=\"" + s + "\" />" + EOL);
}
}
if (globals != null) {
for (Map.Entry<String, String> global : globals.entrySet()) {
xmlDump.append(" <tns:global identifier=\"" + global.getKey() + "\" type=\"" + global.getValue() + "\" />" + EOL);
}
}
writeMetaData(getMetaData(process.getMetaData()), xmlDump);
xmlDump.append(" </extensionElements>" + EOL);
}
// TODO: function imports
// TODO: exception handlers
VariableScope variableScope = (VariableScope) ((io.automatiko.engine.workflow.base.core.Process) process).getDefaultContext(VariableScope.VARIABLE_SCOPE);
if (variableScope != null) {
visitVariables(variableScope.getVariables(), xmlDump);
}
visitLanes(process, xmlDump);
}
use of io.automatiko.engine.api.definition.process.Process in project automatiko-engine by automatiko-io.
the class BPMNPlaneHandler method end.
public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
parser.endElementBuilder();
ProcessInfo processInfo = (ProcessInfo) parser.getCurrent();
List<Process> processes = ((ProcessBuildData) parser.getData()).getProcesses();
ExecutableProcess process = null;
for (Process p : processes) {
if (p.getId() != null && p.getId().equals(processInfo.getProcessRef())) {
process = (ExecutableProcess) p;
break;
}
}
if (process != null) {
for (NodeInfo nodeInfo : processInfo.getNodeInfos()) {
processNodeInfo(nodeInfo, process.getNodes());
}
postProcessNodeOffset(process.getNodes(), 0, 0);
for (ConnectionInfo connectionInfo : processInfo.getConnectionInfos()) {
if (connectionInfo.getBendpoints() != null) {
processConnectionInfo(connectionInfo, process.getNodes());
}
}
}
return processInfo;
}
Aggregations