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