Search in sources :

Example 36 with DecisionDefinition

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);
}
Also used : Response(com.jayway.restassured.response.Response) DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition) Test(org.junit.Test)

Example 37 with DecisionDefinition

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);
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) RestException(org.camunda.bpm.engine.rest.exception.RestException) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) RepositoryService(org.camunda.bpm.engine.RepositoryService)

Example 38 with DecisionDefinition

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());
    }
}
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 39 with DecisionDefinition

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;
}
Also used : DeploymentCache(org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache) DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition)

Example 40 with 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"));
    }
}
Also used : BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition)

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