protected internal virtual void SetEvaluationOutput(DmnDecisionTableImpl decisionTable, IList <DmnDecisionTableRuleImpl> matchingRules, IVariableContext variableContext, DmnDecisionTableEvaluationEventImpl evaluationResult) { var decisionTableOutputs = decisionTable.Outputs; IList <IDmnEvaluatedDecisionRule> evaluatedDecisionRules = new List <IDmnEvaluatedDecisionRule>(); foreach (var matchingRule in matchingRules) { var evaluatedRule = EvaluateMatchingRule(decisionTableOutputs, matchingRule, variableContext); evaluatedDecisionRules.Add(evaluatedRule); } evaluationResult.MatchingRules = evaluatedDecisionRules; }
public virtual IDmnDecisionLogicEvaluationEvent Evaluate(IDmnDecision decision, IVariableContext variableContext) { var evaluationResult = new DmnDecisionTableEvaluationEventImpl(); evaluationResult.DecisionTable = decision; var decisionTable = (DmnDecisionTableImpl)decision.DecisionLogic; evaluationResult.ExecutedDecisionElements = CalculateExecutedDecisionElements(decisionTable); EvaluateDecisionTable(decisionTable, variableContext, evaluationResult); // apply hit policy decisionTable.HitPolicyHandler.apply(evaluationResult); // notify listeners foreach (var evaluationListener in EvaluationListeners) { evaluationListener.Notify(evaluationResult); } return(evaluationResult); }
protected internal virtual void EvaluateDecisionTable(DmnDecisionTableImpl decisionTable, IVariableContext variableContext, DmnDecisionTableEvaluationEventImpl evaluationResult) { var inputSize = decisionTable.Inputs.Count; IList <DmnDecisionTableRuleImpl> matchingRules = new List <DmnDecisionTableRuleImpl>(decisionTable.Rules); for (var inputIdx = 0; inputIdx < inputSize; inputIdx++) { // evaluate input var input = decisionTable.Inputs[inputIdx]; var evaluatedInput = EvaluateInput(input, variableContext); evaluationResult.Inputs.Add(evaluatedInput); // compose local variable context out of global variable context enhanced with the value of the current input. var localVariableContext = GetLocalVariableContext(input, evaluatedInput, variableContext); // filter rules applicable with this input matchingRules = EvaluateInputForAvailableRules(inputIdx, input, matchingRules, localVariableContext); } SetEvaluationOutput(decisionTable, matchingRules, variableContext, evaluationResult); }