Search in sources :

Example 11 with DataDefinition

use of org.jbpm.workflow.core.impl.DataDefinition in project kogito-runtimes by kiegroup.

the class AbstractNodeHandler method decorateMultiInstanceSpecificationSubProcess.

protected NodeImpl decorateMultiInstanceSpecificationSubProcess(CompositeContextNode nodeTarget, MultiInstanceSpecification multiInstanceSpecification) {
    ForEachNode forEachNode = decorateMultiInstanceSpecification(nodeTarget, multiInstanceSpecification);
    forEachNode.setMetaData("UniqueId", (String) nodeTarget.getMetaData().get("UniqueId"));
    forEachNode.setMetaData(ProcessHandler.CONNECTIONS, nodeTarget.getMetaData(ProcessHandler.CONNECTIONS));
    forEachNode.setAutoComplete(nodeTarget.isAutoComplete());
    // within the composite
    for (org.kie.api.definition.process.Node subNode : nodeTarget.getNodes()) {
        forEachNode.addNode(subNode);
    }
    // this is the context of each subprocess
    VariableScope subProcessVariableScope = ((VariableScope) forEachNode.getCompositeNode().getDefaultContext(VariableScope.VARIABLE_SCOPE));
    // we setup the property/data objects of the subprocess to the foreach scope of the subprocess
    // the subprocess itself scope has no effect as nodes were included in the new scope (not the old one. Look
    // at the previous for each.
    VariableScope oldSubProcessVariables = (VariableScope) nodeTarget.getDefaultContext(VariableScope.VARIABLE_SCOPE);
    oldSubProcessVariables.getVariables().forEach(subProcessVariableScope::addVariable);
    // item is the element within the collection so Collection (E1,E2....En) -> Subcontext 1 (item - E1), Subcontext 2 (item - E2)
    DataDefinition inputItem = multiInstanceSpecification.getInputDataItem();
    if (inputItem != null) {
        Variable var = new Variable();
        var.setId(inputItem.getId());
        var.setName(inputItem.getLabel());
        var.setType(DataTypeResolver.fromType(inputItem.getType(), Thread.currentThread().getContextClassLoader()));
        subProcessVariableScope.addVariable(var);
    }
    return forEachNode;
}
Also used : Variable(org.jbpm.process.core.context.variable.Variable) ForEachNode(org.jbpm.workflow.core.node.ForEachNode) DataDefinition(org.jbpm.workflow.core.impl.DataDefinition) VariableScope(org.jbpm.process.core.context.variable.VariableScope)

Example 12 with DataDefinition

use of org.jbpm.workflow.core.impl.DataDefinition in project kogito-runtimes by kiegroup.

the class AbstractNodeHandler method readTarget.

protected DataDefinition readTarget(org.w3c.dom.Node parent, Function<String, DataDefinition> variableResolver) {
    Optional<Element> element = readSingleChildElementByTag(parent, "targetRef");
    if (element.isEmpty()) {
        return null;
    } else {
        String varRef = element.get().getTextContent().trim();
        DataDefinition varResolved = variableResolver.apply(varRef);
        return varResolved != null ? varResolved : DataDefinition.toSimpleDefinition(varRef);
    }
}
Also used : Element(org.w3c.dom.Element) DataDefinition(org.jbpm.workflow.core.impl.DataDefinition)

Example 13 with DataDefinition

use of org.jbpm.workflow.core.impl.DataDefinition in project kogito-runtimes by kiegroup.

the class AbstractNodeHandler method writeIO.

protected void writeIO(IOSpecification ioSpecification, StringBuilder xmlDump) {
    xmlDump.append("      <ioSpecification>" + EOL);
    for (DataDefinition input : ioSpecification.getDataInput().values()) {
        xmlDump.append("        <dataInput id=\"" + input.getId() + "\" name=\"" + input.getLabel() + "\" />" + EOL);
    }
    for (DataDefinition output : ioSpecification.getDataOutput().values()) {
        xmlDump.append("        <dataOutput id=\"" + output.getId() + "\" name=\"" + output.getLabel() + "\" />" + EOL);
    }
    for (DataAssociation input : ioSpecification.getDataInputAssociation()) {
        xmlDump.append("      <dataInputAssociation>" + EOL);
        writeDataAssociation(input, xmlDump);
        xmlDump.append("      </dataInputAssociation>" + EOL);
    }
    for (DataAssociation output : ioSpecification.getDataOutputAssociation()) {
        xmlDump.append("      <dataOutputAssociation>" + EOL);
        writeDataAssociation(output, xmlDump);
        xmlDump.append("      </dataOutputAssociation>" + EOL);
    }
    xmlDump.append("      </ioSpecification>" + EOL);
}
Also used : DataAssociation(org.jbpm.workflow.core.impl.DataAssociation) DataDefinition(org.jbpm.workflow.core.impl.DataDefinition)

Example 14 with DataDefinition

use of org.jbpm.workflow.core.impl.DataDefinition in project kogito-runtimes by kiegroup.

the class AbstractNodeHandler method getVariableDataSpec.

protected DataDefinition getVariableDataSpec(Parser parser, String propertyIdRef) {
    RuleFlowProcess process = (RuleFlowProcess) ((ProcessBuildData) parser.getData()).getMetaData(ProcessHandler.CURRENT_PROCESS);
    Optional<Variable> var = process.getVariableScope().getVariables().stream().filter(e -> e.getId().equals(propertyIdRef)).findAny();
    if (var.isEmpty()) {
        return null;
    }
    Variable variable = var.get();
    return new DataDefinition(variable.getId(), variable.getName(), variable.getType().getStringType());
}
Also used : SequenceFlow(org.jbpm.bpmn2.core.SequenceFlow) ForEachNode(org.jbpm.workflow.core.node.ForEachNode) LoggerFactory(org.slf4j.LoggerFactory) BaseAbstractHandler(org.jbpm.compiler.xml.core.BaseAbstractHandler) PatternConstants(org.jbpm.util.PatternConstants) NodeImpl(org.jbpm.workflow.core.impl.NodeImpl) Thread.currentThread(java.lang.Thread.currentThread) DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) ItemDefinition(org.jbpm.bpmn2.core.ItemDefinition) Assignment(org.jbpm.workflow.core.node.Assignment) Association(org.jbpm.bpmn2.core.Association) StateNode(org.jbpm.workflow.core.node.StateNode) Matcher(java.util.regex.Matcher) ProcessBuildData(org.jbpm.compiler.xml.ProcessBuildData) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) Signal(org.jbpm.bpmn2.core.Signal) Transformation(org.jbpm.workflow.core.node.Transformation) IOSpecification(org.jbpm.workflow.core.impl.IOSpecification) MultiInstanceSpecification(org.jbpm.workflow.core.impl.MultiInstanceSpecification) CatchLinkNode(org.jbpm.workflow.core.node.CatchLinkNode) CompositeContextNode(org.jbpm.workflow.core.node.CompositeContextNode) Collection(java.util.Collection) XmlDumper(org.jbpm.compiler.xml.compiler.XmlDumper) Set(java.util.Set) UUID(java.util.UUID) VariableScope(org.jbpm.process.core.context.variable.VariableScope) List(java.util.List) Error(org.jbpm.bpmn2.core.Error) ContextContainer(org.jbpm.process.core.ContextContainer) Node(org.jbpm.workflow.core.Node) JavaDialect(org.drools.mvel.java.JavaDialect) SAXException(org.xml.sax.SAXException) Optional(java.util.Optional) MAPPING_VARIABLE_INPUT(org.jbpm.ruleflow.core.Metadata.MAPPING_VARIABLE_INPUT) VARIABLE(org.jbpm.ruleflow.core.Metadata.VARIABLE) RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) DataDefinition(org.jbpm.workflow.core.impl.DataDefinition) HashMap(java.util.HashMap) Function(java.util.function.Function) ArrayList(java.util.ArrayList) Lane(org.jbpm.bpmn2.core.Lane) TimerNode(org.jbpm.workflow.core.node.TimerNode) HashSet(java.util.HashSet) DataTypeResolver.fromType(org.jbpm.process.core.datatype.DataTypeResolver.fromType) NodeContainer(org.jbpm.workflow.core.NodeContainer) DataAssociation(org.jbpm.workflow.core.impl.DataAssociation) Parser(org.jbpm.compiler.xml.Parser) Attributes(org.xml.sax.Attributes) FaultNode(org.jbpm.workflow.core.node.FaultNode) DroolsAction(org.jbpm.workflow.core.DroolsAction) Variable(org.jbpm.process.core.context.variable.Variable) DataTransformer(org.kie.api.runtime.process.DataTransformer) ActionNode(org.jbpm.workflow.core.node.ActionNode) EndNode(org.jbpm.workflow.core.node.EndNode) Logger(org.slf4j.Logger) NodeList(org.w3c.dom.NodeList) Iterator(java.util.Iterator) EventNode(org.jbpm.workflow.core.node.EventNode) ExtensibleXmlParser(org.jbpm.compiler.xml.core.ExtensibleXmlParser) COMPLETION_CONDITION(org.jbpm.ruleflow.core.Metadata.COMPLETION_CONDITION) Handler(org.jbpm.compiler.xml.Handler) DataTypeResolver(org.jbpm.process.core.datatype.DataTypeResolver) SAXParseException(org.xml.sax.SAXParseException) Element(org.w3c.dom.Element) DataTransformerRegistry(org.jbpm.process.core.impl.DataTransformerRegistry) MAPPING_VARIABLE(org.jbpm.ruleflow.core.Metadata.MAPPING_VARIABLE) Definitions(org.jbpm.bpmn2.core.Definitions) ExtendedNodeImpl(org.jbpm.workflow.core.impl.ExtendedNodeImpl) RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) Variable(org.jbpm.process.core.context.variable.Variable) DataDefinition(org.jbpm.workflow.core.impl.DataDefinition)

Example 15 with DataDefinition

use of org.jbpm.workflow.core.impl.DataDefinition in project kogito-runtimes by kiegroup.

the class AbstractNodeHandler method toDataExpression.

private DataDefinition toDataExpression(String expression) {
    DataDefinition dataSpec = new DataDefinition(UUID.randomUUID().toString(), "EXPRESSION (" + expression + ")", null);
    dataSpec.setExpression(expression);
    return dataSpec;
}
Also used : DataDefinition(org.jbpm.workflow.core.impl.DataDefinition)

Aggregations

DataDefinition (org.jbpm.workflow.core.impl.DataDefinition)31 DataAssociation (org.jbpm.workflow.core.impl.DataAssociation)12 ArrayList (java.util.ArrayList)9 Assignment (org.jbpm.workflow.core.node.Assignment)9 VariableScope (org.jbpm.process.core.context.variable.VariableScope)8 Element (org.w3c.dom.Element)7 Node (org.jbpm.workflow.core.Node)6 Transformation (org.jbpm.workflow.core.node.Transformation)6 ItemDefinition (org.jbpm.bpmn2.core.ItemDefinition)5 MultiInstanceSpecification (org.jbpm.workflow.core.impl.MultiInstanceSpecification)5 HashMap (java.util.HashMap)4 List (java.util.List)4 Map (java.util.Map)4 Variable (org.jbpm.process.core.context.variable.Variable)4 DataTransformerRegistry (org.jbpm.process.core.impl.DataTransformerRegistry)4 StringLiteralExpr (com.github.javaparser.ast.expr.StringLiteralExpr)3 ClassOrInterfaceType (com.github.javaparser.ast.type.ClassOrInterfaceType)3 Thread.currentThread (java.lang.Thread.currentThread)3 Collection (java.util.Collection)3 HashSet (java.util.HashSet)3