Search in sources :

Example 1 with DmnDecisionLogicEvaluationEvent

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

the class DefaultDmnDecisionContext method generateDecisionEvaluationEvent.

protected void generateDecisionEvaluationEvent(List<DmnDecisionLogicEvaluationEvent> evaluatedEvents) {
    DmnDecisionLogicEvaluationEvent rootEvaluatedEvent = null;
    DmnDecisionEvaluationEventImpl decisionEvaluationEvent = new DmnDecisionEvaluationEventImpl();
    long executedDecisionElements = 0L;
    for (DmnDecisionLogicEvaluationEvent evaluatedEvent : evaluatedEvents) {
        executedDecisionElements += evaluatedEvent.getExecutedDecisionElements();
        rootEvaluatedEvent = evaluatedEvent;
    }
    decisionEvaluationEvent.setDecisionResult(rootEvaluatedEvent);
    decisionEvaluationEvent.setExecutedDecisionElements(executedDecisionElements);
    evaluatedEvents.remove(rootEvaluatedEvent);
    decisionEvaluationEvent.setRequiredDecisionResults(evaluatedEvents);
    for (DmnDecisionEvaluationListener evaluationListener : evaluationListeners) {
        evaluationListener.notify(decisionEvaluationEvent);
    }
}
Also used : DmnDecisionEvaluationListener(org.camunda.bpm.dmn.engine.delegate.DmnDecisionEvaluationListener) DmnDecisionLogicEvaluationEvent(org.camunda.bpm.dmn.engine.delegate.DmnDecisionLogicEvaluationEvent) DmnDecisionEvaluationEventImpl(org.camunda.bpm.dmn.engine.impl.delegate.DmnDecisionEvaluationEventImpl)

Example 2 with DmnDecisionLogicEvaluationEvent

use of org.camunda.bpm.dmn.engine.delegate.DmnDecisionLogicEvaluationEvent 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)

Example 3 with DmnDecisionLogicEvaluationEvent

use of org.camunda.bpm.dmn.engine.delegate.DmnDecisionLogicEvaluationEvent in project camunda-bpm-platform by camunda.

the class DefaultDmnHistoryEventProducer method createHistoryEvent.

protected HistoryEvent createHistoryEvent(DmnDecisionEvaluationEvent evaluationEvent, HistoricDecisionInstanceSupplier supplier) {
    HistoricDecisionEvaluationEvent event = newDecisionEvaluationEvent(evaluationEvent);
    HistoricDecisionInstanceEntity rootDecisionEvent = supplier.createHistoricDecisionInstance(evaluationEvent.getDecisionResult());
    event.setRootHistoricDecisionInstance(rootDecisionEvent);
    List<HistoricDecisionInstanceEntity> requiredDecisionEvents = new ArrayList<HistoricDecisionInstanceEntity>();
    for (DmnDecisionLogicEvaluationEvent requiredDecisionResult : evaluationEvent.getRequiredDecisionResults()) {
        HistoricDecisionInstanceEntity requiredDecisionEvent = supplier.createHistoricDecisionInstance(requiredDecisionResult);
        requiredDecisionEvents.add(requiredDecisionEvent);
    }
    event.setRequiredHistoricDecisionInstances(requiredDecisionEvents);
    return event;
}
Also used : HistoricDecisionEvaluationEvent(org.camunda.bpm.engine.impl.history.event.HistoricDecisionEvaluationEvent) DmnDecisionLogicEvaluationEvent(org.camunda.bpm.dmn.engine.delegate.DmnDecisionLogicEvaluationEvent) ArrayList(java.util.ArrayList) HistoricDecisionInstanceEntity(org.camunda.bpm.engine.impl.history.event.HistoricDecisionInstanceEntity)

Aggregations

DmnDecisionLogicEvaluationEvent (org.camunda.bpm.dmn.engine.delegate.DmnDecisionLogicEvaluationEvent)3 ArrayList (java.util.ArrayList)2 DmnDecision (org.camunda.bpm.dmn.engine.DmnDecision)1 DmnDecisionResult (org.camunda.bpm.dmn.engine.DmnDecisionResult)1 DmnDecisionEvaluationListener (org.camunda.bpm.dmn.engine.delegate.DmnDecisionEvaluationListener)1 DmnDecisionEvaluationEventImpl (org.camunda.bpm.dmn.engine.impl.delegate.DmnDecisionEvaluationEventImpl)1 DmnDecisionLogicEvaluationHandler (org.camunda.bpm.dmn.engine.impl.evaluation.DmnDecisionLogicEvaluationHandler)1 HistoricDecisionEvaluationEvent (org.camunda.bpm.engine.impl.history.event.HistoricDecisionEvaluationEvent)1 HistoricDecisionInstanceEntity (org.camunda.bpm.engine.impl.history.event.HistoricDecisionInstanceEntity)1 VariableMap (org.camunda.bpm.engine.variable.VariableMap)1