Search in sources :

Example 1 with IOSpecification

use of org.jbpm.workflow.core.impl.IOSpecification in project kogito-runtimes by kiegroup.

the class AbstractNodeHandler method readCatchSpecification.

protected IOSpecification readCatchSpecification(ExtensibleXmlParser parser, Element element) {
    IOSpecification ioSpec = new IOSpecification();
    ioSpec.getDataOutputs().addAll(readDataOutput(parser, element));
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("dataOutputAssociation".equals(nodeName)) {
            readDataAssociation(parser, (Element) xmlNode, id -> ioSpec.getDataOutput().get(id), id -> getVariableDataSpec(parser, id)).ifPresent(e -> ioSpec.getDataOutputAssociation().add(e));
        }
        xmlNode = xmlNode.getNextSibling();
    }
    return ioSpec;
}
Also used : SequenceFlow(org.jbpm.bpmn2.core.SequenceFlow) ForEachNode(org.jbpm.workflow.core.node.ForEachNode) LoggerFactory(org.slf4j.LoggerFactory) PatternConstants(org.jbpm.util.PatternConstants) NodeImpl(org.jbpm.workflow.core.impl.NodeImpl) Thread.currentThread(java.lang.Thread.currentThread) DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) ItemDefinition(org.jbpm.bpmn2.core.ItemDefinition) Assignment(org.jbpm.workflow.core.node.Assignment) ExtensibleXmlParser(org.drools.core.xml.ExtensibleXmlParser) Association(org.jbpm.bpmn2.core.Association) StateNode(org.jbpm.workflow.core.node.StateNode) Matcher(java.util.regex.Matcher) ProcessBuildData(org.jbpm.compiler.xml.ProcessBuildData) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) Signal(org.jbpm.bpmn2.core.Signal) Transformation(org.jbpm.workflow.core.node.Transformation) IOSpecification(org.jbpm.workflow.core.impl.IOSpecification) XmlDumper(org.drools.compiler.compiler.xml.XmlDumper) MultiInstanceSpecification(org.jbpm.workflow.core.impl.MultiInstanceSpecification) CatchLinkNode(org.jbpm.workflow.core.node.CatchLinkNode) CompositeContextNode(org.jbpm.workflow.core.node.CompositeContextNode) Collection(java.util.Collection) Set(java.util.Set) UUID(java.util.UUID) VariableScope(org.jbpm.process.core.context.variable.VariableScope) List(java.util.List) Error(org.jbpm.bpmn2.core.Error) ContextContainer(org.jbpm.process.core.ContextContainer) Node(org.jbpm.workflow.core.Node) JavaDialect(org.drools.mvel.java.JavaDialect) SAXException(org.xml.sax.SAXException) Optional(java.util.Optional) MAPPING_VARIABLE_INPUT(org.jbpm.ruleflow.core.Metadata.MAPPING_VARIABLE_INPUT) VARIABLE(org.jbpm.ruleflow.core.Metadata.VARIABLE) RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) DataDefinition(org.jbpm.workflow.core.impl.DataDefinition) HashMap(java.util.HashMap) Function(java.util.function.Function) ArrayList(java.util.ArrayList) Lane(org.jbpm.bpmn2.core.Lane) TimerNode(org.jbpm.workflow.core.node.TimerNode) HashSet(java.util.HashSet) DataTypeResolver.fromType(org.jbpm.process.core.datatype.DataTypeResolver.fromType) NodeContainer(org.jbpm.workflow.core.NodeContainer) DataAssociation(org.jbpm.workflow.core.impl.DataAssociation) Attributes(org.xml.sax.Attributes) BaseAbstractHandler(org.drools.core.xml.BaseAbstractHandler) FaultNode(org.jbpm.workflow.core.node.FaultNode) DroolsAction(org.jbpm.workflow.core.DroolsAction) Variable(org.jbpm.process.core.context.variable.Variable) DataTransformer(org.kie.api.runtime.process.DataTransformer) ActionNode(org.jbpm.workflow.core.node.ActionNode) EndNode(org.jbpm.workflow.core.node.EndNode) Logger(org.slf4j.Logger) NodeList(org.w3c.dom.NodeList) Iterator(java.util.Iterator) EventNode(org.jbpm.workflow.core.node.EventNode) COMPLETION_CONDITION(org.jbpm.ruleflow.core.Metadata.COMPLETION_CONDITION) Handler(org.drools.core.xml.Handler) DataTypeResolver(org.jbpm.process.core.datatype.DataTypeResolver) SAXParseException(org.xml.sax.SAXParseException) Element(org.w3c.dom.Element) DataTransformerRegistry(org.jbpm.process.core.impl.DataTransformerRegistry) MAPPING_VARIABLE(org.jbpm.ruleflow.core.Metadata.MAPPING_VARIABLE) Definitions(org.jbpm.bpmn2.core.Definitions) ExtendedNodeImpl(org.jbpm.workflow.core.impl.ExtendedNodeImpl) IOSpecification(org.jbpm.workflow.core.impl.IOSpecification) Element(org.w3c.dom.Element)

Example 2 with IOSpecification

use of org.jbpm.workflow.core.impl.IOSpecification in project kogito-runtimes by kiegroup.

the class AbstractNodeHandler method readIOEspecification.

protected IOSpecification readIOEspecification(ExtensibleXmlParser parser, Element element) {
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    IOSpecification ioSpec = new IOSpecification();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("ioSpecification".equals(nodeName)) {
            ioSpec.getDataInputs().addAll(readDataInput(parser, xmlNode));
            ioSpec.getDataOutputs().addAll(readDataOutput(parser, xmlNode));
        } else if ("dataInputAssociation".equals(nodeName)) {
            readDataAssociation(parser, (Element) xmlNode, id -> getVariableDataSpec(parser, id), id -> ioSpec.getDataInput().get(id)).ifPresent(e -> ioSpec.getDataInputAssociation().add(e));
        } else if ("dataOutputAssociation".equals(nodeName)) {
            readDataAssociation(parser, (Element) xmlNode, id -> ioSpec.getDataOutput().get(id), id -> getVariableDataSpec(parser, id)).ifPresent(e -> ioSpec.getDataOutputAssociation().add(e));
        }
        xmlNode = xmlNode.getNextSibling();
    }
    return ioSpec;
}
Also used : SequenceFlow(org.jbpm.bpmn2.core.SequenceFlow) ForEachNode(org.jbpm.workflow.core.node.ForEachNode) LoggerFactory(org.slf4j.LoggerFactory) PatternConstants(org.jbpm.util.PatternConstants) NodeImpl(org.jbpm.workflow.core.impl.NodeImpl) Thread.currentThread(java.lang.Thread.currentThread) DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) ItemDefinition(org.jbpm.bpmn2.core.ItemDefinition) Assignment(org.jbpm.workflow.core.node.Assignment) ExtensibleXmlParser(org.drools.core.xml.ExtensibleXmlParser) Association(org.jbpm.bpmn2.core.Association) StateNode(org.jbpm.workflow.core.node.StateNode) Matcher(java.util.regex.Matcher) ProcessBuildData(org.jbpm.compiler.xml.ProcessBuildData) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) Signal(org.jbpm.bpmn2.core.Signal) Transformation(org.jbpm.workflow.core.node.Transformation) IOSpecification(org.jbpm.workflow.core.impl.IOSpecification) XmlDumper(org.drools.compiler.compiler.xml.XmlDumper) MultiInstanceSpecification(org.jbpm.workflow.core.impl.MultiInstanceSpecification) CatchLinkNode(org.jbpm.workflow.core.node.CatchLinkNode) CompositeContextNode(org.jbpm.workflow.core.node.CompositeContextNode) Collection(java.util.Collection) Set(java.util.Set) UUID(java.util.UUID) VariableScope(org.jbpm.process.core.context.variable.VariableScope) List(java.util.List) Error(org.jbpm.bpmn2.core.Error) ContextContainer(org.jbpm.process.core.ContextContainer) Node(org.jbpm.workflow.core.Node) JavaDialect(org.drools.mvel.java.JavaDialect) SAXException(org.xml.sax.SAXException) Optional(java.util.Optional) MAPPING_VARIABLE_INPUT(org.jbpm.ruleflow.core.Metadata.MAPPING_VARIABLE_INPUT) VARIABLE(org.jbpm.ruleflow.core.Metadata.VARIABLE) RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) DataDefinition(org.jbpm.workflow.core.impl.DataDefinition) HashMap(java.util.HashMap) Function(java.util.function.Function) ArrayList(java.util.ArrayList) Lane(org.jbpm.bpmn2.core.Lane) TimerNode(org.jbpm.workflow.core.node.TimerNode) HashSet(java.util.HashSet) DataTypeResolver.fromType(org.jbpm.process.core.datatype.DataTypeResolver.fromType) NodeContainer(org.jbpm.workflow.core.NodeContainer) DataAssociation(org.jbpm.workflow.core.impl.DataAssociation) Attributes(org.xml.sax.Attributes) BaseAbstractHandler(org.drools.core.xml.BaseAbstractHandler) FaultNode(org.jbpm.workflow.core.node.FaultNode) DroolsAction(org.jbpm.workflow.core.DroolsAction) Variable(org.jbpm.process.core.context.variable.Variable) DataTransformer(org.kie.api.runtime.process.DataTransformer) ActionNode(org.jbpm.workflow.core.node.ActionNode) EndNode(org.jbpm.workflow.core.node.EndNode) Logger(org.slf4j.Logger) NodeList(org.w3c.dom.NodeList) Iterator(java.util.Iterator) EventNode(org.jbpm.workflow.core.node.EventNode) COMPLETION_CONDITION(org.jbpm.ruleflow.core.Metadata.COMPLETION_CONDITION) Handler(org.drools.core.xml.Handler) DataTypeResolver(org.jbpm.process.core.datatype.DataTypeResolver) SAXParseException(org.xml.sax.SAXParseException) Element(org.w3c.dom.Element) DataTransformerRegistry(org.jbpm.process.core.impl.DataTransformerRegistry) MAPPING_VARIABLE(org.jbpm.ruleflow.core.Metadata.MAPPING_VARIABLE) Definitions(org.jbpm.bpmn2.core.Definitions) ExtendedNodeImpl(org.jbpm.workflow.core.impl.ExtendedNodeImpl) IOSpecification(org.jbpm.workflow.core.impl.IOSpecification) Element(org.w3c.dom.Element)

Example 3 with IOSpecification

use of org.jbpm.workflow.core.impl.IOSpecification in project kogito-runtimes by kiegroup.

the class EndEventHandler method handleNode.

@Override
protected Node handleNode(Node newNode, Element element, String uri, String localName, ExtensibleXmlParser parser) throws SAXException {
    NodeImpl node = (NodeImpl) newNode;
    // determine type of event definition, so the correct type of node
    // can be generated
    super.handleNode(node, element, uri, localName, parser);
    // all nodes are catch nodes but error and escalation
    IOSpecification ioSpecification = readThrowSpecification(parser, element);
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("terminateEventDefinition".equals(nodeName)) {
            setThrowVariable(ioSpecification, node);
            handleTerminateNode(node, element, uri, localName, parser);
            break;
        } else if ("signalEventDefinition".equals(nodeName)) {
            setThrowVariable(ioSpecification, node);
            handleSignalNode(node, element, uri, localName, parser);
        } else if ("messageEventDefinition".equals(nodeName)) {
            setThrowVariable(ioSpecification, node);
            handleMessageNode(node, element, uri, localName, parser);
        } else if ("errorEventDefinition".equals(nodeName)) {
            FaultNode faultNode = new FaultNode();
            faultNode.setId(node.getId());
            faultNode.setName(node.getName());
            faultNode.setTerminateParent(true);
            faultNode.setMetaData("UniqueId", node.getMetaData().get("UniqueId"));
            node = faultNode;
            setThrowVariable(ioSpecification, node);
            faultNode.setFaultVariable((String) node.getMetaData().get(Metadata.VARIABLE));
            super.handleNode(node, element, uri, localName, parser);
            handleErrorNode(node, element, uri, localName, parser);
            break;
        } else if ("escalationEventDefinition".equals(nodeName)) {
            FaultNode faultNode = new FaultNode();
            faultNode.setId(node.getId());
            faultNode.setName(node.getName());
            faultNode.setMetaData("UniqueId", node.getMetaData().get("UniqueId"));
            node = faultNode;
            setThrowVariable(ioSpecification, node);
            faultNode.setFaultVariable((String) node.getMetaData().get(Metadata.VARIABLE));
            super.handleNode(node, element, uri, localName, parser);
            handleEscalationNode(node, element, uri, localName, parser);
            break;
        } else if ("compensateEventDefinition".equals(nodeName)) {
            setThrowVariable(ioSpecification, node);
            handleThrowCompensationEventNode(node, element, uri, localName, parser);
            break;
        }
        xmlNode = xmlNode.getNextSibling();
    }
    if (node.getName() == null) {
        node.setName("End");
    }
    return node;
}
Also used : FaultNode(org.jbpm.workflow.core.node.FaultNode) NodeImpl(org.jbpm.workflow.core.impl.NodeImpl) IOSpecification(org.jbpm.workflow.core.impl.IOSpecification)

Example 4 with IOSpecification

use of org.jbpm.workflow.core.impl.IOSpecification in project kogito-runtimes by kiegroup.

the class IntermediateCatchEventHandler method handleNode.

@Override
protected Node handleNode(Node newNode, Element element, String uri, String localName, ExtensibleXmlParser parser) throws SAXException {
    NodeImpl node = (NodeImpl) newNode;
    // determine type of event definition, so the correct type of node
    // can be generated
    IOSpecification ioSpecification = readCatchSpecification(parser, element);
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("signalEventDefinition".equals(nodeName)) {
            // reuse already created EventNode
            setCatchVariable(ioSpecification, node);
            handleSignalNode(node, element, uri, localName, parser);
            node.setMetaData(EVENT_TYPE, EVENT_TYPE_SIGNAL);
            break;
        } else if ("messageEventDefinition".equals(nodeName)) {
            // reuse already created EventNode
            setCatchVariable(ioSpecification, node);
            handleMessageNode(node, element, uri, localName, parser);
            node.setMetaData(EVENT_TYPE, EVENT_TYPE_MESSAGE);
            break;
        } else if ("timerEventDefinition".equals(nodeName)) {
            // create new timerNode
            TimerNode timerNode = new TimerNode();
            timerNode.setId(node.getId());
            timerNode.setName(node.getName());
            timerNode.setMetaData("UniqueId", node.getMetaData().get("UniqueId"));
            node = timerNode;
            setCatchVariable(ioSpecification, node);
            node.setMetaData(EVENT_TYPE, EVENT_TYPE_TIMER);
            handleTimerNode(node, element, uri, localName, parser);
            break;
        } else if ("conditionalEventDefinition".equals(nodeName)) {
            // create new stateNode
            StateNode stateNode = new StateNode();
            stateNode.setId(node.getId());
            stateNode.setName(node.getName());
            stateNode.setMetaData("UniqueId", node.getMetaData().get("UniqueId"));
            node = stateNode;
            setCatchVariable(ioSpecification, node);
            node.setMetaData(EVENT_TYPE, EVENT_TYPE_CONDITIONAL);
            handleStateNode(node, element, uri, localName, parser);
            break;
        } else if ("linkEventDefinition".equals(nodeName)) {
            CatchLinkNode linkNode = new CatchLinkNode();
            linkNode.setId(node.getId());
            node = linkNode;
            setCatchVariable(ioSpecification, node);
            node.setMetaData(EVENT_TYPE, EVENT_TYPE_LINK);
            handleLinkNode(element, node, xmlNode, parser);
            break;
        }
        xmlNode = xmlNode.getNextSibling();
    }
    return node;
}
Also used : CatchLinkNode(org.jbpm.workflow.core.node.CatchLinkNode) NodeImpl(org.jbpm.workflow.core.impl.NodeImpl) IOSpecification(org.jbpm.workflow.core.impl.IOSpecification) StateNode(org.jbpm.workflow.core.node.StateNode) TimerNode(org.jbpm.workflow.core.node.TimerNode)

Example 5 with IOSpecification

use of org.jbpm.workflow.core.impl.IOSpecification in project kogito-runtimes by kiegroup.

the class IntermediateThrowEventHandler method handleNode.

@Override
protected Node handleNode(Node newNode, Element element, String uri, String localName, ExtensibleXmlParser parser) throws SAXException {
    Node node = newNode;
    IOSpecification ioSpecification = readThrowSpecification(parser, element);
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("signalEventDefinition".equals(nodeName)) {
            // reuse already created ActionNode
            setThrowVariable(ioSpecification, node);
            handleSignalNode(node, element, uri, localName, parser);
            break;
        } else if ("messageEventDefinition".equals(nodeName)) {
            // reuse already created ActionNode
            setThrowVariable(ioSpecification, node);
            handleMessageNode(node, element, uri, localName, parser);
            break;
        } else if ("escalationEventDefinition".equals(nodeName)) {
            // reuse already created ActionNode
            setThrowVariable(ioSpecification, node);
            handleEscalationNode(node, element, uri, localName, parser);
            break;
        } else if ("compensateEventDefinition".equals(nodeName)) {
            // reuse already created ActionNode
            setThrowVariable(ioSpecification, node);
            handleThrowCompensationEventNode(node, element, uri, localName, parser);
            break;
        } else if ("linkEventDefinition".equals(nodeName)) {
            ThrowLinkNode linkNode = new ThrowLinkNode();
            linkNode.setId(node.getId());
            node = linkNode;
            setThrowVariable(ioSpecification, node);
            handleLinkNode(element, node, xmlNode, parser);
        }
        xmlNode = xmlNode.getNextSibling();
    }
    if (node instanceof ActionNode) {
        ActionNode actionNode = (ActionNode) node;
        if (actionNode.getAction() == null) {
            actionNode.setAction(new DroolsConsequenceAction("java", ""));
            actionNode.setMetaData("NodeType", "IntermediateThrowEvent-None");
        }
    }
    return node;
}
Also used : DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) IOSpecification(org.jbpm.workflow.core.impl.IOSpecification) CompositeNode(org.jbpm.workflow.core.node.CompositeNode) ActionNode(org.jbpm.workflow.core.node.ActionNode) Node(org.jbpm.workflow.core.Node) ThrowLinkNode(org.jbpm.workflow.core.node.ThrowLinkNode) ActionNode(org.jbpm.workflow.core.node.ActionNode) ThrowLinkNode(org.jbpm.workflow.core.node.ThrowLinkNode)

Aggregations

IOSpecification (org.jbpm.workflow.core.impl.IOSpecification)7 NodeImpl (org.jbpm.workflow.core.impl.NodeImpl)6 Thread.currentThread (java.lang.Thread.currentThread)4 ArrayList (java.util.ArrayList)4 Collection (java.util.Collection)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 Iterator (java.util.Iterator)4 List (java.util.List)4 Map (java.util.Map)4 Optional (java.util.Optional)4 Set (java.util.Set)4 UUID (java.util.UUID)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 Function (java.util.function.Function)4 Matcher (java.util.regex.Matcher)4 XmlDumper (org.drools.compiler.compiler.xml.XmlDumper)4 BaseAbstractHandler (org.drools.core.xml.BaseAbstractHandler)4 ExtensibleXmlParser (org.drools.core.xml.ExtensibleXmlParser)4 Handler (org.drools.core.xml.Handler)4