use of org.kie.dmn.core.ast.DecisionNodeImpl in project drools by kiegroup.
the class DMNModelImpl method getRequiredInputsForDecisionId.
@Override
public Set<InputDataNode> getRequiredInputsForDecisionId(String decisionId) {
DecisionNodeImpl decision = (DecisionNodeImpl) getDecisionById(decisionId);
Set<InputDataNode> inputs = new HashSet<>();
if (decision != null) {
collectRequiredInputs(decision.getDependencies().values(), inputs);
}
return inputs;
}
use of org.kie.dmn.core.ast.DecisionNodeImpl in project drools by kiegroup.
the class DMNModelImpl method getRequiredInputsForDecisionName.
@Override
public Set<InputDataNode> getRequiredInputsForDecisionName(String decisionName) {
DecisionNodeImpl decision = (DecisionNodeImpl) getDecisionByName(decisionName);
Set<InputDataNode> inputs = new HashSet<>();
if (decision != null) {
collectRequiredInputs(decision.getDependencies().values(), inputs);
}
return inputs;
}
use of org.kie.dmn.core.ast.DecisionNodeImpl in project drools by kiegroup.
the class DMNRuntimeTest method testSharedDependency.
@Test
public void testSharedDependency() {
DecisionNodeImpl a = new DecisionNodeImpl();
DecisionNodeImpl b = new DecisionNodeImpl();
DecisionNodeImpl c = new DecisionNodeImpl();
a.addDependency("c", c);
b.addDependency("c", c);
DMNModelImpl model = new DMNModelImpl();
model.addDecision(a);
model.addDecision(b);
model.addDecision(c);
DMNRuntime runtime = DMNRuntimeUtil.createRuntime(this.getClass());
DMNResult result = runtime.evaluateAll(model, DMNFactory.newContext());
assertFalse(result.hasErrors());
}
use of org.kie.dmn.core.ast.DecisionNodeImpl in project drools by kiegroup.
the class DMNRuntimeTest method testCycleDetection.
@Test
public void testCycleDetection() {
DecisionNodeImpl a = new DecisionNodeImpl();
DecisionNodeImpl b = new DecisionNodeImpl();
a.addDependency("b", b);
b.addDependency("a", b);
DMNModelImpl model = new DMNModelImpl();
model.addDecision(a);
model.addDecision(b);
DMNRuntime runtime = DMNRuntimeUtil.createRuntime(this.getClass());
DMNResult result = runtime.evaluateAll(model, DMNFactory.newContext());
assertTrue(result.hasErrors());
}
use of org.kie.dmn.core.ast.DecisionNodeImpl in project drools by kiegroup.
the class DMNCompilerImpl method detectCycles.
private void detectCycles(DMNModelImpl model) {
/*
Boolean.TRUE = node is either safe or already reported for having a cyclic dependency
Boolean.FALSE = node is being checked at the moment
*/
final Map<DecisionNodeImpl, Boolean> registry = new HashMap<>();
for (DecisionNode decision : model.getDecisions()) {
final DecisionNodeImpl decisionNode = (DecisionNodeImpl) decision;
detectCycles(decisionNode, registry, model);
}
}
Aggregations