Search in sources :

Example 6 with InputDataNode

use of org.kie.dmn.api.core.ast.InputDataNode in project drools by kiegroup.

the class DMNInputRuntimeTest method testGetRequiredInputsByName.

@Test
public void testGetRequiredInputsByName() {
    final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0001-input-data-string.dmn", this.getClass());
    final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/drools/kie-dmn", "_0001-input-data-string");
    assertThat(dmnModel, notNullValue());
    Set<InputDataNode> inputs = dmnModel.getRequiredInputsForDecisionName("Greeting Message");
    assertThat(inputs.size(), is(1));
    assertThat(inputs.iterator().next().getName(), is("Full Name"));
    inputs = dmnModel.getRequiredInputsForDecisionName("nonExistantDecisionName");
    assertThat(inputs.size(), is(0));
}
Also used : InputDataNode(org.kie.dmn.api.core.ast.InputDataNode) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) DMNModel(org.kie.dmn.api.core.DMNModel) Test(org.junit.Test)

Example 7 with InputDataNode

use of org.kie.dmn.api.core.ast.InputDataNode in project drools by kiegroup.

the class DMNCompilerImpl method linkRequirements.

public void linkRequirements(DMNModelImpl model, DMNBaseNode node) {
    for (InformationRequirement ir : node.getInformationRequirement()) {
        if (ir.getRequiredInput() != null) {
            String id = getId(ir.getRequiredInput());
            InputDataNode input = model.getInputById(id);
            if (input != null) {
                node.addDependency(input.getName(), input);
            } else {
                MsgUtil.reportMessage(logger, DMNMessage.Severity.ERROR, ir.getRequiredInput(), model, null, null, Msg.REQ_INPUT_NOT_FOUND_FOR_NODE, id, node.getName());
            }
        } else if (ir.getRequiredDecision() != null) {
            String id = getId(ir.getRequiredDecision());
            DecisionNode dn = model.getDecisionById(id);
            if (dn != null) {
                node.addDependency(dn.getName(), dn);
            } else {
                MsgUtil.reportMessage(logger, DMNMessage.Severity.ERROR, ir.getRequiredDecision(), model, null, null, Msg.REQ_DECISION_NOT_FOUND_FOR_NODE, id, node.getName());
            }
        }
    }
    for (KnowledgeRequirement kr : node.getKnowledgeRequirement()) {
        if (kr.getRequiredKnowledge() != null) {
            String id = getId(kr.getRequiredKnowledge());
            BusinessKnowledgeModelNode bkmn = model.getBusinessKnowledgeModelById(id);
            if (bkmn != null) {
                node.addDependency(bkmn.getName(), bkmn);
            } else {
                MsgUtil.reportMessage(logger, DMNMessage.Severity.ERROR, kr.getRequiredKnowledge(), model, null, null, Msg.REQ_BKM_NOT_FOUND_FOR_NODE, id, node.getName());
            }
        }
    }
}
Also used : KnowledgeRequirement(org.kie.dmn.model.v1_1.KnowledgeRequirement) InformationRequirement(org.kie.dmn.model.v1_1.InformationRequirement) InputDataNode(org.kie.dmn.api.core.ast.InputDataNode) DecisionNode(org.kie.dmn.api.core.ast.DecisionNode) BusinessKnowledgeModelNode(org.kie.dmn.api.core.ast.BusinessKnowledgeModelNode)

Example 8 with InputDataNode

use of org.kie.dmn.api.core.ast.InputDataNode in project drools by kiegroup.

the class DMNInputRuntimeTest method testGetRequiredInputsById.

@Test
public void testGetRequiredInputsById() {
    final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0001-input-data-string.dmn", this.getClass());
    final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/drools/kie-dmn", "_0001-input-data-string");
    assertThat(dmnModel, notNullValue());
    Set<InputDataNode> inputs = dmnModel.getRequiredInputsForDecisionId("d_GreetingMessage");
    assertThat(inputs.size(), is(1));
    assertThat(inputs.iterator().next().getName(), is("Full Name"));
    inputs = dmnModel.getRequiredInputsForDecisionId("nonExistantId");
    assertThat(inputs.size(), is(0));
}
Also used : InputDataNode(org.kie.dmn.api.core.ast.InputDataNode) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) DMNModel(org.kie.dmn.api.core.DMNModel) Test(org.junit.Test)

Aggregations

InputDataNode (org.kie.dmn.api.core.ast.InputDataNode)8 Test (org.junit.Test)3 DMNModel (org.kie.dmn.api.core.DMNModel)3 DMNRuntime (org.kie.dmn.api.core.DMNRuntime)3 DecisionNodeImpl (org.kie.dmn.core.ast.DecisionNodeImpl)3 HashSet (java.util.HashSet)2 BusinessKnowledgeModelNode (org.kie.dmn.api.core.ast.BusinessKnowledgeModelNode)2 DecisionNode (org.kie.dmn.api.core.ast.DecisionNode)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Optional (java.util.Optional)1 DMNType (org.kie.dmn.api.core.DMNType)1 DMNNode (org.kie.dmn.api.core.ast.DMNNode)1 DMNExpressionEvaluator (org.kie.dmn.core.api.DMNExpressionEvaluator)1 InputDataNodeImpl (org.kie.dmn.core.ast.InputDataNodeImpl)1 CompositeTypeImpl (org.kie.dmn.core.impl.CompositeTypeImpl)1 DMNModelImpl (org.kie.dmn.core.impl.DMNModelImpl)1 Msg (org.kie.dmn.core.util.Msg)1 DRGElement (org.kie.dmn.model.v1_1.DRGElement)1