Search in sources :

Example 61 with DecisionDefinition

use of org.camunda.bpm.engine.repository.DecisionDefinition in project camunda-bpm-platform by camunda.

the class DecisionEvaluationUtil method evaluateDecision.

public static void evaluateDecision(AbstractVariableScope execution, BaseCallableElement callableElement, String resultVariable, DecisionResultMapper decisionResultMapper) throws Exception {
    DecisionDefinition decisionDefinition = resolveDecisionDefinition(callableElement, execution);
    DecisionInvocation invocation = createInvocation(decisionDefinition, execution);
    invoke(invocation);
    DmnDecisionResult result = invocation.getInvocationResult();
    if (result != null) {
        execution.setVariableLocalTransient(DECISION_RESULT_VARIABLE, result);
        if (resultVariable != null && decisionResultMapper != null) {
            Object mappedDecisionResult = decisionResultMapper.mapDecisionResult(result);
            execution.setVariable(resultVariable, mappedDecisionResult);
        }
    }
}
Also used : DmnDecisionResult(org.camunda.bpm.dmn.engine.DmnDecisionResult) DecisionInvocation(org.camunda.bpm.engine.impl.dmn.invocation.DecisionInvocation) DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition)

Example 62 with DecisionDefinition

use of org.camunda.bpm.engine.repository.DecisionDefinition in project camunda-bpm-platform by camunda.

the class RepositoryServiceTest method testGetDecisionDefinition.

@Deployment(resources = { "org/camunda/bpm/engine/test/repository/one.dmn" })
public void testGetDecisionDefinition() {
    DecisionDefinitionQuery query = repositoryService.createDecisionDefinitionQuery();
    DecisionDefinition decisionDefinition = query.singleResult();
    String decisionDefinitionId = decisionDefinition.getId();
    DecisionDefinition definition = repositoryService.getDecisionDefinition(decisionDefinitionId);
    assertNotNull(definition);
    assertEquals(decisionDefinitionId, definition.getId());
}
Also used : DecisionDefinitionQuery(org.camunda.bpm.engine.repository.DecisionDefinitionQuery) DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 63 with DecisionDefinition

use of org.camunda.bpm.engine.repository.DecisionDefinition in project camunda-bpm-platform by camunda.

the class RepositoryServiceTest method testGetDecisionModel.

@Deployment(resources = { "org/camunda/bpm/engine/test/repository/one.dmn" })
public void testGetDecisionModel() throws Exception {
    DecisionDefinitionQuery query = repositoryService.createDecisionDefinitionQuery();
    DecisionDefinition decisionDefinition = query.singleResult();
    String decisionDefinitionId = decisionDefinition.getId();
    InputStream decisionModel = repositoryService.getDecisionModel(decisionDefinitionId);
    assertNotNull(decisionModel);
    byte[] readInputStream = IoUtil.readInputStream(decisionModel, "decisionModel");
    String model = new String(readInputStream, "UTF-8");
    assertTrue(model.contains("<decision id=\"one\" name=\"One\">"));
    IoUtil.closeSilently(decisionModel);
}
Also used : DecisionDefinitionQuery(org.camunda.bpm.engine.repository.DecisionDefinitionQuery) InputStream(java.io.InputStream) DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 64 with DecisionDefinition

use of org.camunda.bpm.engine.repository.DecisionDefinition in project camunda-bpm-platform by camunda.

the class CleanableHistoricDecisionInstanceReportTest method prepareDecisionInstances.

protected void prepareDecisionInstances(String key, int daysInThePast, Integer historyTimeToLive, int instanceCount) {
    List<DecisionDefinition> decisionDefinitions = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(key).list();
    assertEquals(1, decisionDefinitions.size());
    repositoryService.updateDecisionDefinitionHistoryTimeToLive(decisionDefinitions.get(0).getId(), historyTimeToLive);
    Date oldCurrentTime = ClockUtil.getCurrentTime();
    ClockUtil.setCurrentTime(DateUtils.addDays(oldCurrentTime, daysInThePast));
    Map<String, Object> variables = Variables.createVariables().putValue("status", "silver").putValue("sum", 723);
    for (int i = 0; i < instanceCount; i++) {
        engineRule.getDecisionService().evaluateDecisionByKey(key).variables(variables).evaluate();
    }
    ClockUtil.setCurrentTime(oldCurrentTime);
}
Also used : DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition) Date(java.util.Date)

Example 65 with DecisionDefinition

use of org.camunda.bpm.engine.repository.DecisionDefinition in project camunda-bpm-platform by camunda.

the class HistoricDecisionInstanceTest method testDeleteHistoricDecisionInstances.

@Deployment(resources = { DECISION_PROCESS, DECISION_SINGLE_OUTPUT_DMN })
public void testDeleteHistoricDecisionInstances() {
    HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery().decisionDefinitionKey(DECISION_DEFINITION_KEY);
    startProcessInstanceAndEvaluateDecision();
    assertThat(query.count(), is(1L));
    DecisionDefinition decisionDefinition = repositoryService.createDecisionDefinitionQuery().singleResult();
    historyService.deleteHistoricDecisionInstanceByDefinitionId(decisionDefinition.getId());
    assertThat(query.count(), is(0L));
}
Also used : HistoricDecisionInstanceQuery(org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery) DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

DecisionDefinition (org.camunda.bpm.engine.repository.DecisionDefinition)68 Test (org.junit.Test)21 Deployment (org.camunda.bpm.engine.test.Deployment)18 DecisionDefinitionQuery (org.camunda.bpm.engine.repository.DecisionDefinitionQuery)10 Date (java.util.Date)6 DmnDecisionTableResult (org.camunda.bpm.dmn.engine.DmnDecisionTableResult)5 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)5 InputStream (java.io.InputStream)4 ArrayList (java.util.ArrayList)4 DmnDecisionResult (org.camunda.bpm.dmn.engine.DmnDecisionResult)4 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)3 HistoricDecisionInstanceEntity (org.camunda.bpm.engine.impl.history.event.HistoricDecisionInstanceEntity)3 Response (com.jayway.restassured.response.Response)2 HistoricCaseInstance (org.camunda.bpm.engine.history.HistoricCaseInstance)2 HistoricDecisionInstanceQuery (org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery)2 HistoricDecisionOutputInstance (org.camunda.bpm.engine.history.HistoricDecisionOutputInstance)2 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)2 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)2 GetDeploymentResourceCmd (org.camunda.bpm.engine.impl.cmd.GetDeploymentResourceCmd)2 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)2