Search in sources :

Example 1 with DmnDecisionModel

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;
}
Also used : StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) Variable(io.automatiko.engine.workflow.base.core.context.variable.Variable) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) RuleSetNode(io.automatiko.engine.workflow.process.core.node.RuleSetNode) DmnDecisionModel(io.automatiko.engine.decision.dmn.DmnDecisionModel) ArrayList(java.util.ArrayList) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) ObjectDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType) BooleanDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.BooleanDataType) DMNRuntime(org.kie.dmn.api.core.DMNRuntime)

Aggregations

DmnDecisionModel (io.automatiko.engine.decision.dmn.DmnDecisionModel)1 Variable (io.automatiko.engine.workflow.base.core.context.variable.Variable)1 BooleanDataType (io.automatiko.engine.workflow.base.core.datatype.impl.type.BooleanDataType)1 ObjectDataType (io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType)1 EndNode (io.automatiko.engine.workflow.process.core.node.EndNode)1 RuleSetNode (io.automatiko.engine.workflow.process.core.node.RuleSetNode)1 StartNode (io.automatiko.engine.workflow.process.core.node.StartNode)1 ExecutableProcess (io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)1 ArrayList (java.util.ArrayList)1 DMNRuntime (org.kie.dmn.api.core.DMNRuntime)1