use of org.camunda.bpm.dmn.engine.impl.evaluation.DmnDecisionLogicEvaluationHandler in project camunda-engine-dmn by camunda.
the class DefaultDmnDecisionContext method evaluateDecision.
/**
* Evaluate a decision with the given {@link VariableContext}
*
* @param decision the decision to evaluate
* @param variableContext the available variable context
* @return the result of the decision evaluation
*/
public DmnDecisionResult evaluateDecision(DmnDecision decision, VariableContext variableContext) {
if (decision.getKey() == null) {
throw LOG.unableToFindAnyDecisionTable();
}
VariableMap variableMap = buildVariableMapFromVariableContext(variableContext);
List<DmnDecision> requiredDecisions = new ArrayList<DmnDecision>();
buildDecisionTree(decision, requiredDecisions);
List<DmnDecisionLogicEvaluationEvent> evaluatedEvents = new ArrayList<DmnDecisionLogicEvaluationEvent>();
DmnDecisionResult evaluatedResult = null;
for (DmnDecision evaluateDecision : requiredDecisions) {
DmnDecisionLogicEvaluationHandler handler = getDecisionEvaluationHandler(evaluateDecision);
DmnDecisionLogicEvaluationEvent evaluatedEvent = handler.evaluate(evaluateDecision, variableMap.asVariableContext());
evaluatedEvents.add(evaluatedEvent);
evaluatedResult = handler.generateDecisionResult(evaluatedEvent);
if (decision != evaluateDecision) {
addResultToVariableContext(evaluatedResult, variableMap, evaluateDecision);
}
}
generateDecisionEvaluationEvent(evaluatedEvents);
return evaluatedResult;
}
Aggregations