Search in sources :

Example 6 with HistoricDecisionOutputInstance

use of org.camunda.bpm.engine.history.HistoricDecisionOutputInstance in project camunda-bpm-platform by camunda.

the class HistoricDecisionInstanceTest method testCompoundDecisionOutputInstances.

@Deployment(resources = { DECISION_PROCESS, DECISION_COMPOUND_OUTPUT_DMN })
public void testCompoundDecisionOutputInstances() {
    startProcessInstanceAndEvaluateDecision();
    HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery().includeOutputs().singleResult();
    List<HistoricDecisionOutputInstance> outputs = historicDecisionInstance.getOutputs();
    assertThat(outputs.size(), is(2));
    HistoricDecisionOutputInstance firstOutput = outputs.get(0);
    assertThat(firstOutput.getClauseId(), is("out1"));
    assertThat(firstOutput.getRuleId(), is("rule1"));
    assertThat(firstOutput.getRuleOrder(), is(1));
    assertThat(firstOutput.getVariableName(), is("result1"));
    assertThat(firstOutput.getValue(), is((Object) "okay"));
    HistoricDecisionOutputInstance secondOutput = outputs.get(1);
    assertThat(secondOutput.getClauseId(), is("out2"));
    assertThat(secondOutput.getRuleId(), is("rule1"));
    assertThat(secondOutput.getRuleOrder(), is(1));
    assertThat(secondOutput.getVariableName(), is("result2"));
    assertThat(secondOutput.getValue(), is((Object) "not okay"));
}
Also used : HistoricDecisionInstance(org.camunda.bpm.engine.history.HistoricDecisionInstance) HistoricDecisionOutputInstance(org.camunda.bpm.engine.history.HistoricDecisionOutputInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 7 with HistoricDecisionOutputInstance

use of org.camunda.bpm.engine.history.HistoricDecisionOutputInstance in project camunda-bpm-platform by camunda.

the class HistoricDecisionInstanceTest method testDecisionInstancePropertiesOfDecisionLiteralExpression.

@Deployment(resources = DECISION_LITERAL_EXPRESSION_DMN)
public void testDecisionInstancePropertiesOfDecisionLiteralExpression() {
    DecisionDefinition decisionDefinition = repositoryService.createDecisionDefinitionQuery().singleResult();
    decisionService.evaluateDecisionByKey("decision").variables(Variables.createVariables().putValue("sum", 2205)).evaluate();
    HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery().includeInputs().includeOutputs();
    assertThat(query.count(), is(1L));
    HistoricDecisionInstance historicDecisionInstance = query.singleResult();
    assertThat(historicDecisionInstance.getDecisionDefinitionId(), is(decisionDefinition.getId()));
    assertThat(historicDecisionInstance.getDecisionDefinitionKey(), is("decision"));
    assertThat(historicDecisionInstance.getDecisionDefinitionName(), is("Decision with Literal Expression"));
    assertThat(historicDecisionInstance.getEvaluationTime(), is(notNullValue()));
    assertThat(historicDecisionInstance.getInputs().size(), is(0));
    List<HistoricDecisionOutputInstance> outputs = historicDecisionInstance.getOutputs();
    assertThat(outputs.size(), is(1));
    HistoricDecisionOutputInstance output = outputs.get(0);
    assertThat(output.getVariableName(), is("result"));
    assertThat(output.getTypeName(), is("string"));
    assertThat((String) output.getValue(), is("ok"));
    assertThat(output.getClauseId(), is(nullValue()));
    assertThat(output.getClauseName(), is(nullValue()));
    assertThat(output.getRuleId(), is(nullValue()));
    assertThat(output.getRuleOrder(), is(nullValue()));
}
Also used : HistoricDecisionInstance(org.camunda.bpm.engine.history.HistoricDecisionInstance) HistoricDecisionInstanceQuery(org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery) HistoricDecisionOutputInstance(org.camunda.bpm.engine.history.HistoricDecisionOutputInstance) DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 8 with HistoricDecisionOutputInstance

use of org.camunda.bpm.engine.history.HistoricDecisionOutputInstance in project camunda-bpm-platform by camunda.

the class MockProvider method createMockHistoricDecisionInstanceWithInputsAndOutputs.

public static HistoricDecisionInstance createMockHistoricDecisionInstanceWithInputsAndOutputs() {
    List<HistoricDecisionInputInstance> inputs = createMockHistoricDecisionInputInstances();
    List<HistoricDecisionOutputInstance> outputs = createMockHistoricDecisionOutputInstances();
    HistoricDecisionInstance mock = createMockHistoricDecisionInstanceBase();
    when(mock.getInputs()).thenReturn(inputs);
    when(mock.getOutputs()).thenReturn(outputs);
    return mock;
}
Also used : HistoricDecisionInputInstance(org.camunda.bpm.engine.history.HistoricDecisionInputInstance) HistoricDecisionInstance(org.camunda.bpm.engine.history.HistoricDecisionInstance) HistoricDecisionOutputInstance(org.camunda.bpm.engine.history.HistoricDecisionOutputInstance)

Example 9 with HistoricDecisionOutputInstance

use of org.camunda.bpm.engine.history.HistoricDecisionOutputInstance in project camunda-bpm-platform by camunda.

the class DefaultDmnHistoryEventProducer method initDecisionInstanceEvent.

protected void initDecisionInstanceEvent(HistoricDecisionInstanceEntity event, DmnDecisionLogicEvaluationEvent evaluationEvent, HistoryEventTypes eventType) {
    event.setEventType(eventType.getEventName());
    DecisionDefinition decision = (DecisionDefinition) evaluationEvent.getDecision();
    event.setDecisionDefinitionId(decision.getId());
    event.setDecisionDefinitionKey(decision.getKey());
    event.setDecisionDefinitionName(decision.getName());
    if (decision.getDecisionRequirementsDefinitionId() != null) {
        event.setDecisionRequirementsDefinitionId(decision.getDecisionRequirementsDefinitionId());
        event.setDecisionRequirementsDefinitionKey(decision.getDecisionRequirementsDefinitionKey());
    }
    if (evaluationEvent instanceof DmnDecisionTableEvaluationEvent) {
        initDecisionInstanceEventForDecisionTable(event, (DmnDecisionTableEvaluationEvent) evaluationEvent);
    } else if (evaluationEvent instanceof DmnDecisionLiteralExpressionEvaluationEvent) {
        initDecisionInstanceEventForDecisionLiteralExpression(event, (DmnDecisionLiteralExpressionEvaluationEvent) evaluationEvent);
    } else {
        event.setInputs(Collections.<HistoricDecisionInputInstance>emptyList());
        event.setOutputs(Collections.<HistoricDecisionOutputInstance>emptyList());
    }
}
Also used : HistoricDecisionInputInstance(org.camunda.bpm.engine.history.HistoricDecisionInputInstance) DmnDecisionLiteralExpressionEvaluationEvent(org.camunda.bpm.dmn.engine.delegate.DmnDecisionLiteralExpressionEvaluationEvent) DmnDecisionTableEvaluationEvent(org.camunda.bpm.dmn.engine.delegate.DmnDecisionTableEvaluationEvent) HistoricDecisionOutputInstance(org.camunda.bpm.engine.history.HistoricDecisionOutputInstance) DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition)

Example 10 with HistoricDecisionOutputInstance

use of org.camunda.bpm.engine.history.HistoricDecisionOutputInstance 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)

Aggregations

HistoricDecisionOutputInstance (org.camunda.bpm.engine.history.HistoricDecisionOutputInstance)14 HistoricDecisionInstance (org.camunda.bpm.engine.history.HistoricDecisionInstance)9 Deployment (org.camunda.bpm.engine.test.Deployment)6 HistoricDecisionInputInstance (org.camunda.bpm.engine.history.HistoricDecisionInputInstance)4 ArrayList (java.util.ArrayList)2 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)2 HistoricDecisionOutputInstanceEntity (org.camunda.bpm.engine.impl.history.event.HistoricDecisionOutputInstanceEntity)2 DecisionDefinition (org.camunda.bpm.engine.repository.DecisionDefinition)2 DmnDecisionLiteralExpressionEvaluationEvent (org.camunda.bpm.dmn.engine.delegate.DmnDecisionLiteralExpressionEvaluationEvent)1 DmnDecisionTableEvaluationEvent (org.camunda.bpm.dmn.engine.delegate.DmnDecisionTableEvaluationEvent)1 DmnEvaluatedDecisionRule (org.camunda.bpm.dmn.engine.delegate.DmnEvaluatedDecisionRule)1 DmnEvaluatedOutput (org.camunda.bpm.dmn.engine.delegate.DmnEvaluatedOutput)1 HistoricDecisionInstanceQuery (org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery)1 VariableMap (org.camunda.bpm.engine.variable.VariableMap)1 ObjectValue (org.camunda.bpm.engine.variable.value.ObjectValue)1 Test (org.junit.Test)1