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);
}
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);
}
}
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);
}
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);
}
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());
}
}
}
}
}
Aggregations