use of io.automatiko.engine.decision.dmn.DmnDecisionModel in project automatiko-engine by automatiko-io.
the class DmnDecisionInProcessTest method createProcess.
private ExecutableProcess createProcess(String namespace, String modelName, String decisionName) {
DMNRuntime dmnRuntime = DmnRuntimeProvider.fromClassPath("PersonDecisions.dmn");
DmnDecisionModel dmnDecisionModel = new DmnDecisionModel(dmnRuntime, namespace, modelName);
ExecutableProcess process = new ExecutableProcess();
process.setId("process");
process.setName("Process");
List<Variable> variables = new ArrayList<Variable>();
Variable variable1 = new Variable();
variable1.setName("person");
variable1.setType(new ObjectDataType(Person.class));
variables.add(variable1);
Variable variable2 = new Variable();
variable2.setName("isAdult");
variable2.setType(new BooleanDataType());
variables.add(variable2);
process.getVariableScope().setVariables(variables);
StartNode startNode = new StartNode();
startNode.setName("Start");
startNode.setId(1);
RuleSetNode ruleSetNode = new RuleSetNode();
ruleSetNode.setName("RuleSetNode");
ruleSetNode.setId(2);
ruleSetNode.setRuleType(RuleSetNode.RuleType.decision(namespace, modelName, null));
ruleSetNode.setLanguage(RuleSetNode.DMN_LANG);
ruleSetNode.setDecisionModel(() -> dmnDecisionModel);
ruleSetNode.addInMapping("Person", "person");
ruleSetNode.addOutMapping("isAdult", "isAdult");
EndNode endNode = new EndNode();
endNode.setName("End");
endNode.setId(3);
connect(startNode, ruleSetNode);
connect(ruleSetNode, endNode);
process.addNode(startNode);
process.addNode(ruleSetNode);
process.addNode(endNode);
return process;
}
Aggregations