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