use of org.camunda.bpm.dmn.engine.delegate.DmnEvaluatedOutput in project camunda-engine-dmn by camunda.
the class DecisionTableEvaluationHandler method evaluateOutputEntries.
protected Map<String, DmnEvaluatedOutput> evaluateOutputEntries(List<DmnDecisionTableOutputImpl> decisionTableOutputs, DmnDecisionTableRuleImpl matchingRule, VariableContext variableContext) {
Map<String, DmnEvaluatedOutput> outputEntries = new LinkedHashMap<String, DmnEvaluatedOutput>();
for (int outputIdx = 0; outputIdx < decisionTableOutputs.size(); outputIdx++) {
// evaluate output entry, skip empty expressions
DmnExpressionImpl conclusion = matchingRule.getConclusions().get(outputIdx);
if (isNonEmptyExpression(conclusion)) {
Object value = evaluateOutputEntry(conclusion, variableContext);
// transform to output type
DmnDecisionTableOutputImpl decisionTableOutput = decisionTableOutputs.get(outputIdx);
TypedValue typedValue = decisionTableOutput.getTypeDefinition().transform(value);
// set on result
DmnEvaluatedOutputImpl evaluatedOutput = new DmnEvaluatedOutputImpl(decisionTableOutput, typedValue);
outputEntries.put(decisionTableOutput.getOutputName(), evaluatedOutput);
}
}
return outputEntries;
}
use of org.camunda.bpm.dmn.engine.delegate.DmnEvaluatedOutput 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.DmnEvaluatedOutput in project camunda-engine-dmn by camunda.
the class DecisionTableEvaluationHandler method evaluateMatchingRule.
protected DmnEvaluatedDecisionRule evaluateMatchingRule(List<DmnDecisionTableOutputImpl> decisionTableOutputs, DmnDecisionTableRuleImpl matchingRule, VariableContext variableContext) {
DmnEvaluatedDecisionRuleImpl evaluatedDecisionRule = new DmnEvaluatedDecisionRuleImpl(matchingRule);
Map<String, DmnEvaluatedOutput> outputEntries = evaluateOutputEntries(decisionTableOutputs, matchingRule, variableContext);
evaluatedDecisionRule.setOutputEntries(outputEntries);
return evaluatedDecisionRule;
}
use of org.camunda.bpm.dmn.engine.delegate.DmnEvaluatedOutput 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);
}
Aggregations