Search in sources :

Example 1 with EventTransformerImpl

use of io.automatiko.engine.workflow.base.core.event.EventTransformerImpl in project automatiko-engine by automatiko-io.

the class HandleEscalationAction method execute.

public void execute(ProcessContext context) throws Exception {
    ExceptionScopeInstance scopeInstance = (ExceptionScopeInstance) ((NodeInstance) context.getNodeInstance()).resolveContextInstance(ExceptionScope.EXCEPTION_SCOPE, faultName);
    if (scopeInstance != null) {
        Object tVariable = variableName == null ? null : context.getVariable(variableName);
        io.automatiko.engine.workflow.process.core.node.Transformation transformation = (io.automatiko.engine.workflow.process.core.node.Transformation) context.getNodeInstance().getNode().getMetaData().get("Transformation");
        if (transformation != null) {
            tVariable = new EventTransformerImpl(transformation).transformEvent(context.getProcessInstance().getVariables());
        }
        scopeInstance.handleException(context.getNodeInstance(), faultName, tVariable);
    } else {
        ((ProcessInstance) context.getProcessInstance()).setState(STATE_ABORTED);
    }
}
Also used : ProcessInstance(io.automatiko.engine.workflow.base.instance.ProcessInstance) EventTransformerImpl(io.automatiko.engine.workflow.base.core.event.EventTransformerImpl) ExceptionScopeInstance(io.automatiko.engine.workflow.base.instance.context.exception.ExceptionScopeInstance)

Example 2 with EventTransformerImpl

use of io.automatiko.engine.workflow.base.core.event.EventTransformerImpl in project automatiko-engine by automatiko-io.

the class StartEventHandler method readDataOutputAssociation.

protected void readDataOutputAssociation(org.w3c.dom.Node xmlNode, StartNode startNode) {
    // sourceRef
    org.w3c.dom.Node subNode = xmlNode.getFirstChild();
    if (!"sourceRef".equals(subNode.getNodeName())) {
        throw new IllegalArgumentException("No sourceRef found in dataOutputAssociation in startEvent");
    }
    String source = subNode.getTextContent();
    if (dataOutputs.get(source) == null) {
        throw new IllegalArgumentException("No dataOutput could be found for the dataOutputAssociation.");
    }
    String target = null;
    Transformation transformation = null;
    // targetRef
    subNode = subNode.getNextSibling();
    if (subNode != null && "targetRef".equals(subNode.getNodeName())) {
        target = subNode.getTextContent();
        if (target != null) {
            startNode.setMetaData("TriggerMapping", target);
        }
        // transformation
        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(source));
        startNode.setMetaData("Transformation", transformation);
        startNode.setEventTransformer(new EventTransformerImpl(transformation));
        subNode = subNode.getNextSibling();
        startNode.addOutMapping(target, dataOutputs.get(source));
    } else if (subNode != null && "assignment".equals(subNode.getNodeName())) {
        // assignments
        while (subNode != null) {
            org.w3c.dom.Node ssubNode = subNode.getFirstChild();
            target = ssubNode.getNextSibling().getTextContent();
            subNode = subNode.getNextSibling();
        }
        startNode.setMetaData("TriggerMapping", target);
        startNode.addOutMapping(dataOutputs.get(source), target);
    } else {
        startNode.addOutMapping(dataOutputs.get(source), target);
    }
}
Also used : Transformation(io.automatiko.engine.workflow.process.core.node.Transformation) DataTransformer(io.automatiko.engine.api.runtime.process.DataTransformer) Node(io.automatiko.engine.workflow.process.core.Node) EventSubProcessNode(io.automatiko.engine.workflow.process.core.node.EventSubProcessNode) StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) EventTransformerImpl(io.automatiko.engine.workflow.base.core.event.EventTransformerImpl)

Example 3 with EventTransformerImpl

use of io.automatiko.engine.workflow.base.core.event.EventTransformerImpl 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 4 with EventTransformerImpl

use of io.automatiko.engine.workflow.base.core.event.EventTransformerImpl 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)

Example 5 with EventTransformerImpl

use of io.automatiko.engine.workflow.base.core.event.EventTransformerImpl in project automatiko-engine by automatiko-io.

the class HandleMessageAction method execute.

public void execute(ProcessContext context) throws Exception {
    Object variable = VariableUtil.resolveVariable(variableName, context.getNodeInstance());
    if (transformation != null) {
        variable = new EventTransformerImpl(transformation).transformEvent(variable);
    }
    WorkItemImpl workItem = new WorkItemImpl();
    workItem.setName("Send Task");
    workItem.setNodeInstanceId(context.getNodeInstance().getId());
    workItem.setProcessInstanceId(context.getProcessInstance().getId());
    workItem.setProcessInstanceId(context.getProcessInstance().getParentProcessInstanceId());
    workItem.setNodeId(context.getNodeInstance().getNodeId());
    workItem.setParameter("MessageType", messageType);
    if (variable != null) {
        workItem.setParameter("Message", variable);
    }
    ((DefaultWorkItemManager) context.getProcessRuntime().getWorkItemManager()).internalExecuteWorkItem(workItem);
}
Also used : DefaultWorkItemManager(io.automatiko.engine.workflow.base.instance.impl.workitem.DefaultWorkItemManager) WorkItemImpl(io.automatiko.engine.workflow.base.instance.impl.workitem.WorkItemImpl) EventTransformerImpl(io.automatiko.engine.workflow.base.core.event.EventTransformerImpl)

Aggregations

EventTransformerImpl (io.automatiko.engine.workflow.base.core.event.EventTransformerImpl)5 DataTransformer (io.automatiko.engine.api.runtime.process.DataTransformer)3 Transformation (io.automatiko.engine.workflow.process.core.node.Transformation)3 Node (io.automatiko.engine.workflow.process.core.Node)2 ProcessInstance (io.automatiko.engine.workflow.base.instance.ProcessInstance)1 ExceptionScopeInstance (io.automatiko.engine.workflow.base.instance.context.exception.ExceptionScopeInstance)1 DefaultWorkItemManager (io.automatiko.engine.workflow.base.instance.impl.workitem.DefaultWorkItemManager)1 WorkItemImpl (io.automatiko.engine.workflow.base.instance.impl.workitem.WorkItemImpl)1 CatchLinkNode (io.automatiko.engine.workflow.process.core.node.CatchLinkNode)1 CompositeNode (io.automatiko.engine.workflow.process.core.node.CompositeNode)1 EventNode (io.automatiko.engine.workflow.process.core.node.EventNode)1 EventSubProcessNode (io.automatiko.engine.workflow.process.core.node.EventSubProcessNode)1 StartNode (io.automatiko.engine.workflow.process.core.node.StartNode)1 StateNode (io.automatiko.engine.workflow.process.core.node.StateNode)1 TimerNode (io.automatiko.engine.workflow.process.core.node.TimerNode)1