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