use of org.camunda.bpm.dmn.engine.delegate.DmnEvaluatedDecisionRule 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;
}
use of org.camunda.bpm.dmn.engine.delegate.DmnEvaluatedDecisionRule in project camunda-bpm-platform by camunda.
the class DefaultDmnHistoryEventProducer method createHistoricDecisionOutputInstances.
protected List<HistoricDecisionOutputInstance> createHistoricDecisionOutputInstances(DmnDecisionTableEvaluationEvent evaluationEvent) {
List<HistoricDecisionOutputInstance> outputInstances = new ArrayList<HistoricDecisionOutputInstance>();
List<DmnEvaluatedDecisionRule> matchingRules = evaluationEvent.getMatchingRules();
for (int index = 0; index < matchingRules.size(); index++) {
DmnEvaluatedDecisionRule rule = matchingRules.get(index);
String ruleId = rule.getId();
Integer ruleOrder = index + 1;
for (DmnEvaluatedOutput outputClause : rule.getOutputEntries().values()) {
HistoricDecisionOutputInstanceEntity outputInstance = new HistoricDecisionOutputInstanceEntity();
outputInstance.setClauseId(outputClause.getId());
outputInstance.setClauseName(outputClause.getName());
outputInstance.setRuleId(ruleId);
outputInstance.setRuleOrder(ruleOrder);
outputInstance.setVariableName(outputClause.getOutputName());
outputInstance.setValue(outputClause.getValue());
outputInstances.add(outputInstance);
}
}
return outputInstances;
}
use of org.camunda.bpm.dmn.engine.delegate.DmnEvaluatedDecisionRule in project camunda-engine-dmn by camunda.
the class DecisionTableEvaluationHandler method generateDecisionResult.
@Override
public DmnDecisionResult generateDecisionResult(DmnDecisionLogicEvaluationEvent event) {
DmnDecisionTableEvaluationEvent evaluationResult = (DmnDecisionTableEvaluationEvent) event;
List<DmnDecisionResultEntries> ruleResults = new ArrayList<DmnDecisionResultEntries>();
if (evaluationResult.getCollectResultName() != null || evaluationResult.getCollectResultValue() != null) {
DmnDecisionResultEntriesImpl ruleResult = new DmnDecisionResultEntriesImpl();
ruleResult.putValue(evaluationResult.getCollectResultName(), evaluationResult.getCollectResultValue());
ruleResults.add(ruleResult);
} else {
for (DmnEvaluatedDecisionRule evaluatedRule : evaluationResult.getMatchingRules()) {
DmnDecisionResultEntriesImpl ruleResult = new DmnDecisionResultEntriesImpl();
for (DmnEvaluatedOutput evaluatedOutput : evaluatedRule.getOutputEntries().values()) {
ruleResult.putValue(evaluatedOutput.getOutputName(), evaluatedOutput.getValue());
}
ruleResults.add(ruleResult);
}
}
return new DmnDecisionResultImpl(ruleResults);
}
use of org.camunda.bpm.dmn.engine.delegate.DmnEvaluatedDecisionRule in project camunda-engine-dmn by camunda.
the class DecisionTableEvaluationHandler method setEvaluationOutput.
protected void setEvaluationOutput(DmnDecisionTableImpl decisionTable, List<DmnDecisionTableRuleImpl> matchingRules, VariableContext variableContext, DmnDecisionTableEvaluationEventImpl evaluationResult) {
List<DmnDecisionTableOutputImpl> decisionTableOutputs = decisionTable.getOutputs();
List<DmnEvaluatedDecisionRule> evaluatedDecisionRules = new ArrayList<DmnEvaluatedDecisionRule>();
for (DmnDecisionTableRuleImpl matchingRule : matchingRules) {
DmnEvaluatedDecisionRule evaluatedRule = evaluateMatchingRule(decisionTableOutputs, matchingRule, variableContext);
evaluatedDecisionRules.add(evaluatedRule);
}
evaluationResult.setMatchingRules(evaluatedDecisionRules);
}
use of org.camunda.bpm.dmn.engine.delegate.DmnEvaluatedDecisionRule 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;
}
Aggregations