Search in sources :

Example 1 with DynamicNode

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);
}
Also used : Node(io.automatiko.engine.workflow.process.core.Node) DynamicNode(io.automatiko.engine.workflow.process.core.node.DynamicNode) DynamicNode(io.automatiko.engine.workflow.process.core.node.DynamicNode)

Example 2 with DynamicNode

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());
}
Also used : ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) DynamicNode(io.automatiko.engine.workflow.process.core.node.DynamicNode) ProcessValidationError(io.automatiko.engine.workflow.base.core.validation.ProcessValidationError) Test(org.junit.jupiter.api.Test)

Example 3 with DynamicNode

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;
}
Also used : DynamicNode(io.automatiko.engine.workflow.process.core.node.DynamicNode) VariableScope(io.automatiko.engine.workflow.base.core.context.variable.VariableScope)

Example 4 with DynamicNode

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");
}
Also used : SequenceFlow(io.automatiko.engine.workflow.bpmn2.core.SequenceFlow) DynamicNode(io.automatiko.engine.workflow.process.core.node.DynamicNode) List(java.util.List)

Example 5 with DynamicNode

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());
}
Also used : ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) DynamicNode(io.automatiko.engine.workflow.process.core.node.DynamicNode) ProcessValidationError(io.automatiko.engine.workflow.base.core.validation.ProcessValidationError) Test(org.junit.jupiter.api.Test)

Aggregations

DynamicNode (io.automatiko.engine.workflow.process.core.node.DynamicNode)8 Node (io.automatiko.engine.api.definition.process.Node)2 ProcessValidationError (io.automatiko.engine.workflow.base.core.validation.ProcessValidationError)2 ActionNode (io.automatiko.engine.workflow.process.core.node.ActionNode)2 BoundaryEventNode (io.automatiko.engine.workflow.process.core.node.BoundaryEventNode)2 CatchLinkNode (io.automatiko.engine.workflow.process.core.node.CatchLinkNode)2 CompositeNode (io.automatiko.engine.workflow.process.core.node.CompositeNode)2 NodeAndType (io.automatiko.engine.workflow.process.core.node.CompositeNode.NodeAndType)2 EndNode (io.automatiko.engine.workflow.process.core.node.EndNode)2 EventNode (io.automatiko.engine.workflow.process.core.node.EventNode)2 EventSubProcessNode (io.automatiko.engine.workflow.process.core.node.EventSubProcessNode)2 FaultNode (io.automatiko.engine.workflow.process.core.node.FaultNode)2 ForEachNode (io.automatiko.engine.workflow.process.core.node.ForEachNode)2 ForEachJoinNode (io.automatiko.engine.workflow.process.core.node.ForEachNode.ForEachJoinNode)2 ForEachSplitNode (io.automatiko.engine.workflow.process.core.node.ForEachNode.ForEachSplitNode)2 MilestoneNode (io.automatiko.engine.workflow.process.core.node.MilestoneNode)2 RuleSetNode (io.automatiko.engine.workflow.process.core.node.RuleSetNode)2 StartNode (io.automatiko.engine.workflow.process.core.node.StartNode)2 StateNode (io.automatiko.engine.workflow.process.core.node.StateNode)2 SubProcessNode (io.automatiko.engine.workflow.process.core.node.SubProcessNode)2