Search in sources :

Example 21 with Transformation

use of org.jbpm.workflow.core.node.Transformation in project jbpm by kiegroup.

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.");
    }
    // targetRef
    subNode = subNode.getNextSibling();
    if (!"targetRef".equals(subNode.getNodeName())) {
        throw new IllegalArgumentException("No targetRef found in dataOutputAssociation in startEvent");
    }
    String target = subNode.getTextContent();
    startNode.setMetaData("TriggerMapping", target);
    // 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, dataOutputs.get(source));
        startNode.setMetaData("Transformation", transformation);
        startNode.setEventTransformer(new EventTransformerImpl(transformation));
        subNode = subNode.getNextSibling();
    }
    if (subNode != null) {
        // no support for assignments
        throw new UnsupportedOperationException(subNode.getNodeName() + " elements in dataOutputAssociations are not yet supported.");
    }
    startNode.addOutMapping(target, dataOutputs.get(source));
}
Also used : Transformation(org.jbpm.workflow.core.node.Transformation) DataTransformer(org.kie.api.runtime.process.DataTransformer) EventTransformerImpl(org.jbpm.process.core.event.EventTransformerImpl)

Example 22 with Transformation

use of org.jbpm.workflow.core.node.Transformation in project jbpm by kiegroup.

the class TaskHandler method readDataOutputAssociation.

protected void readDataOutputAssociation(org.w3c.dom.Node xmlNode, WorkItemNode workItemNode, Map<String, String> dataOutputs) {
    // sourceRef
    org.w3c.dom.Node subNode = xmlNode.getFirstChild();
    String source = 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, source);
        // transformation.setCompiledExpression(transformer.compile(expression));
        subNode = subNode.getNextSibling();
    }
    // assignments
    List<Assignment> assignments = new LinkedList<Assignment>();
    while (subNode != null) {
        org.w3c.dom.Node ssubNode = subNode.getFirstChild();
        String from = ssubNode.getTextContent();
        String to = ssubNode.getNextSibling().getTextContent();
        assignments.add(new Assignment("XPath", from, to));
        subNode = subNode.getNextSibling();
    }
    workItemNode.addOutAssociation(new DataAssociation(dataOutputs.get(source), target, assignments, transformation));
}
Also used : Assignment(org.jbpm.workflow.core.node.Assignment) Transformation(org.jbpm.workflow.core.node.Transformation) DataTransformer(org.kie.api.runtime.process.DataTransformer) DataAssociation(org.jbpm.workflow.core.node.DataAssociation) LinkedList(java.util.LinkedList)

Aggregations

Transformation (org.jbpm.workflow.core.node.Transformation)22 DataTransformer (org.kie.api.runtime.process.DataTransformer)22 DataAssociation (org.jbpm.workflow.core.node.DataAssociation)13 HashMap (java.util.HashMap)9 VariableScopeInstance (org.jbpm.process.instance.context.variable.VariableScopeInstance)6 WorkflowProcess (org.jbpm.workflow.core.WorkflowProcess)6 Assignment (org.jbpm.workflow.core.node.Assignment)5 LinkedList (java.util.LinkedList)4 Map (java.util.Map)3 EventTransformerImpl (org.jbpm.process.core.event.EventTransformerImpl)3 NodeInstanceResolverFactory (org.jbpm.workflow.instance.impl.NodeInstanceResolverFactory)3 NodeList (org.w3c.dom.NodeList)3 Text (org.w3c.dom.Text)3 Iterator (java.util.Iterator)2 Matcher (java.util.regex.Matcher)2 WorkItem (org.drools.core.process.instance.WorkItem)2 ProcessDialect (org.jbpm.process.builder.dialect.ProcessDialect)2 Variable (org.jbpm.process.core.context.variable.Variable)2 DataType (org.jbpm.process.core.datatype.DataType)2 ProcessInstance (org.jbpm.process.instance.ProcessInstance)2