Search in sources :

Example 6 with DecisionNodeImpl

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;
}
Also used : InputDataNode(org.kie.dmn.api.core.ast.InputDataNode) DecisionNodeImpl(org.kie.dmn.core.ast.DecisionNodeImpl) HashSet(java.util.HashSet)

Example 7 with DecisionNodeImpl

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;
}
Also used : InputDataNode(org.kie.dmn.api.core.ast.InputDataNode) DecisionNodeImpl(org.kie.dmn.core.ast.DecisionNodeImpl) HashSet(java.util.HashSet)

Example 8 with DecisionNodeImpl

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());
}
Also used : DMNResult(org.kie.dmn.api.core.DMNResult) DMNModelImpl(org.kie.dmn.core.impl.DMNModelImpl) DecisionNodeImpl(org.kie.dmn.core.ast.DecisionNodeImpl) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) Test(org.junit.Test)

Example 9 with DecisionNodeImpl

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());
}
Also used : DMNResult(org.kie.dmn.api.core.DMNResult) DMNModelImpl(org.kie.dmn.core.impl.DMNModelImpl) DecisionNodeImpl(org.kie.dmn.core.ast.DecisionNodeImpl) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) Test(org.junit.Test)

Example 10 with DecisionNodeImpl

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);
    }
}
Also used : HashMap(java.util.HashMap) DecisionNode(org.kie.dmn.api.core.ast.DecisionNode) DecisionNodeImpl(org.kie.dmn.core.ast.DecisionNodeImpl)

Aggregations

DecisionNodeImpl (org.kie.dmn.core.ast.DecisionNodeImpl)12 DMNModelImpl (org.kie.dmn.core.impl.DMNModelImpl)5 Test (org.junit.Test)4 DMNResult (org.kie.dmn.api.core.DMNResult)4 DMNRuntime (org.kie.dmn.api.core.DMNRuntime)4 DecisionNode (org.kie.dmn.api.core.ast.DecisionNode)4 BusinessKnowledgeModelNode (org.kie.dmn.api.core.ast.BusinessKnowledgeModelNode)3 DMNNode (org.kie.dmn.api.core.ast.DMNNode)3 InputDataNode (org.kie.dmn.api.core.ast.InputDataNode)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 DMNType (org.kie.dmn.api.core.DMNType)2 DRGElement (org.kie.dmn.model.v1_1.DRGElement)2 Decision (org.kie.dmn.model.v1_1.Decision)2 Collection (java.util.Collection)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Optional (java.util.Optional)1 DMNDecisionResult (org.kie.dmn.api.core.DMNDecisionResult)1 DMNMessage (org.kie.dmn.api.core.DMNMessage)1