use of org.camunda.bpm.engine.repository.DecisionDefinition in project camunda-bpm-platform by camunda.
the class DecisionDefinitionRestServiceQueryTest method testDecisionDefinitionTenantIdIncludeDefinitionsWithoutTenantid.
@Test
public void testDecisionDefinitionTenantIdIncludeDefinitionsWithoutTenantid() {
List<DecisionDefinition> decisionDefinitions = Arrays.asList(MockProvider.mockDecisionDefinition().tenantId(null).build(), MockProvider.mockDecisionDefinition().tenantId(MockProvider.EXAMPLE_TENANT_ID).build());
mockedQuery = createMockDecisionDefinitionQuery(decisionDefinitions);
Response response = given().queryParam("tenantIdIn", MockProvider.EXAMPLE_TENANT_ID).queryParam("includeDecisionDefinitionsWithoutTenantId", true).then().expect().statusCode(Status.OK.getStatusCode()).when().get(DECISION_DEFINITION_QUERY_URL);
verify(mockedQuery).tenantIdIn(MockProvider.EXAMPLE_TENANT_ID);
verify(mockedQuery).includeDecisionDefinitionsWithoutTenantId();
verify(mockedQuery).list();
String content = response.asString();
List<String> definitions = from(content).getList("");
assertThat(definitions).hasSize(2);
String returnedTenantId1 = from(content).getString("[0].tenantId");
String returnedTenantId2 = from(content).getString("[1].tenantId");
assertThat(returnedTenantId1).isEqualTo(null);
assertThat(returnedTenantId2).isEqualTo(MockProvider.EXAMPLE_TENANT_ID);
}
use of org.camunda.bpm.engine.repository.DecisionDefinition in project camunda-bpm-platform by camunda.
the class DecisionDefinitionResourceImpl method getDecisionDefinition.
@Override
public DecisionDefinitionDto getDecisionDefinition() {
RepositoryService repositoryService = engine.getRepositoryService();
DecisionDefinition definition = null;
try {
definition = repositoryService.getDecisionDefinition(decisionDefinitionId);
} catch (NotFoundException e) {
throw new InvalidRequestException(Status.NOT_FOUND, e, e.getMessage());
} catch (NotValidException e) {
throw new InvalidRequestException(Status.BAD_REQUEST, e, e.getMessage());
} catch (ProcessEngineException e) {
throw new RestException(Status.INTERNAL_SERVER_ERROR, e);
}
return DecisionDefinitionDto.fromDecisionDefinition(definition);
}
use of org.camunda.bpm.engine.repository.DecisionDefinition 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());
}
}
use of org.camunda.bpm.engine.repository.DecisionDefinition in project camunda-bpm-platform by camunda.
the class CallableElementUtil method getDecisionDefinitionToCall.
public static DecisionDefinition getDecisionDefinitionToCall(VariableScope execution, BaseCallableElement callableElement) {
String decisionDefinitionKey = callableElement.getDefinitionKey(execution);
String tenantId = callableElement.getDefinitionTenantId(execution);
DeploymentCache deploymentCache = getDeploymentCache();
DecisionDefinition decisionDefinition = null;
if (callableElement.isLatestBinding()) {
decisionDefinition = deploymentCache.findDeployedLatestDecisionDefinitionByKeyAndTenantId(decisionDefinitionKey, tenantId);
} else if (callableElement.isDeploymentBinding()) {
String deploymentId = callableElement.getDeploymentId();
decisionDefinition = deploymentCache.findDeployedDecisionDefinitionByDeploymentAndKey(deploymentId, decisionDefinitionKey);
} else if (callableElement.isVersionBinding()) {
Integer version = callableElement.getVersion(execution);
decisionDefinition = deploymentCache.findDeployedDecisionDefinitionByKeyVersionAndTenantId(decisionDefinitionKey, version, tenantId);
}
return decisionDefinition;
}
use of org.camunda.bpm.engine.repository.DecisionDefinition in project camunda-bpm-platform by camunda.
the class MultiTenancyDecisionTableEvaluationTest method testFailToEvaluateDecisionByIdWithoutTenantId.
public void testFailToEvaluateDecisionByIdWithoutTenantId() {
deployment(DMN_FILE);
DecisionDefinition decisionDefinition = repositoryService.createDecisionDefinitionQuery().singleResult();
try {
decisionService.evaluateDecisionTableById(decisionDefinition.getId()).variables(createVariables()).decisionDefinitionWithoutTenantId().evaluate();
fail("BadUserRequestException exception");
} catch (BadUserRequestException e) {
assertThat(e.getMessage(), containsString("Cannot specify a tenant-id"));
}
}
Aggregations