Search in sources :

Example 1 with DmnEvaluatedOutput

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;
}
Also used : DmnDecisionTableOutputImpl(org.camunda.bpm.dmn.engine.impl.DmnDecisionTableOutputImpl) DmnExpressionImpl(org.camunda.bpm.dmn.engine.impl.DmnExpressionImpl) DmnEvaluatedOutput(org.camunda.bpm.dmn.engine.delegate.DmnEvaluatedOutput) DmnEvaluatedOutputImpl(org.camunda.bpm.dmn.engine.impl.delegate.DmnEvaluatedOutputImpl) LinkedHashMap(java.util.LinkedHashMap) TypedValue(org.camunda.bpm.engine.variable.value.TypedValue)

Example 2 with DmnEvaluatedOutput

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;
}
Also used : HistoricDecisionOutputInstanceEntity(org.camunda.bpm.engine.impl.history.event.HistoricDecisionOutputInstanceEntity) ArrayList(java.util.ArrayList) DmnEvaluatedOutput(org.camunda.bpm.dmn.engine.delegate.DmnEvaluatedOutput) DmnEvaluatedDecisionRule(org.camunda.bpm.dmn.engine.delegate.DmnEvaluatedDecisionRule) HistoricDecisionOutputInstance(org.camunda.bpm.engine.history.HistoricDecisionOutputInstance)

Example 3 with DmnEvaluatedOutput

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;
}
Also used : DmnEvaluatedDecisionRuleImpl(org.camunda.bpm.dmn.engine.impl.delegate.DmnEvaluatedDecisionRuleImpl) DmnEvaluatedOutput(org.camunda.bpm.dmn.engine.delegate.DmnEvaluatedOutput)

Example 4 with DmnEvaluatedOutput

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);
}
Also used : DmnDecisionResultEntries(org.camunda.bpm.dmn.engine.DmnDecisionResultEntries) DmnDecisionResultImpl(org.camunda.bpm.dmn.engine.impl.DmnDecisionResultImpl) ArrayList(java.util.ArrayList) DmnEvaluatedOutput(org.camunda.bpm.dmn.engine.delegate.DmnEvaluatedOutput) DmnEvaluatedDecisionRule(org.camunda.bpm.dmn.engine.delegate.DmnEvaluatedDecisionRule) DmnDecisionTableEvaluationEvent(org.camunda.bpm.dmn.engine.delegate.DmnDecisionTableEvaluationEvent) DmnDecisionResultEntriesImpl(org.camunda.bpm.dmn.engine.impl.DmnDecisionResultEntriesImpl)

Aggregations

DmnEvaluatedOutput (org.camunda.bpm.dmn.engine.delegate.DmnEvaluatedOutput)4 ArrayList (java.util.ArrayList)2 DmnEvaluatedDecisionRule (org.camunda.bpm.dmn.engine.delegate.DmnEvaluatedDecisionRule)2 LinkedHashMap (java.util.LinkedHashMap)1 DmnDecisionResultEntries (org.camunda.bpm.dmn.engine.DmnDecisionResultEntries)1 DmnDecisionTableEvaluationEvent (org.camunda.bpm.dmn.engine.delegate.DmnDecisionTableEvaluationEvent)1 DmnDecisionResultEntriesImpl (org.camunda.bpm.dmn.engine.impl.DmnDecisionResultEntriesImpl)1 DmnDecisionResultImpl (org.camunda.bpm.dmn.engine.impl.DmnDecisionResultImpl)1 DmnDecisionTableOutputImpl (org.camunda.bpm.dmn.engine.impl.DmnDecisionTableOutputImpl)1 DmnExpressionImpl (org.camunda.bpm.dmn.engine.impl.DmnExpressionImpl)1 DmnEvaluatedDecisionRuleImpl (org.camunda.bpm.dmn.engine.impl.delegate.DmnEvaluatedDecisionRuleImpl)1 DmnEvaluatedOutputImpl (org.camunda.bpm.dmn.engine.impl.delegate.DmnEvaluatedOutputImpl)1 HistoricDecisionOutputInstance (org.camunda.bpm.engine.history.HistoricDecisionOutputInstance)1 HistoricDecisionOutputInstanceEntity (org.camunda.bpm.engine.impl.history.event.HistoricDecisionOutputInstanceEntity)1 TypedValue (org.camunda.bpm.engine.variable.value.TypedValue)1