use of io.automatiko.engine.workflow.process.core.node.DynamicNode in project automatiko-engine by automatiko-io.
the class AdHocSubProcessHandler method writeNode.
@Override
public void writeNode(Node node, StringBuilder xmlDump, int metaDataType) {
DynamicNode dynamicNode = (DynamicNode) node;
writeNode("adHocSubProcess", dynamicNode, xmlDump, metaDataType);
if (!dynamicNode.isCancelRemainingInstances()) {
xmlDump.append(" cancelRemainingInstances=\"false\"");
}
xmlDump.append(" ordering=\"Parallel\" >" + EOL);
writeExtensionElements(dynamicNode, xmlDump);
// nodes
List<Node> subNodes = getSubNodes(dynamicNode);
XmlBPMNProcessDumper.INSTANCE.visitNodes(subNodes, xmlDump, metaDataType);
// connections
visitConnectionsAndAssociations(dynamicNode, xmlDump, metaDataType);
if (dynamicNode.isAutoComplete()) {
xmlDump.append(" <completionCondition xsi:type=\"tFormalExpression\">" + AUTOCOMPLETE_COMPLETION_CONDITION + "</completionCondition>" + EOL);
}
endNode("adHocSubProcess", xmlDump);
}
use of io.automatiko.engine.workflow.process.core.node.DynamicNode in project automatiko-engine by automatiko-io.
the class RuleFlowProcessValidatorTest method testDynamicNodeValidationInNotDynamicProcess.
@Test
void testDynamicNodeValidationInNotDynamicProcess() {
ExecutableProcess process = new ExecutableProcess();
process.setId("org.company.core.process");
process.setName("Dynamic Node Process");
process.setPackageName("org.mycomp.myprocess");
process.setDynamic(false);
DynamicNode dynamicNode = new DynamicNode();
dynamicNode.setName("MyDynamicNode");
dynamicNode.setId(1);
dynamicNode.setAutoComplete(false);
// empty completion expression to trigger validation error
process.addNode(dynamicNode);
ProcessValidationError[] errors = validator.validateProcess(process);
assertNotNull(errors);
// in non-dynamic processes all check should be triggered
// they should also include process level checks (start node, end node etc)
assertEquals(6, errors.length);
assertEquals("Process has no start node.", errors[0].getMessage());
assertEquals("Process has no end node.", errors[1].getMessage());
assertEquals("Node 'MyDynamicNode' [1] Dynamic has no incoming connection", errors[2].getMessage());
assertEquals("Node 'MyDynamicNode' [1] Dynamic has no outgoing connection", errors[3].getMessage());
assertEquals("Node 'MyDynamicNode' [1] Dynamic has no completion condition set", errors[4].getMessage());
assertEquals("Node 'MyDynamicNode' [1] Has no connection to the start node.", errors[5].getMessage());
}
use of io.automatiko.engine.workflow.process.core.node.DynamicNode in project automatiko-engine by automatiko-io.
the class AdHocSubProcessHandler method createNode.
@Override
protected Node createNode(Attributes attrs) {
DynamicNode result = new DynamicNode();
VariableScope variableScope = new VariableScope();
result.addContext(variableScope);
result.setDefaultContext(variableScope);
return result;
}
use of io.automatiko.engine.workflow.process.core.node.DynamicNode in project automatiko-engine by automatiko-io.
the class AdHocSubProcessHandler method handleNode.
@SuppressWarnings("unchecked")
@Override
protected void handleNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
super.handleNode(node, element, uri, localName, parser);
DynamicNode dynamicNode = (DynamicNode) node;
String cancelRemainingInstances = element.getAttribute("cancelRemainingInstances");
if ("false".equals(cancelRemainingInstances)) {
dynamicNode.setCancelRemainingInstances(false);
}
// by default it should not autocomplete as it's adhoc
org.w3c.dom.Node xmlNode = element.getFirstChild();
dynamicNode.setActivationCondition((String) node.getMetaData().get(CUSTOM_ACTIVATION_CONDITION));
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if (COMPLETION_CONDITION.equals(nodeName)) {
String expression = xmlNode.getTextContent();
if (AUTOCOMPLETE_EXPRESSIONS.contains(expression)) {
dynamicNode.setAutoComplete(true);
} else {
dynamicNode.setCompletionCondition(expression);
}
}
xmlNode = xmlNode.getNextSibling();
}
List<SequenceFlow> connections = (List<SequenceFlow>) dynamicNode.getMetaData(ProcessHandler.CONNECTIONS);
ProcessHandler processHandler = new ProcessHandler();
processHandler.linkConnections(dynamicNode, connections);
processHandler.linkBoundaryEvents(dynamicNode);
handleScript(dynamicNode, element, "onEntry");
handleScript(dynamicNode, element, "onExit");
}
use of io.automatiko.engine.workflow.process.core.node.DynamicNode in project automatiko-engine by automatiko-io.
the class RuleFlowProcessValidatorTest method testDynamicNodeValidationInDynamicProcess.
@Test
void testDynamicNodeValidationInDynamicProcess() {
ExecutableProcess process = new ExecutableProcess();
process.setId("org.company.core.process");
process.setName("Dynamic Node Process");
process.setPackageName("org.mycomp.myprocess");
process.setDynamic(true);
DynamicNode dynamicNode = new DynamicNode();
dynamicNode.setName("MyDynamicNode");
dynamicNode.setId(1);
dynamicNode.setAutoComplete(false);
dynamicNode.setCompletionExpression(kcontext -> true);
process.addNode(dynamicNode);
ProcessValidationError[] errors = validator.validateProcess(process);
assertNotNull(errors);
// if dynamic process no longer triggering incoming / outgoing connection errors
// for dynamic nodes
assertEquals(0, errors.length);
// empty completion expression to trigger validation error
process.removeNode(dynamicNode);
DynamicNode dynamicNode2 = new DynamicNode();
dynamicNode2.setName("MyDynamicNode");
dynamicNode2.setId(1);
dynamicNode2.setAutoComplete(false);
process.addNode(dynamicNode2);
ProcessValidationError[] errors2 = validator.validateProcess(process);
assertNotNull(errors2);
// autocomplete set to false and empty completion condition triggers error
assertEquals(1, errors2.length);
assertEquals("Node 'MyDynamicNode' [1] Dynamic has no completion condition set", errors2[0].getMessage());
}
Aggregations