Search in sources :

Example 1 with DataAssociation

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

the class ServerlessWorkflowParser method subprocessNode.

public static <T extends RuleFlowNodeContainerFactory<T, ?>> SubProcessNodeFactory<T> subprocessNode(SubProcessNodeFactory<T> nodeFactory, String inputVar, String outputVar) {
    Map<String, String> types = Collections.singletonMap(DEFAULT_WORKFLOW_VAR, JSON_NODE);
    DataAssociation inputDa = new DataAssociation(new DataDefinition(inputVar, inputVar, JSON_NODE), new DataDefinition(DEFAULT_WORKFLOW_VAR, DEFAULT_WORKFLOW_VAR, JSON_NODE), null, null);
    DataAssociation outputDa = new DataAssociation(new DataDefinition(DEFAULT_WORKFLOW_VAR, DEFAULT_WORKFLOW_VAR, JSON_NODE), new DataDefinition(outputVar, outputVar, JSON_NODE), null, null);
    VariableScope variableScope = new VariableScope();
    return nodeFactory.independent(true).metaData("BPMN.InputTypes", types).metaData("BPMN.OutputTypes", types).mapDataInputAssociation(inputDa).mapDataOutputAssociation(outputDa).context(variableScope).defaultContext(variableScope);
}
Also used : DataAssociation(org.jbpm.workflow.core.impl.DataAssociation) DataDefinition(org.jbpm.workflow.core.impl.DataDefinition) VariableScope(org.jbpm.process.core.context.variable.VariableScope)

Example 2 with DataAssociation

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

the class AbstractNodeHandler method writeCatchIO.

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

Example 3 with DataAssociation

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

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

the class AbstractServiceTaskDescriptor method completeWorkItem.

protected MethodCallExpr completeWorkItem(BlockStmt executeWorkItemBody, MethodCallExpr callService, Collection<Class<?>> exceptions) {
    Expression results;
    List<DataAssociation> outAssociations = workItemNode.getOutAssociations();
    if (outAssociations.isEmpty() || isEmptyResult()) {
        executeWorkItemBody.addStatement(tryStmt(callService, exceptions));
        results = new MethodCallExpr(new NameExpr("java.util.Collections"), "emptyMap");
    } else {
        VariableDeclarationExpr resultField = new VariableDeclarationExpr().addVariable(new VariableDeclarator(new ClassOrInterfaceType(null, Object.class.getCanonicalName()), RESULT_NAME));
        executeWorkItemBody.addStatement(resultField);
        executeWorkItemBody.addStatement(tryStmt(new AssignExpr(new NameExpr(RESULT_NAME), callService, AssignExpr.Operator.ASSIGN), exceptions));
        results = new MethodCallExpr(new NameExpr("java.util.Collections"), "singletonMap").addArgument(new StringLiteralExpr(outAssociations.get(0).getSources().get(0).getLabel())).addArgument(new NameExpr(RESULT_NAME));
    }
    return new MethodCallExpr(new NameExpr("workItemManager"), "completeWorkItem").addArgument(new MethodCallExpr(new NameExpr("workItem"), "getStringId")).addArgument(results);
}
Also used : VariableDeclarationExpr(com.github.javaparser.ast.expr.VariableDeclarationExpr) Expression(com.github.javaparser.ast.expr.Expression) DataAssociation(org.jbpm.workflow.core.impl.DataAssociation) NameExpr(com.github.javaparser.ast.expr.NameExpr) StringLiteralExpr(com.github.javaparser.ast.expr.StringLiteralExpr) ClassOrInterfaceType(com.github.javaparser.ast.type.ClassOrInterfaceType) MethodCallExpr(com.github.javaparser.ast.expr.MethodCallExpr) VariableDeclarator(com.github.javaparser.ast.body.VariableDeclarator) AssignExpr(com.github.javaparser.ast.expr.AssignExpr)

Example 5 with DataAssociation

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

the class ExtendedNodeBuilder method buildDataAssociation.

protected void buildDataAssociation(PackageBuildContext context, Collection<DataAssociation> dataAssociations, Map<String, Object> parameters) {
    for (DataAssociation dataAssociation : dataAssociations) {
        Transformation transformation = dataAssociation.getTransformation();
        if (transformation != null) {
            DataTransformer transformer = DataTransformerRegistry.get().find(transformation.getLanguage());
            transformation.setCompiledExpression(transformer.compile(transformation.getExpression(), parameters));
        }
        List<Assignment> assignments = dataAssociation.getAssignments();
        if (assignments != null) {
            for (Assignment assignment : assignments) {
                if (assignment.getDialect() != null) {
                    ProcessDialect processDialect = ProcessDialectRegistry.getDialect(assignment.getDialect());
                    processDialect.getAssignmentBuilder().build(context, assignment, dataAssociation.getSources(), dataAssociation.getTarget());
                }
            }
        }
    }
}
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.impl.DataAssociation) ProcessDialect(org.jbpm.process.builder.dialect.ProcessDialect)

Aggregations

DataAssociation (org.jbpm.workflow.core.impl.DataAssociation)13 DataDefinition (org.jbpm.workflow.core.impl.DataDefinition)7 Assignment (org.jbpm.workflow.core.node.Assignment)5 Transformation (org.jbpm.workflow.core.node.Transformation)3 Element (org.w3c.dom.Element)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 VariableScope (org.jbpm.process.core.context.variable.VariableScope)2 DroolsConsequenceAction (org.jbpm.workflow.core.impl.DroolsConsequenceAction)2 ActionNode (org.jbpm.workflow.core.node.ActionNode)2 EventNode (org.jbpm.workflow.core.node.EventNode)2 VariableDeclarator (com.github.javaparser.ast.body.VariableDeclarator)1 AssignExpr (com.github.javaparser.ast.expr.AssignExpr)1 Expression (com.github.javaparser.ast.expr.Expression)1 MethodCallExpr (com.github.javaparser.ast.expr.MethodCallExpr)1 NameExpr (com.github.javaparser.ast.expr.NameExpr)1 StringLiteralExpr (com.github.javaparser.ast.expr.StringLiteralExpr)1 VariableDeclarationExpr (com.github.javaparser.ast.expr.VariableDeclarationExpr)1 ClassOrInterfaceType (com.github.javaparser.ast.type.ClassOrInterfaceType)1 Thread.currentThread (java.lang.Thread.currentThread)1