use of io.automatiko.engine.workflow.process.core.node.CompositeContextNode in project automatiko-engine by automatiko-io.
the class CompositeNodeHandler method createNode.
protected Node createNode() {
CompositeContextNode result = new CompositeContextNode();
VariableScope variableScope = new VariableScope();
result.addContext(variableScope);
result.setDefaultContext(variableScope);
return result;
}
use of io.automatiko.engine.workflow.process.core.node.CompositeContextNode in project automatiko-engine by automatiko-io.
the class SubProcessHandler method handleCompositeContextNode.
@SuppressWarnings("unchecked")
protected void handleCompositeContextNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
super.handleNode(node, element, uri, localName, parser);
CompositeContextNode compositeNode = (CompositeContextNode) node;
List<SequenceFlow> connections = (List<SequenceFlow>) compositeNode.getMetaData(ProcessHandler.CONNECTIONS);
handleScript(compositeNode, element, "onEntry");
handleScript(compositeNode, element, "onExit");
List<IntermediateLink> throwLinks = (List<IntermediateLink>) compositeNode.getMetaData(ProcessHandler.LINKS);
ProcessHandler.linkIntermediateLinks(compositeNode, throwLinks);
ProcessHandler processHandler = new ProcessHandler();
processHandler.linkConnections(compositeNode, connections);
processHandler.linkBoundaryEvents(compositeNode);
// This must be done *after* linkConnections(process, connections)
// because it adds hidden connections for compensations
List<Association> associations = (List<Association>) compositeNode.getMetaData(ProcessHandler.ASSOCIATIONS);
ProcessHandler.linkAssociations((Definitions) compositeNode.getMetaData("Definitions"), compositeNode, associations);
// TODO: do we fully support interruping ESP's?
/**
* for( org.kie.api.definition.process.Node subNode : compositeNode.getNodes() )
* { if( subNode instanceof StartNode ) { if( ! ((StartNode)
* subNode).isInterrupting() ) { throw new
* IllegalArgumentException("Non-interrupting event subprocesses are not yet
* fully supported." ); } } }
*/
}
use of io.automatiko.engine.workflow.process.core.node.CompositeContextNode in project automatiko-engine by automatiko-io.
the class SubProcessHandler method createNode.
protected Node createNode(Attributes attrs) {
CompositeContextNode subProcessNode = new CompositeContextNode();
String eventSubprocessAttribute = attrs.getValue("triggeredByEvent");
if (eventSubprocessAttribute != null && Boolean.parseBoolean(eventSubprocessAttribute)) {
subProcessNode = new EventSubProcessNode();
}
VariableScope variableScope = new VariableScope();
subProcessNode.addContext(variableScope);
subProcessNode.setDefaultContext(variableScope);
String compensation = attrs.getValue("isForCompensation");
if (compensation != null) {
boolean isForCompensation = Boolean.parseBoolean(compensation);
if (isForCompensation) {
subProcessNode.setMetaData("isForCompensation", isForCompensation);
}
}
subProcessNode.setAutoComplete(true);
return subProcessNode;
}
use of io.automatiko.engine.workflow.process.core.node.CompositeContextNode in project automatiko-engine by automatiko-io.
the class SubProcessHandler method end.
public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
final Element element = parser.endElementBuilder();
Node node = (Node) parser.getCurrent();
// determine type of event definition, so the correct type of node can be
// generated
boolean found = false;
org.w3c.dom.Node xmlNode = element.getFirstChild();
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if ("multiInstanceLoopCharacteristics".equals(nodeName)) {
Boolean isAsync = Boolean.parseBoolean((String) node.getMetaData().get("customAsync"));
// create new timerNode
ForEachNode forEachNode = new ForEachNode();
forEachNode.setId(node.getId());
forEachNode.setName(node.getName());
forEachNode.setSequential(Boolean.parseBoolean(((Element) xmlNode).getAttribute("isSequential")));
forEachNode.setAutoComplete(((CompositeContextNode) node).isAutoComplete());
// for (io.automatiko.engine.api.definition.process.Node subNode : ((CompositeContextNode) node)
// .getNodes()) {
//
// forEachNode.addNode(subNode);
// }
forEachNode.addNode(node);
forEachNode.linkIncomingConnections(NodeImpl.CONNECTION_DEFAULT_TYPE, node.getId(), NodeImpl.CONNECTION_DEFAULT_TYPE);
forEachNode.linkOutgoingConnections(node.getId(), NodeImpl.CONNECTION_DEFAULT_TYPE, NodeImpl.CONNECTION_DEFAULT_TYPE);
forEachNode.setMetaData("UniqueId", ((CompositeContextNode) node).getMetaData("UniqueId"));
// forEachNode.setMetaData(ProcessHandler.CONNECTIONS,
// ((CompositeContextNode) node).getMetaData(ProcessHandler.CONNECTIONS));
VariableScope v = (VariableScope) ((CompositeContextNode) node).getDefaultContext(VariableScope.VARIABLE_SCOPE);
// ((VariableScope) ((CompositeContextNode) forEachNode.internalGetNode(2))
// .getDefaultContext(VariableScope.VARIABLE_SCOPE)).setVariables(v.getVariables());
List<SequenceFlow> connections = (List<SequenceFlow>) ((CompositeContextNode) node).getMetaData(ProcessHandler.CONNECTIONS);
ProcessHandler processHandler = new ProcessHandler();
processHandler.linkConnections((io.automatiko.engine.api.definition.process.NodeContainer) node, connections);
processHandler.linkBoundaryEvents((io.automatiko.engine.api.definition.process.NodeContainer) node);
node = forEachNode;
handleForEachNode(node, element, uri, localName, parser, isAsync);
found = true;
break;
}
xmlNode = xmlNode.getNextSibling();
}
if (!found) {
handleCompositeContextNode(node, element, uri, localName, parser);
}
NodeContainer nodeContainer = (NodeContainer) parser.getParent();
nodeContainer.addNode(node);
((ProcessBuildData) parser.getData()).addNode(node);
return node;
}
use of io.automatiko.engine.workflow.process.core.node.CompositeContextNode in project automatiko-engine by automatiko-io.
the class StartNodeFactory method timer.
public StartNodeFactory timer(String delay, String period, String date, int timeType) {
Timer timer = new Timer();
timer.setDate(date);
timer.setDelay(delay);
timer.setPeriod(period);
timer.setTimeType(timeType);
getStartNode().setTimer(timer);
if (nodeContainer instanceof CompositeContextNode) {
ProcessAction noop = new ProcessAction();
Action action = kcontext -> {
};
noop.wire(action);
((CompositeContextNode) nodeContainer).addTimer(timer, noop);
}
return this;
}
Aggregations