Search in sources :

Example 1 with DmnDecisionLogicEvaluationHandler

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;
}
Also used : DmnDecisionResult(org.camunda.bpm.dmn.engine.DmnDecisionResult) DmnDecisionLogicEvaluationHandler(org.camunda.bpm.dmn.engine.impl.evaluation.DmnDecisionLogicEvaluationHandler) VariableMap(org.camunda.bpm.engine.variable.VariableMap) DmnDecisionLogicEvaluationEvent(org.camunda.bpm.dmn.engine.delegate.DmnDecisionLogicEvaluationEvent) ArrayList(java.util.ArrayList) DmnDecision(org.camunda.bpm.dmn.engine.DmnDecision)

Aggregations

ArrayList (java.util.ArrayList)1 DmnDecision (org.camunda.bpm.dmn.engine.DmnDecision)1 DmnDecisionResult (org.camunda.bpm.dmn.engine.DmnDecisionResult)1 DmnDecisionLogicEvaluationEvent (org.camunda.bpm.dmn.engine.delegate.DmnDecisionLogicEvaluationEvent)1 DmnDecisionLogicEvaluationHandler (org.camunda.bpm.dmn.engine.impl.evaluation.DmnDecisionLogicEvaluationHandler)1 VariableMap (org.camunda.bpm.engine.variable.VariableMap)1