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);
}
}
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;
}
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;
}
Aggregations