use of io.automatiko.engine.workflow.process.core.node.StartNode in project automatiko-engine by automatiko-io.
the class StartNodeHandler method writeNode.
public void writeNode(Node node, StringBuilder xmlDump, boolean includeMeta) {
StartNode startNode = (StartNode) node;
writeNode("start", startNode, xmlDump, includeMeta);
List<Trigger> triggers = startNode.getTriggers();
if ((triggers == null || triggers.isEmpty()) && (!includeMeta || !containsMetaData(startNode))) {
endNode(xmlDump);
} else {
xmlDump.append(">" + EOL);
if (includeMeta) {
writeMetaData(startNode, xmlDump);
}
if (triggers != null) {
xmlDump.append(" <triggers>" + EOL);
for (Trigger trigger : triggers) {
if (trigger instanceof ConstraintTrigger) {
xmlDump.append(" <trigger type=\"constraint\" >" + EOL);
xmlDump.append(" <constraint type=\"rule\" dialect=\"mvel\" >" + ((ConstraintTrigger) trigger).getConstraint() + "</constraint>" + EOL);
Map<String, String> inMappings = trigger.getInMappings();
if (inMappings != null && !inMappings.isEmpty()) {
for (Map.Entry<String, String> entry : inMappings.entrySet()) {
xmlDump.append(" <mapping type=\"in\" from=\"" + XmlDumper.replaceIllegalChars(entry.getValue()) + "\" to=\"" + entry.getKey() + "\" />" + EOL);
}
}
xmlDump.append(" </trigger>" + EOL);
} else if (trigger instanceof EventTrigger) {
xmlDump.append(" <trigger type=\"event\" >" + EOL);
xmlDump.append(" <eventFilters>" + EOL);
for (EventFilter filter : ((EventTrigger) trigger).getEventFilters()) {
if (filter instanceof EventTypeFilter) {
xmlDump.append(" <eventFilter " + "type=\"eventType\" " + "eventType=\"" + ((EventTypeFilter) filter).getType() + "\" />" + EOL);
} else {
throw new IllegalArgumentException("Unknown filter type: " + filter);
}
}
xmlDump.append(" </eventFilters>" + EOL);
Map<String, String> inMappings = trigger.getInMappings();
if (inMappings != null && !inMappings.isEmpty()) {
for (Map.Entry<String, String> entry : inMappings.entrySet()) {
xmlDump.append(" <mapping type=\"in\" from=\"" + XmlDumper.replaceIllegalChars(entry.getValue()) + "\" to=\"" + entry.getKey() + "\" />" + EOL);
}
}
xmlDump.append(" </trigger>" + EOL);
} else {
throw new IllegalArgumentException("Unknown trigger type " + trigger);
}
}
xmlDump.append(" </triggers>" + EOL);
}
endNode("start", xmlDump);
}
}
use of io.automatiko.engine.workflow.process.core.node.StartNode in project automatiko-engine by automatiko-io.
the class TriggerHandler method start.
public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
parser.startElementBuilder(localName, attrs);
StartNode startNode = (StartNode) parser.getParent();
String type = attrs.getValue("type");
emptyAttributeCheck(localName, "type", type, parser);
Trigger trigger = null;
if ("constraint".equals(type)) {
trigger = new ConstraintTrigger();
} else if ("event".equals(type)) {
trigger = new EventTrigger();
} else {
throw new SAXException("Unknown trigger type " + type);
}
startNode.addTrigger(trigger);
return trigger;
}
use of io.automatiko.engine.workflow.process.core.node.StartNode in project automatiko-engine by automatiko-io.
the class SvgBpmnProcessImageGenerator method buildNodeContainer.
/*
* Build methods
*/
protected void buildNodeContainer(int x, int y, NodeContainer nodeContainer, SVGGraphics2D g2) {
try {
for (Node node : nodeContainer.getNodes()) {
if (node instanceof StartNode) {
buildStartEvent(x, y, (StartNode) node, g2);
} else if (node instanceof EndNode) {
buildEndEvent(x, y, (EndNode) node, g2);
} else if (node instanceof FaultNode) {
buildErrorEndEvent(x, y, (FaultNode) node, g2);
} else if (node instanceof BoundaryEventNode) {
buildBoundaryEvent(x, y, node, g2);
} else if (node instanceof EventNode || node instanceof StateNode) {
buildIntermediateEvent(x, y, node, g2);
} else if (node instanceof HumanTaskNode) {
buildHumanTaskNode(x, y, (HumanTaskNode) node, g2);
} else if (node instanceof ActionNode) {
buildScriptTaskNode(x, y, (ActionNode) node, g2);
} else if (node instanceof WorkItemNode) {
buildServiceTaskNode(x, y, (WorkItemNode) node, g2);
} else if (node instanceof Split || node instanceof Join) {
buildGateway(x, y, node, g2);
} else if (node instanceof ForEachNode) {
buildNodeContainer(x(node), y(node), ((ForEachNode) node).getCompositeNode(), g2);
} else if (node instanceof CompositeNode) {
buildSubprocessNode(x, y, (CompositeNode) node, g2);
int sx = x(node);
int sy = y(node);
buildNodeContainer(sx, sy, (CompositeNode) node, g2);
} else if (node instanceof RuleSetNode) {
buildBusinessRuleTaskNode(x, y, (RuleSetNode) node, g2);
} else if (node instanceof TimerNode) {
buildTimerEvent(x, y, (TimerNode) node, g2);
} else if (node instanceof SubProcessNode) {
buildCallActivity(x, y, (SubProcessNode) node, g2);
}
buildSequenceFlow(x, y, node, g2);
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
use of io.automatiko.engine.workflow.process.core.node.StartNode in project automatiko-engine by automatiko-io.
the class ExecutableProcessFactory method postProcessNodes.
private void postProcessNodes(ExecutableProcess process, NodeContainer container) {
List<String> eventSubProcessHandlers = new ArrayList<String>();
for (Node node : container.getNodes()) {
if (node instanceof NodeContainer) {
// prepare event sub process
if (node instanceof EventSubProcessNode) {
EventSubProcessNode eventSubProcessNode = (EventSubProcessNode) node;
Node[] nodes = eventSubProcessNode.getNodes();
for (Node subNode : nodes) {
// avoids cyclomatic complexity
if (subNode instanceof StartNode) {
processEventSubprocessStartNode(process, ((StartNode) subNode), eventSubProcessNode, eventSubProcessHandlers);
}
}
}
postProcessNodes(process, (NodeContainer) node);
}
}
// process fault node to disable termnate parent if there is event subprocess handler
for (Node node : container.getNodes()) {
if (node instanceof FaultNode) {
FaultNode faultNode = (FaultNode) node;
if (eventSubProcessHandlers.contains(faultNode.getFaultName())) {
faultNode.setTerminateParent(false);
}
}
}
}
use of io.automatiko.engine.workflow.process.core.node.StartNode in project automatiko-engine by automatiko-io.
the class ExecutableProcessFactory method executionTimeout.
public ExecutableProcessFactory executionTimeout(int nodeIdCounter, String timeoutExpression, long... extranodes) {
int nodeId = ++nodeIdCounter;
EventSubProcessNodeFactory eventSubProcessNode4 = eventSubProcessNode(nodeId);
eventSubProcessNode4.name("Execution timeout");
eventSubProcessNode4.metaData("UniqueId", "SubProcess_" + nodeId);
eventSubProcessNode4.metaData("hidden_node", true);
eventSubProcessNode4.keepActive(true);
eventSubProcessNode4.event("Timer-" + nodeId);
eventSubProcessNode4.autoComplete(true);
int startNodeId = ++nodeIdCounter;
StartNodeFactory startNode5 = eventSubProcessNode4.startNode(startNodeId);
startNode5.name("Execution timeout :: start");
startNode5.interrupting(true);
startNode5.metaData("UniqueId", "StartEvent_" + startNodeId);
startNode5.metaData("TriggerType", "Timer");
startNode5.done();
startNode5.timer(timeoutExpression, null, null, 1);
int endNodeId = ++nodeIdCounter;
EndNodeFactory endNode7 = eventSubProcessNode4.endNode(endNodeId);
endNode7.name("Execution timeout :: end");
endNode7.terminate(false);
endNode7.metaData("UniqueId", "EndEvent_" + endNodeId);
endNode7.done();
if (extranodes != null && extranodes.length > 0) {
for (long extraNodId : extranodes) {
Node node = getNodeContainer().getNode(extraNodId);
getNodeContainer().removeNode(node);
eventSubProcessNode4.getNodeContainer().addNode(node);
}
if (extranodes.length == 1) {
eventSubProcessNode4.connection(startNodeId, extranodes[0], "SequenceFlow_e_" + startNodeId);
eventSubProcessNode4.connection(extranodes[0], endNodeId, "SequenceFlow_e_" + endNodeId);
} else {
eventSubProcessNode4.connection(startNodeId, extranodes[0], "SequenceFlow_e_" + startNodeId);
int counter = 1;
for (long extraNodId : extranodes) {
if (counter > extranodes.length) {
eventSubProcessNode4.connection(extraNodId, extranodes[counter], "SequenceFlow_e_" + counter);
counter++;
}
}
eventSubProcessNode4.connection(extranodes[extranodes.length - 1], endNodeId, "SequenceFlow_e_" + endNodeId);
}
} else {
eventSubProcessNode4.connection(startNodeId, endNodeId, "SequenceFlow_" + startNodeId);
}
eventSubProcessNode4.done();
return this;
}
Aggregations