Search in sources :

Example 1 with DmnEvaluatedInput

use of org.camunda.bpm.dmn.engine.delegate.DmnEvaluatedInput in project camunda-bpm-platform by camunda.

the class DefaultDmnHistoryEventProducer method createHistoricDecisionInputInstances.

protected List<HistoricDecisionInputInstance> createHistoricDecisionInputInstances(DmnDecisionTableEvaluationEvent evaluationEvent) {
    List<HistoricDecisionInputInstance> inputInstances = new ArrayList<HistoricDecisionInputInstance>();
    for (DmnEvaluatedInput inputClause : evaluationEvent.getInputs()) {
        HistoricDecisionInputInstanceEntity inputInstance = new HistoricDecisionInputInstanceEntity();
        inputInstance.setClauseId(inputClause.getId());
        inputInstance.setClauseName(inputClause.getName());
        TypedValue typedValue = Variables.untypedValue(inputClause.getValue());
        inputInstance.setValue(typedValue);
        inputInstances.add(inputInstance);
    }
    return inputInstances;
}
Also used : HistoricDecisionInputInstance(org.camunda.bpm.engine.history.HistoricDecisionInputInstance) HistoricDecisionInputInstanceEntity(org.camunda.bpm.engine.impl.history.event.HistoricDecisionInputInstanceEntity) DmnEvaluatedInput(org.camunda.bpm.dmn.engine.delegate.DmnEvaluatedInput) ArrayList(java.util.ArrayList) TypedValue(org.camunda.bpm.engine.variable.value.TypedValue)

Example 2 with DmnEvaluatedInput

use of org.camunda.bpm.dmn.engine.delegate.DmnEvaluatedInput in project camunda-engine-dmn by camunda.

the class DecisionTableEvaluationHandler method evaluateDecisionTable.

protected void evaluateDecisionTable(DmnDecisionTableImpl decisionTable, VariableContext variableContext, DmnDecisionTableEvaluationEventImpl evaluationResult) {
    int inputSize = decisionTable.getInputs().size();
    List<DmnDecisionTableRuleImpl> matchingRules = new ArrayList<DmnDecisionTableRuleImpl>(decisionTable.getRules());
    for (int inputIdx = 0; inputIdx < inputSize; inputIdx++) {
        // evaluate input
        DmnDecisionTableInputImpl input = decisionTable.getInputs().get(inputIdx);
        DmnEvaluatedInput evaluatedInput = evaluateInput(input, variableContext);
        evaluationResult.getInputs().add(evaluatedInput);
        // compose local variable context out of global variable context enhanced with the value of the current input.
        VariableContext localVariableContext = getLocalVariableContext(input, evaluatedInput, variableContext);
        // filter rules applicable with this input
        matchingRules = evaluateInputForAvailableRules(inputIdx, input, matchingRules, localVariableContext);
    }
    setEvaluationOutput(decisionTable, matchingRules, variableContext, evaluationResult);
}
Also used : DmnDecisionTableInputImpl(org.camunda.bpm.dmn.engine.impl.DmnDecisionTableInputImpl) DmnEvaluatedInput(org.camunda.bpm.dmn.engine.delegate.DmnEvaluatedInput) DmnDecisionTableRuleImpl(org.camunda.bpm.dmn.engine.impl.DmnDecisionTableRuleImpl) ArrayList(java.util.ArrayList) CompositeVariableContext(org.camunda.bpm.engine.variable.impl.context.CompositeVariableContext) VariableContext(org.camunda.bpm.engine.variable.context.VariableContext)

Aggregations

ArrayList (java.util.ArrayList)2 DmnEvaluatedInput (org.camunda.bpm.dmn.engine.delegate.DmnEvaluatedInput)2 DmnDecisionTableInputImpl (org.camunda.bpm.dmn.engine.impl.DmnDecisionTableInputImpl)1 DmnDecisionTableRuleImpl (org.camunda.bpm.dmn.engine.impl.DmnDecisionTableRuleImpl)1 HistoricDecisionInputInstance (org.camunda.bpm.engine.history.HistoricDecisionInputInstance)1 HistoricDecisionInputInstanceEntity (org.camunda.bpm.engine.impl.history.event.HistoricDecisionInputInstanceEntity)1 VariableContext (org.camunda.bpm.engine.variable.context.VariableContext)1 CompositeVariableContext (org.camunda.bpm.engine.variable.impl.context.CompositeVariableContext)1 TypedValue (org.camunda.bpm.engine.variable.value.TypedValue)1