Search in sources :

Example 16 with DataTransformer

use of org.kie.api.runtime.process.DataTransformer in project jbpm by kiegroup.

the class ActionNodeBuilder method build.

public void build(Process process, ProcessDescr processDescr, ProcessBuildContext context, Node node) {
    super.build(process, processDescr, context, node);
    ActionNode actionNode = (ActionNode) node;
    DroolsConsequenceAction action = (DroolsConsequenceAction) actionNode.getAction();
    ActionDescr actionDescr = new ActionDescr();
    actionDescr.setText(action.getConsequence());
    actionDescr.setResource(processDescr.getResource());
    ProcessDialect dialect = ProcessDialectRegistry.getDialect(action.getDialect());
    dialect.getActionBuilder().build(context, action, actionDescr, (NodeImpl) node);
    Transformation transformation = (Transformation) node.getMetaData().get("Transformation");
    if (transformation != null) {
        WorkflowProcess wfProcess = (WorkflowProcess) process;
        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put("imports", wfProcess.getImports());
        parameters.put("classloader", context.getConfiguration().getClassLoader());
        DataTransformer transformer = DataTransformerRegistry.get().find(transformation.getLanguage());
        transformation.setCompiledExpression(transformer.compile(transformation.getExpression(), parameters));
    }
}
Also used : Transformation(org.jbpm.workflow.core.node.Transformation) DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) DataTransformer(org.kie.api.runtime.process.DataTransformer) HashMap(java.util.HashMap) ActionDescr(org.drools.compiler.lang.descr.ActionDescr) ActionNode(org.jbpm.workflow.core.node.ActionNode) ProcessDialect(org.jbpm.process.builder.dialect.ProcessDialect) WorkflowProcess(org.jbpm.workflow.core.WorkflowProcess)

Example 17 with DataTransformer

use of org.kie.api.runtime.process.DataTransformer in project jbpm by kiegroup.

the class EventNodeBuilder method build.

@Override
public void build(Process process, ProcessDescr processDescr, ProcessBuildContext context, Node node) {
    Transformation transformation = (Transformation) node.getMetaData().get("Transformation");
    if (transformation != null) {
        WorkflowProcess wfProcess = (WorkflowProcess) process;
        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put("imports", wfProcess.getImports());
        parameters.put("classloader", context.getConfiguration().getClassLoader());
        DataTransformer transformer = DataTransformerRegistry.get().find(transformation.getLanguage());
        transformation.setCompiledExpression(transformer.compile(transformation.getExpression(), parameters));
    }
}
Also used : Transformation(org.jbpm.workflow.core.node.Transformation) DataTransformer(org.kie.api.runtime.process.DataTransformer) HashMap(java.util.HashMap) WorkflowProcess(org.jbpm.workflow.core.WorkflowProcess)

Example 18 with DataTransformer

use of org.kie.api.runtime.process.DataTransformer in project jbpm by kiegroup.

the class RuleSetNodeBuilder method build.

@Override
public void build(Process process, ProcessDescr processDescr, ProcessBuildContext context, Node node) {
    super.build(process, processDescr, context, node);
    WorkflowProcess wfProcess = (WorkflowProcess) process;
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("imports", wfProcess.getImports());
    parameters.put("classloader", context.getConfiguration().getClassLoader());
    for (DataAssociation dataAssociation : ((RuleSetNode) node).getInAssociations()) {
        Transformation transformation = dataAssociation.getTransformation();
        if (transformation != null) {
            DataTransformer transformer = DataTransformerRegistry.get().find(transformation.getLanguage());
            transformation.setCompiledExpression(transformer.compile(transformation.getExpression(), parameters));
        }
    }
    for (DataAssociation dataAssociation : ((RuleSetNode) node).getOutAssociations()) {
        Transformation transformation = dataAssociation.getTransformation();
        if (transformation != null) {
            DataTransformer transformer = DataTransformerRegistry.get().find(transformation.getLanguage());
            transformation.setCompiledExpression(transformer.compile(transformation.getExpression(), parameters));
        }
    }
}
Also used : Transformation(org.jbpm.workflow.core.node.Transformation) DataTransformer(org.kie.api.runtime.process.DataTransformer) HashMap(java.util.HashMap) DataAssociation(org.jbpm.workflow.core.node.DataAssociation) RuleSetNode(org.jbpm.workflow.core.node.RuleSetNode) WorkflowProcess(org.jbpm.workflow.core.WorkflowProcess)

Example 19 with DataTransformer

use of org.kie.api.runtime.process.DataTransformer in project jbpm by kiegroup.

the class StartNodeBuilder method build.

@Override
public void build(Process process, ProcessDescr processDescr, ProcessBuildContext context, Node node) {
    super.build(process, processDescr, context, node);
    Transformation transformation = (Transformation) node.getMetaData().get("Transformation");
    if (transformation != null) {
        WorkflowProcess wfProcess = (WorkflowProcess) process;
        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put("imports", wfProcess.getImports());
        parameters.put("classloader", context.getConfiguration().getClassLoader());
        DataTransformer transformer = DataTransformerRegistry.get().find(transformation.getLanguage());
        transformation.setCompiledExpression(transformer.compile(transformation.getExpression(), parameters));
    }
}
Also used : Transformation(org.jbpm.workflow.core.node.Transformation) DataTransformer(org.kie.api.runtime.process.DataTransformer) HashMap(java.util.HashMap) WorkflowProcess(org.jbpm.workflow.core.WorkflowProcess)

Example 20 with DataTransformer

use of org.kie.api.runtime.process.DataTransformer in project jbpm by kiegroup.

the class BoundaryEventHandler method readDataOutputAssociation.

protected void readDataOutputAssociation(org.w3c.dom.Node xmlNode, EventNode eventNode) {
    // sourceRef
    org.w3c.dom.Node subNode = xmlNode.getFirstChild();
    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, dataOutputs.get(from));
        eventNode.setMetaData("Transformation", transformation);
        eventNode.setEventTransformer(new EventTransformerImpl(transformation));
    }
    eventNode.setVariableName(to);
}
Also used : Transformation(org.jbpm.workflow.core.node.Transformation) DataTransformer(org.kie.api.runtime.process.DataTransformer) EventTransformerImpl(org.jbpm.process.core.event.EventTransformerImpl)

Aggregations

DataTransformer (org.kie.api.runtime.process.DataTransformer)25 Transformation (org.jbpm.workflow.core.node.Transformation)22 DataAssociation (org.jbpm.workflow.core.node.DataAssociation)13 HashMap (java.util.HashMap)12 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 Test (org.junit.Test)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