Search in sources :

Example 11 with DataAssociation

use of org.jbpm.workflow.core.node.DataAssociation 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 12 with DataAssociation

use of org.jbpm.workflow.core.node.DataAssociation 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

DataAssociation (org.jbpm.workflow.core.node.DataAssociation)12 Transformation (org.jbpm.workflow.core.node.Transformation)12 DataTransformer (org.kie.api.runtime.process.DataTransformer)12 HashMap (java.util.HashMap)6 VariableScopeInstance (org.jbpm.process.instance.context.variable.VariableScopeInstance)5 Assignment (org.jbpm.workflow.core.node.Assignment)5 LinkedList (java.util.LinkedList)4 Map (java.util.Map)3 WorkflowProcess (org.jbpm.workflow.core.WorkflowProcess)3 NodeInstanceResolverFactory (org.jbpm.workflow.instance.impl.NodeInstanceResolverFactory)3 Iterator (java.util.Iterator)2 Matcher (java.util.regex.Matcher)2 WorkItem (org.drools.core.process.instance.WorkItem)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 RuleSetNode (org.jbpm.workflow.core.node.RuleSetNode)2 WorkItemNode (org.jbpm.workflow.core.node.WorkItemNode)2 KieRuntime (org.kie.api.runtime.KieRuntime)2 NodeList (org.w3c.dom.NodeList)2