use of org.jbpm.workflow.core.impl.DataDefinition in project kogito-runtimes by kiegroup.
the class ActivityTest method testUserTaskWithAssignment.
@Test
public void testUserTaskWithAssignment() throws Exception {
ProcessDialectRegistry.setDialect("custom", new ProcessDialect() {
@Override
public ReturnValueEvaluatorBuilder getReturnValueEvaluatorBuilder() {
// TODO Auto-generated method stub
return null;
}
@Override
public ProcessClassBuilder getProcessClassBuilder() {
return null;
}
@Override
public AssignmentBuilder getAssignmentBuilder() {
return new AssignmentBuilder() {
@Override
public void build(PackageBuildContext context, Assignment assignment, List<DataDefinition> sourceExpr, DataDefinition targetExpr) {
assertEquals("from_expression", assignment.getFrom().getExpression());
assertEquals("to_expression", assignment.getTo().getExpression());
}
};
}
@Override
public ActionBuilder getActionBuilder() {
return null;
}
@Override
public void addProcess(ProcessBuildContext context) {
}
});
kruntime = createKogitoProcessRuntime("BPMN2-DataOutputAssignmentCustomExpressionLang.bpmn2");
Process scriptProcess = kruntime.getKieBase().getProcess("process");
assertThat(scriptProcess).isNotNull();
Node[] nodes = ((NodeContainer) scriptProcess).getNodes();
assertThat(nodes).hasSize(3);
assertThat(nodes).filteredOn(n -> n instanceof WorkItemNode).allMatch(this::matchExpectedAssociationSetup);
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
Map<String, Object> params = new HashMap<>();
params.put("name", "John");
KogitoProcessInstance processInstance = kruntime.startProcess("process", params);
kruntime.abortProcessInstance(processInstance.getStringId());
assertProcessInstanceAborted(processInstance);
}
use of org.jbpm.workflow.core.impl.DataDefinition 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.DataDefinition in project kogito-runtimes by kiegroup.
the class AbstractNodeHandler method writeDataAssociation.
protected void writeDataAssociation(DataAssociation input, StringBuilder xmlDump) {
for (DataDefinition source : input.getSources()) {
xmlDump.append(" <sourceRef>" + source.getId() + "</sourceRef>" + EOL);
}
if (input.getTarget() != null) {
xmlDump.append("<targetRef>" + input.getTarget().getId() + "</targetRef>" + EOL);
}
if (!input.getAssignments().isEmpty()) {
for (Assignment assignment : input.getAssignments()) {
xmlDump.append(" <assignment>" + EOL);
xmlDump.append(" <from xsi:type=\"tFormalExpression\">" + assignment.getFrom().getExpression() + "</from>");
xmlDump.append(" <to xsi:type=\"tFormalExpression\">" + assignment.getTo().getExpression() + "</to>");
xmlDump.append(" </assignment>" + EOL);
}
}
}
use of org.jbpm.workflow.core.impl.DataDefinition in project kogito-runtimes by kiegroup.
the class AbstractNodeHandler method readDataAssociation.
protected Optional<DataAssociation> readDataAssociation(ExtensibleXmlParser parser, org.w3c.dom.Element element, Function<String, DataDefinition> sourceResolver, Function<String, DataDefinition> targetResolver) {
List<DataDefinition> sources = readSources(element, sourceResolver);
DataDefinition target = readTarget(element, targetResolver);
List<Assignment> assignments = readAssignments(element, target, src -> {
if (".".equals(src)) {
return sources.get(0);
}
return sourceResolver.apply(src);
}, dst -> {
if (".".equals(dst)) {
return target;
}
return targetResolver.apply(dst);
});
Transformation transformation = readTransformation(element);
DataAssociation da = new DataAssociation(sources, target, assignments, transformation);
if (da.getTarget() != null && da.getSources().isEmpty() && da.getAssignments().isEmpty()) {
// incomplete description we ignore it
logger.debug("Read incomplete data association, will be ignored\n{}", da);
return Optional.empty();
}
return Optional.of(da);
}
use of org.jbpm.workflow.core.impl.DataDefinition in project kogito-runtimes by kiegroup.
the class AbstractNodeHandler method readMultiInstanceSpecification.
// this is only for compiling purposes
protected MultiInstanceSpecification readMultiInstanceSpecification(ExtensibleXmlParser parser, org.w3c.dom.Node parent, IOSpecification ioSpecification) {
MultiInstanceSpecification multiInstanceSpecification = new MultiInstanceSpecification();
Optional<Element> multiInstanceParent = readSingleChildElementByTag(parent, "multiInstanceLoopCharacteristics");
if (multiInstanceParent.isEmpty()) {
return multiInstanceSpecification;
}
Element multiInstanceNode = multiInstanceParent.get();
multiInstanceSpecification.setSequential(Boolean.parseBoolean(multiInstanceNode.getAttribute("isSequential")));
readSingleChildElementByTag(multiInstanceNode, "inputDataItem").ifPresent(inputDataItem -> {
String id = inputDataItem.getAttribute("id");
String name = inputDataItem.getAttribute("name");
String itemSubjectRef = inputDataItem.getAttribute("itemSubjectRef");
ItemDefinition itemDefinition = getStructureRef(parser, itemSubjectRef);
String structureRef = itemDefinition != null ? itemDefinition.getStructureRef() : null;
DataDefinition input = new DataDefinition(id, name, structureRef);
multiInstanceSpecification.setInputDataItem(input);
if (!ioSpecification.containsInputLabel(input.getLabel())) {
ioSpecification.getDataInputs().add(input);
}
});
readSingleChildElementByTag(multiInstanceNode, "outputDataItem").ifPresent(outputDataItem -> {
String id = outputDataItem.getAttribute("id");
String name = outputDataItem.getAttribute("name");
String itemSubjectRef = outputDataItem.getAttribute("itemSubjectRef");
ItemDefinition itemDefinition = getStructureRef(parser, itemSubjectRef);
String structureRef = itemDefinition != null ? itemDefinition.getStructureRef() : null;
DataDefinition output = new DataDefinition(id, name, structureRef);
multiInstanceSpecification.setOutputDataItem(output);
if (!ioSpecification.containsOutputLabel(output.getLabel())) {
ioSpecification.getDataOutputs().add(output);
}
});
readSingleChildElementByTag(multiInstanceNode, "loopDataOutputRef").ifPresent(loopDataOutputRef -> {
String expressiontOutput = loopDataOutputRef.getTextContent();
if (expressiontOutput != null && !expressiontOutput.isEmpty()) {
multiInstanceSpecification.setLoopDataOutputRef(ioSpecification.getDataOutput().get(expressiontOutput));
}
});
readSingleChildElementByTag(multiInstanceNode, "loopDataInputRef").ifPresent(loopDataInputRef -> {
String expressionInput = loopDataInputRef.getTextContent();
if (expressionInput != null && !expressionInput.isEmpty()) {
multiInstanceSpecification.setLoopDataInputRef(ioSpecification.getDataInput().get(expressionInput));
}
});
readSingleChildElementByTag(multiInstanceNode, COMPLETION_CONDITION).ifPresent(completeCondition -> {
String completion = completeCondition.getTextContent();
if (completion != null && !completion.isEmpty()) {
multiInstanceSpecification.setCompletionCondition(completion);
}
});
return multiInstanceSpecification;
}
Aggregations