Search in sources :

Example 1 with DmnEvaluatedDecisionRule

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

Example 2 with DmnEvaluatedDecisionRule

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;
}
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 DmnEvaluatedDecisionRule

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

Example 4 with DmnEvaluatedDecisionRule

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);
}
Also used : DmnDecisionTableOutputImpl(org.camunda.bpm.dmn.engine.impl.DmnDecisionTableOutputImpl) ArrayList(java.util.ArrayList) DmnDecisionTableRuleImpl(org.camunda.bpm.dmn.engine.impl.DmnDecisionTableRuleImpl) DmnEvaluatedDecisionRule(org.camunda.bpm.dmn.engine.delegate.DmnEvaluatedDecisionRule)

Example 5 with DmnEvaluatedDecisionRule

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

Aggregations

DmnEvaluatedDecisionRule (org.camunda.bpm.dmn.engine.delegate.DmnEvaluatedDecisionRule)5 ArrayList (java.util.ArrayList)3 DmnEvaluatedOutput (org.camunda.bpm.dmn.engine.delegate.DmnEvaluatedOutput)2 DmnDecisionTableEvaluationEventImpl (org.camunda.bpm.dmn.engine.impl.delegate.DmnDecisionTableEvaluationEventImpl)2 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 DmnDecisionTableRuleImpl (org.camunda.bpm.dmn.engine.impl.DmnDecisionTableRuleImpl)1 HistoricDecisionOutputInstance (org.camunda.bpm.engine.history.HistoricDecisionOutputInstance)1 HistoricDecisionOutputInstanceEntity (org.camunda.bpm.engine.impl.history.event.HistoricDecisionOutputInstanceEntity)1