Search in sources :

Example 16 with Transformation

use of io.automatiko.engine.workflow.process.core.node.Transformation in project automatiko-engine by automatiko-io.

the class IntermediateCatchEventHandler method readDataOutputAssociation.

protected void readDataOutputAssociation(org.w3c.dom.Node xmlNode, EventNode eventNode) {
    // sourceRef
    org.w3c.dom.Node subNode = xmlNode.getFirstChild();
    String from = subNode.getTextContent();
    String to = null;
    Transformation transformation = null;
    // targetRef
    subNode = subNode.getNextSibling();
    if (subNode != null && "targetRef".equals(subNode.getNodeName())) {
        to = subNode.getTextContent();
        eventNode.setVariableName(to);
        subNode = subNode.getNextSibling();
    }
    if (subNode != null && "transformation".equals(subNode.getNodeName())) {
        String lang = subNode.getAttributes().getNamedItem("language").getNodeValue();
        String expression = subNode.getTextContent();
        DataTransformer transformer = transformerRegistry.find(lang);
        if (transformer == null) {
            throw new IllegalArgumentException("No transformer registered for language " + lang);
        }
        transformation = new Transformation(lang, expression, dataOutputs.get(from));
        eventNode.setMetaData("Transformation", transformation);
        eventNode.setEventTransformer(new EventTransformerImpl(transformation));
    } else if (subNode != null && "assignment".equals(subNode.getNodeName())) {
        // assignments
        while (subNode != null) {
            org.w3c.dom.Node ssubNode = subNode.getFirstChild();
            to = ssubNode.getNextSibling().getTextContent();
            subNode = subNode.getNextSibling();
            eventNode.setVariableName(to);
        }
    }
}
Also used : Transformation(io.automatiko.engine.workflow.process.core.node.Transformation) DataTransformer(io.automatiko.engine.api.runtime.process.DataTransformer) TimerNode(io.automatiko.engine.workflow.process.core.node.TimerNode) CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) CatchLinkNode(io.automatiko.engine.workflow.process.core.node.CatchLinkNode) Node(io.automatiko.engine.workflow.process.core.Node) StateNode(io.automatiko.engine.workflow.process.core.node.StateNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) EventTransformerImpl(io.automatiko.engine.workflow.base.core.event.EventTransformerImpl)

Example 17 with Transformation

use of io.automatiko.engine.workflow.process.core.node.Transformation in project automatiko-engine by automatiko-io.

the class IntermediateThrowEventHandler method handleSignalNode.

public void handleSignalNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    ActionNode actionNode = (ActionNode) node;
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("dataInput".equals(nodeName)) {
            String id = ((Element) xmlNode).getAttribute("id");
            String inputName = ((Element) xmlNode).getAttribute("name");
            dataInputs.put(id, inputName);
        } else if ("dataInputAssociation".equals(nodeName)) {
            readDataInputAssociation(xmlNode, actionNode, parser);
        } else if ("signalEventDefinition".equals(nodeName)) {
            String signalName = ((Element) xmlNode).getAttribute("signalRef");
            String variable = findVariable((String) actionNode.getMetaData(MAPPING_VARIABLE_KEY), parser);
            signalName = checkSignalAndConvertToRealSignalNam(parser, signalName);
            actionNode.setMetaData("EventType", "signal");
            actionNode.setMetaData("Ref", signalName);
            actionNode.setMetaData("Variable", variable);
            actionNode.setMetaData("TriggerType", "Signal");
            // check if signal should be send async
            if (dataInputs.containsValue("async")) {
                signalName = "ASYNC-" + signalName;
            }
            ConsequenceAction action = createJavaAction(new SignalProcessInstanceAction(signalName, variable, (String) actionNode.getMetaData("customScope"), (Transformation) actionNode.getMetaData().get(TRANSFORMATION_KEY)));
            actionNode.setAction(action);
        }
        xmlNode = xmlNode.getNextSibling();
    }
}
Also used : SignalProcessInstanceAction(io.automatiko.engine.workflow.base.instance.impl.actions.SignalProcessInstanceAction) Transformation(io.automatiko.engine.workflow.process.core.node.Transformation) Element(org.w3c.dom.Element) ConsequenceAction(io.automatiko.engine.workflow.process.core.impl.ConsequenceAction) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode)

Example 18 with Transformation

use of io.automatiko.engine.workflow.process.core.node.Transformation in project automatiko-engine by automatiko-io.

the class IntermediateThrowEventHandler method readDataInputAssociation.

protected void readDataInputAssociation(org.w3c.dom.Node xmlNode, ActionNode actionNode, final ExtensibleXmlParser parser) {
    org.w3c.dom.Node subNode = xmlNode.getFirstChild();
    if ("sourceRef".equals(subNode.getNodeName())) {
        // sourceRef
        String eventVariable = subNode.getTextContent();
        // targetRef
        subNode = subNode.getNextSibling();
        String target = subNode.getTextContent();
        // transformation
        Transformation transformation = null;
        subNode = subNode.getNextSibling();
        if (subNode != null && "transformation".equals(subNode.getNodeName())) {
            String lang = subNode.getAttributes().getNamedItem("language").getNodeValue();
            String expression = subNode.getTextContent();
            DataTransformer transformer = transformerRegistry.find(lang);
            if (transformer == null) {
                throw new IllegalArgumentException("No transformer registered for language " + lang);
            }
            transformation = new Transformation(lang, expression, dataInputs.get(target));
            actionNode.setMetaData(TRANSFORMATION_KEY, transformation);
        }
        if (eventVariable != null && eventVariable.trim().length() > 0) {
            if (dataInputs.containsKey(eventVariable)) {
                eventVariable = dataInputs.get(eventVariable);
            }
            actionNode.setMetaData(MAPPING_VARIABLE_KEY, findVariable(eventVariable, parser));
        }
    } else {
        // targetRef
        // assignment
        subNode = subNode.getNextSibling();
        if (subNode != null) {
            org.w3c.dom.Node subSubNode = subNode.getFirstChild();
            NodeList nl = subSubNode.getChildNodes();
            if (nl.getLength() > 1) {
                actionNode.setMetaData(MAPPING_VARIABLE_KEY, subSubNode.getTextContent());
                return;
            } else if (nl.getLength() == 0) {
                return;
            }
            Object result = null;
            Object from = nl.item(0);
            if (from instanceof Text) {
                String text = ((Text) from).getTextContent();
                if (text.startsWith("\"") && text.endsWith("\"")) {
                    result = text.substring(1, text.length() - 1);
                } else {
                    result = text;
                }
            } else {
                result = nl.item(0);
            }
            actionNode.setMetaData(MAPPING_VARIABLE_KEY, "\"" + findVariable(result.toString(), parser) + "\"");
        }
    }
}
Also used : Transformation(io.automatiko.engine.workflow.process.core.node.Transformation) DataTransformer(io.automatiko.engine.api.runtime.process.DataTransformer) NodeList(org.w3c.dom.NodeList) Text(org.w3c.dom.Text)

Example 19 with Transformation

use of io.automatiko.engine.workflow.process.core.node.Transformation in project automatiko-engine by automatiko-io.

the class CallActivityHandler method readDataInputAssociation.

protected void readDataInputAssociation(org.w3c.dom.Node xmlNode, SubProcessNode subProcessNode, Map<String, String> dataInputs) {
    // sourceRef
    org.w3c.dom.Node subNode = xmlNode.getFirstChild();
    if ("sourceRef".equals(subNode.getNodeName())) {
        String from = subNode.getTextContent();
        // targetRef
        subNode = subNode.getNextSibling();
        String to = subNode.getTextContent();
        // transformation
        Transformation transformation = null;
        subNode = subNode.getNextSibling();
        if (subNode != null && "transformation".equals(subNode.getNodeName())) {
            String lang = subNode.getAttributes().getNamedItem("language").getNodeValue();
            String expression = subNode.getTextContent();
            DataTransformer transformer = transformerRegistry.find(lang);
            if (transformer == null) {
                throw new IllegalArgumentException("No transformer registered for language " + lang);
            }
            transformation = new Transformation(lang, expression);
            subNode = subNode.getNextSibling();
        }
        subProcessNode.addInMapping(dataInputs.get(to), from, transformation);
    } else {
        // targetRef
        String to = subNode.getTextContent();
        // assignment
        subNode = subNode.getNextSibling();
        if (subNode != null) {
            org.w3c.dom.Node subSubNode = subNode.getFirstChild();
            NodeList nl = subSubNode.getChildNodes();
            if (nl.getLength() > 1) {
                // not supported ?
                subProcessNode.addInMapping(dataInputs.get(to), subSubNode.getTextContent());
                return;
            } else if (nl.getLength() == 0) {
                return;
            }
            Object result = null;
            Object from = nl.item(0);
            if (from instanceof Text) {
                result = ((Text) from).getTextContent();
            } else {
                result = nl.item(0);
            }
            subProcessNode.addInMapping(dataInputs.get(to), result.toString());
        }
    }
}
Also used : Transformation(io.automatiko.engine.workflow.process.core.node.Transformation) DataTransformer(io.automatiko.engine.api.runtime.process.DataTransformer) NodeList(org.w3c.dom.NodeList) Text(org.w3c.dom.Text)

Example 20 with Transformation

use of io.automatiko.engine.workflow.process.core.node.Transformation in project automatiko-engine by automatiko-io.

the class BoundaryEventHandler method readDataOutputAssociation.

protected void readDataOutputAssociation(org.w3c.dom.Node xmlNode, EventNode eventNode, final ExtensibleXmlParser parser) {
    // sourceRef
    org.w3c.dom.Node subNode = xmlNode.getFirstChild();
    String from = subNode.getTextContent();
    String to = null;
    Transformation transformation = null;
    // targetRef
    subNode = subNode.getNextSibling();
    if (subNode != null && "targetRef".equals(subNode.getNodeName())) {
        to = subNode.getTextContent();
        eventNode.setVariableName(to);
        subNode = subNode.getNextSibling();
    } else if (subNode != null && "transformation".equals(subNode.getNodeName())) {
        String lang = subNode.getAttributes().getNamedItem("language").getNodeValue();
        String expression = subNode.getTextContent();
        DataTransformer transformer = transformerRegistry.find(lang);
        if (transformer == null) {
            throw new IllegalArgumentException("No transformer registered for language " + lang);
        }
        transformation = new Transformation(lang, expression, dataOutputs.get(from));
        eventNode.setMetaData("Transformation", transformation);
        eventNode.setEventTransformer(new EventTransformerImpl(transformation));
    } else if (subNode != null && "assignment".equals(subNode.getNodeName())) {
        // assignments
        while (subNode != null) {
            org.w3c.dom.Node ssubNode = subNode.getFirstChild();
            to = ssubNode.getNextSibling().getTextContent();
            subNode = subNode.getNextSibling();
            eventNode.setVariableName(to);
        }
    }
    eventNode.setVariableName(findVariable(to, parser));
}
Also used : Transformation(io.automatiko.engine.workflow.process.core.node.Transformation) DataTransformer(io.automatiko.engine.api.runtime.process.DataTransformer) EventTransformerImpl(io.automatiko.engine.workflow.base.core.event.EventTransformerImpl)

Aggregations

Transformation (io.automatiko.engine.workflow.process.core.node.Transformation)24 DataTransformer (io.automatiko.engine.api.runtime.process.DataTransformer)21 DataAssociation (io.automatiko.engine.workflow.process.core.node.DataAssociation)15 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)10 Map (java.util.Map)10 VariableScopeInstance (io.automatiko.engine.workflow.base.instance.context.variable.VariableScopeInstance)9 Element (org.w3c.dom.Element)9 ExpressionEvaluator (io.automatiko.engine.api.expression.ExpressionEvaluator)8 Assignment (io.automatiko.engine.workflow.process.core.node.Assignment)8 NodeInstanceResolverFactory (io.automatiko.engine.workflow.process.instance.impl.NodeInstanceResolverFactory)7 WorkflowProcess (io.automatiko.engine.workflow.process.core.WorkflowProcess)6 LinkedList (java.util.LinkedList)6 DataTransformerRegistry (io.automatiko.engine.workflow.base.core.impl.DataTransformerRegistry)5 Node (io.automatiko.engine.workflow.process.core.Node)5 Matcher (java.util.regex.Matcher)5 Variable (io.automatiko.engine.workflow.base.core.context.variable.Variable)4 ConsequenceAction (io.automatiko.engine.workflow.process.core.impl.ConsequenceAction)4 List (java.util.List)4 NodeList (org.w3c.dom.NodeList)4