Search in sources :

Example 16 with Assignment

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

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();
    List<String> sources = new ArrayList<>();
    sources.add(subNode.getTextContent());
    subNode = subNode.getNextSibling();
    while ("sourceRef".equals(subNode.getNodeName())) {
        sources.add(subNode.getTextContent());
        subNode = subNode.getNextSibling();
    }
    // targetRef
    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);
        // transformation.setCompiledExpression(transformer.compile(expression));
        subNode = subNode.getNextSibling();
    }
    // assignments
    List<Assignment> assignments = new LinkedList<Assignment>();
    while (subNode != null) {
        String expressionLang = ((Element) subNode).getAttribute("expressionLanguage");
        if (expressionLang == null || expressionLang.trim().isEmpty()) {
            expressionLang = "XPath";
        }
        org.w3c.dom.Node ssubNode = subNode.getFirstChild();
        String from = ssubNode.getTextContent();
        String to = ssubNode.getNextSibling().getTextContent();
        assignments.add(new Assignment(expressionLang, from, to));
        subNode = subNode.getNextSibling();
    }
    workItemNode.addOutAssociation(new DataAssociation(sources.stream().map(source -> dataOutputs.get(source)).collect(Collectors.toList()), target, assignments, transformation));
}
Also used : Text(org.w3c.dom.Text) Assignment(io.automatiko.engine.workflow.process.core.node.Assignment) ItemDefinition(io.automatiko.engine.workflow.bpmn2.core.ItemDefinition) NodeContainer(io.automatiko.engine.workflow.process.core.NodeContainer) ObjectDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType) ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) ArrayList(java.util.ArrayList) DataTransformer(io.automatiko.engine.api.runtime.process.DataTransformer) LinkedHashMap(java.util.LinkedHashMap) NodeImpl(io.automatiko.engine.workflow.process.core.impl.NodeImpl) DataAssociation(io.automatiko.engine.workflow.process.core.node.DataAssociation) Map(java.util.Map) Attributes(org.xml.sax.Attributes) LinkedList(java.util.LinkedList) Node(io.automatiko.engine.workflow.process.core.Node) ParameterDefinition(io.automatiko.engine.workflow.base.core.ParameterDefinition) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) NodeList(org.w3c.dom.NodeList) MilestoneNode(io.automatiko.engine.workflow.process.core.node.MilestoneNode) Collectors(java.util.stream.Collectors) ClassUtils.constructClass(io.automatiko.engine.workflow.compiler.util.ClassUtils.constructClass) Transformation(io.automatiko.engine.workflow.process.core.node.Transformation) DataTransformerRegistry(io.automatiko.engine.workflow.base.core.impl.DataTransformerRegistry) List(java.util.List) Element(org.w3c.dom.Element) ExtensibleXmlParser(io.automatiko.engine.workflow.compiler.xml.ExtensibleXmlParser) SAXException(org.xml.sax.SAXException) WorkItemNode(io.automatiko.engine.workflow.process.core.node.WorkItemNode) Entry(java.util.Map.Entry) CONDITION(io.automatiko.engine.workflow.process.executable.core.Metadata.CONDITION) ParameterDefinitionImpl(io.automatiko.engine.workflow.base.core.impl.ParameterDefinitionImpl) WorkImpl(io.automatiko.engine.workflow.base.core.impl.WorkImpl) Work(io.automatiko.engine.workflow.base.core.Work) Transformation(io.automatiko.engine.workflow.process.core.node.Transformation) DataAssociation(io.automatiko.engine.workflow.process.core.node.DataAssociation) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) Assignment(io.automatiko.engine.workflow.process.core.node.Assignment) DataTransformer(io.automatiko.engine.api.runtime.process.DataTransformer)

Example 17 with Assignment

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

the class CompositeContextNodeFactory method outMappingWithJqAssignment.

public CompositeContextNodeFactory outMappingWithJqAssignment(String stateDataFilter) {
    Assignment outputAssignment = new Assignment("jq", "", "");
    outputAssignment.setMetaData("Action", new OutputJqAssignmentAction(stateDataFilter));
    getCompositeNode().addOutAssociation(new DataAssociation(Collections.emptyList(), "", Arrays.asList(outputAssignment), null));
    return this;
}
Also used : Assignment(io.automatiko.engine.workflow.process.core.node.Assignment) DataAssociation(io.automatiko.engine.workflow.process.core.node.DataAssociation) OutputJqAssignmentAction(io.automatiko.engine.workflow.base.instance.impl.jq.OutputJqAssignmentAction)

Example 18 with Assignment

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

the class CompositeContextNodeFactory method inMappingWithJqAssignment.

public CompositeContextNodeFactory inMappingWithJqAssignment(String stateDataFilter) {
    Assignment inputAssignment = new Assignment("jq", "", "");
    inputAssignment.setMetaData("Action", new InputJqAssignmentAction(stateDataFilter));
    getCompositeNode().addInAssociation(new DataAssociation(Collections.emptyList(), "", Arrays.asList(inputAssignment), null));
    return this;
}
Also used : Assignment(io.automatiko.engine.workflow.process.core.node.Assignment) DataAssociation(io.automatiko.engine.workflow.process.core.node.DataAssociation) InputJqAssignmentAction(io.automatiko.engine.workflow.base.instance.impl.jq.InputJqAssignmentAction)

Example 19 with Assignment

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

the class MappableNodeFactory method outMappingWithJqAssignment.

default MappableNodeFactory outMappingWithJqAssignment(String outputExpression, String scopeExpression, boolean ignoreScopeExpression) {
    Assignment outAssignment = new Assignment("jq", null, null);
    outAssignment.setMetaData("Action", new TaskOutputJqAssignmentAction(outputExpression, scopeExpression, ignoreScopeExpression));
    getMappableNode().addOutAssociation(new DataAssociation(Collections.emptyList(), "", Arrays.asList(outAssignment), null));
    return this;
}
Also used : Assignment(io.automatiko.engine.workflow.process.core.node.Assignment) DataAssociation(io.automatiko.engine.workflow.process.core.node.DataAssociation) TaskOutputJqAssignmentAction(io.automatiko.engine.workflow.base.instance.impl.jq.TaskOutputJqAssignmentAction)

Example 20 with Assignment

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

the class StartNodeFactory method outMapping.

public StartNodeFactory outMapping(String source, String target, String assignmentDialect, String assignmentFrom, String assignmentTo) {
    List<Assignment> assignments = null;
    if (assignmentFrom != null && assignmentTo != null) {
        assignments = Arrays.asList(new Assignment(assignmentDialect, assignmentFrom, assignmentTo));
    }
    DataAssociation dataAssociation = new DataAssociation(source, target, assignments, null);
    getStartNode().addOutAssociation(dataAssociation);
    return this;
}
Also used : Assignment(io.automatiko.engine.workflow.process.core.node.Assignment) DataAssociation(io.automatiko.engine.workflow.process.core.node.DataAssociation)

Aggregations

Assignment (io.automatiko.engine.workflow.process.core.node.Assignment)20 DataAssociation (io.automatiko.engine.workflow.process.core.node.DataAssociation)20 ArrayList (java.util.ArrayList)9 DataTransformer (io.automatiko.engine.api.runtime.process.DataTransformer)8 Transformation (io.automatiko.engine.workflow.process.core.node.Transformation)8 Map (java.util.Map)8 LinkedList (java.util.LinkedList)6 Element (org.w3c.dom.Element)6 DataTransformerRegistry (io.automatiko.engine.workflow.base.core.impl.DataTransformerRegistry)5 TaskOutputJqAssignmentAction (io.automatiko.engine.workflow.base.instance.impl.jq.TaskOutputJqAssignmentAction)5 List (java.util.List)5 Node (io.automatiko.engine.workflow.process.core.Node)4 NodeContainer (io.automatiko.engine.workflow.process.core.NodeContainer)4 HashMap (java.util.HashMap)4 NodeInstance (io.automatiko.engine.api.runtime.process.NodeInstance)3 WorkItemExecutionError (io.automatiko.engine.api.workflow.workitem.WorkItemExecutionError)3 ProcessContext (io.automatiko.engine.workflow.base.core.context.ProcessContext)3 VARIABLE_SCOPE (io.automatiko.engine.workflow.base.core.context.variable.VariableScope.VARIABLE_SCOPE)3 ProcessInstance (io.automatiko.engine.workflow.base.instance.ProcessInstance)3 VariableScopeInstance (io.automatiko.engine.workflow.base.instance.context.variable.VariableScopeInstance)3