Search in sources :

Example 1 with DmnDecisionTableEvaluationEventImpl

use of org.camunda.bpm.dmn.engine.impl.delegate.DmnDecisionTableEvaluationEventImpl in project camunda-engine-dmn by camunda.

the class DecisionTableEvaluationHandler method evaluate.

@Override
public DmnDecisionLogicEvaluationEvent evaluate(DmnDecision decision, VariableContext variableContext) {
    DmnDecisionTableEvaluationEventImpl evaluationResult = new DmnDecisionTableEvaluationEventImpl();
    evaluationResult.setDecisionTable(decision);
    DmnDecisionTableImpl decisionTable = (DmnDecisionTableImpl) decision.getDecisionLogic();
    evaluationResult.setExecutedDecisionElements(calculateExecutedDecisionElements(decisionTable));
    evaluateDecisionTable(decisionTable, variableContext, evaluationResult);
    // apply hit policy
    decisionTable.getHitPolicyHandler().apply(evaluationResult);
    // notify listeners
    for (DmnDecisionTableEvaluationListener evaluationListener : evaluationListeners) {
        evaluationListener.notify(evaluationResult);
    }
    return evaluationResult;
}
Also used : DmnDecisionTableImpl(org.camunda.bpm.dmn.engine.impl.DmnDecisionTableImpl) DmnDecisionTableEvaluationEventImpl(org.camunda.bpm.dmn.engine.impl.delegate.DmnDecisionTableEvaluationEventImpl) DmnDecisionTableEvaluationListener(org.camunda.bpm.dmn.engine.delegate.DmnDecisionTableEvaluationListener)

Example 2 with DmnDecisionTableEvaluationEventImpl

use of org.camunda.bpm.dmn.engine.impl.delegate.DmnDecisionTableEvaluationEventImpl in project camunda-engine-dmn by camunda.

the class AbstractCollectNumberHitPolicyHandler method apply.

public DmnDecisionTableEvaluationEvent apply(DmnDecisionTableEvaluationEvent decisionTableEvaluationEvent) {
    String resultName = getResultName(decisionTableEvaluationEvent);
    TypedValue resultValue = getResultValue(decisionTableEvaluationEvent);
    DmnDecisionTableEvaluationEventImpl evaluationEvent = (DmnDecisionTableEvaluationEventImpl) decisionTableEvaluationEvent;
    evaluationEvent.setCollectResultName(resultName);
    evaluationEvent.setCollectResultValue(resultValue);
    return evaluationEvent;
}
Also used : DmnDecisionTableEvaluationEventImpl(org.camunda.bpm.dmn.engine.impl.delegate.DmnDecisionTableEvaluationEventImpl) TypedValue(org.camunda.bpm.engine.variable.value.TypedValue)

Example 3 with DmnDecisionTableEvaluationEventImpl

use of org.camunda.bpm.dmn.engine.impl.delegate.DmnDecisionTableEvaluationEventImpl in project camunda-engine-dmn by camunda.

the class AnyHitPolicyHandler method apply.

public DmnDecisionTableEvaluationEvent apply(DmnDecisionTableEvaluationEvent decisionTableEvaluationEvent) {
    List<DmnEvaluatedDecisionRule> matchingRules = decisionTableEvaluationEvent.getMatchingRules();
    if (!matchingRules.isEmpty()) {
        if (allOutputsAreEqual(matchingRules)) {
            DmnEvaluatedDecisionRule firstMatchingRule = matchingRules.get(0);
            ((DmnDecisionTableEvaluationEventImpl) decisionTableEvaluationEvent).setMatchingRules(Collections.singletonList(firstMatchingRule));
        } else {
            throw LOG.anyHitPolicyRequiresThatAllOutputsAreEqual(matchingRules);
        }
    }
    return decisionTableEvaluationEvent;
}
Also used : DmnDecisionTableEvaluationEventImpl(org.camunda.bpm.dmn.engine.impl.delegate.DmnDecisionTableEvaluationEventImpl) DmnEvaluatedDecisionRule(org.camunda.bpm.dmn.engine.delegate.DmnEvaluatedDecisionRule)

Example 4 with DmnDecisionTableEvaluationEventImpl

use of org.camunda.bpm.dmn.engine.impl.delegate.DmnDecisionTableEvaluationEventImpl in project camunda-engine-dmn by camunda.

the class FirstHitPolicyHandler method apply.

public DmnDecisionTableEvaluationEvent apply(DmnDecisionTableEvaluationEvent decisionTableEvaluationEvent) {
    if (!decisionTableEvaluationEvent.getMatchingRules().isEmpty()) {
        DmnEvaluatedDecisionRule firstMatchedRule = decisionTableEvaluationEvent.getMatchingRules().get(0);
        ((DmnDecisionTableEvaluationEventImpl) decisionTableEvaluationEvent).setMatchingRules(Collections.singletonList(firstMatchedRule));
    }
    return decisionTableEvaluationEvent;
}
Also used : DmnDecisionTableEvaluationEventImpl(org.camunda.bpm.dmn.engine.impl.delegate.DmnDecisionTableEvaluationEventImpl) DmnEvaluatedDecisionRule(org.camunda.bpm.dmn.engine.delegate.DmnEvaluatedDecisionRule)

Aggregations

DmnDecisionTableEvaluationEventImpl (org.camunda.bpm.dmn.engine.impl.delegate.DmnDecisionTableEvaluationEventImpl)4 DmnEvaluatedDecisionRule (org.camunda.bpm.dmn.engine.delegate.DmnEvaluatedDecisionRule)2 DmnDecisionTableEvaluationListener (org.camunda.bpm.dmn.engine.delegate.DmnDecisionTableEvaluationListener)1 DmnDecisionTableImpl (org.camunda.bpm.dmn.engine.impl.DmnDecisionTableImpl)1 TypedValue (org.camunda.bpm.engine.variable.value.TypedValue)1