Search in sources :

Example 16 with CaseService

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

the class CaseDefinitionResourceImpl method createCaseInstance.

public CaseInstanceDto createCaseInstance(UriInfo context, CreateCaseInstanceDto parameters) {
    CaseService caseService = engine.getCaseService();
    CaseInstance instance = null;
    try {
        String businessKey = parameters.getBusinessKey();
        VariableMap variables = VariableValueDto.toMap(parameters.getVariables(), engine, objectMapper);
        instance = caseService.withCaseDefinition(caseDefinitionId).businessKey(businessKey).setVariables(variables).create();
    } catch (RestException e) {
        String errorMessage = String.format("Cannot instantiate case definition %s: %s", caseDefinitionId, e.getMessage());
        throw new InvalidRequestException(e.getStatus(), e, errorMessage);
    } catch (NotFoundException e) {
        String errorMessage = String.format("Cannot instantiate case definition %s: %s", caseDefinitionId, e.getMessage());
        throw new InvalidRequestException(Status.NOT_FOUND, e, errorMessage);
    } catch (NotValidException e) {
        String errorMessage = String.format("Cannot instantiate case definition %s: %s", caseDefinitionId, e.getMessage());
        throw new InvalidRequestException(Status.BAD_REQUEST, e, errorMessage);
    } catch (NotAllowedException e) {
        String errorMessage = String.format("Cannot instantiate case definition %s: %s", caseDefinitionId, e.getMessage());
        throw new InvalidRequestException(Status.FORBIDDEN, e, errorMessage);
    } catch (ProcessEngineException e) {
        String errorMessage = String.format("Cannot instantiate case definition %s: %s", caseDefinitionId, e.getMessage());
        throw new RestException(Status.INTERNAL_SERVER_ERROR, e, errorMessage);
    }
    CaseInstanceDto result = CaseInstanceDto.fromCaseInstance(instance);
    URI uri = context.getBaseUriBuilder().path(rootResourcePath).path(CaseInstanceRestService.PATH).path(instance.getId()).build();
    result.addReflexiveLink(uri, HttpMethod.GET, "self");
    return result;
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) NotValidException(org.camunda.bpm.engine.exception.NotValidException) NotAllowedException(org.camunda.bpm.engine.exception.NotAllowedException) VariableMap(org.camunda.bpm.engine.variable.VariableMap) RestException(org.camunda.bpm.engine.rest.exception.RestException) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) CaseService(org.camunda.bpm.engine.CaseService) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) CreateCaseInstanceDto(org.camunda.bpm.engine.rest.dto.runtime.CreateCaseInstanceDto) CaseInstanceDto(org.camunda.bpm.engine.rest.dto.runtime.CaseInstanceDto) URI(java.net.URI) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 17 with CaseService

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

the class LocalCaseExecutionVariablesResource method removeVariableEntity.

protected void removeVariableEntity(String variableKey) {
    CaseService caseService = engine.getCaseService();
    caseService.withCaseExecution(resourceId).removeVariableLocal(variableKey).execute();
}
Also used : CaseService(org.camunda.bpm.engine.CaseService)

Example 18 with CaseService

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

the class CaseExecutionVariablesResource method setVariableEntity.

protected void setVariableEntity(String variableKey, TypedValue variableValue) {
    CaseService caseService = engine.getCaseService();
    caseService.withCaseExecution(resourceId).setVariable(variableKey, variableValue).execute();
}
Also used : CaseService(org.camunda.bpm.engine.CaseService)

Example 19 with CaseService

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

the class CaseExecutionVariablesResource method removeVariableEntity.

protected void removeVariableEntity(String variableKey) {
    CaseService caseService = engine.getCaseService();
    caseService.withCaseExecution(resourceId).removeVariable(variableKey).execute();
}
Also used : CaseService(org.camunda.bpm.engine.CaseService)

Example 20 with CaseService

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

the class CaseExecutionResourceImpl method manualStart.

public void manualStart(CaseExecutionTriggerDto triggerDto) {
    try {
        CaseService caseService = engine.getCaseService();
        CaseExecutionCommandBuilder commandBuilder = caseService.withCaseExecution(caseExecutionId);
        initializeCommand(commandBuilder, triggerDto, "start manually");
        commandBuilder.manualStart();
    } catch (NotFoundException e) {
        throw createInvalidRequestException("manualStart", Status.NOT_FOUND, e);
    } catch (NotValidException e) {
        throw createInvalidRequestException("manualStart", Status.BAD_REQUEST, e);
    } catch (NotAllowedException e) {
        throw createInvalidRequestException("manualStart", Status.FORBIDDEN, e);
    } catch (ProcessEngineException e) {
        throw createRestException("manualStart", Status.INTERNAL_SERVER_ERROR, e);
    }
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) NotAllowedException(org.camunda.bpm.engine.exception.NotAllowedException) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) CaseService(org.camunda.bpm.engine.CaseService) CaseExecutionCommandBuilder(org.camunda.bpm.engine.runtime.CaseExecutionCommandBuilder) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Aggregations

CaseService (org.camunda.bpm.engine.CaseService)22 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)9 NotAllowedException (org.camunda.bpm.engine.exception.NotAllowedException)9 NotFoundException (org.camunda.bpm.engine.exception.NotFoundException)9 NotValidException (org.camunda.bpm.engine.exception.NotValidException)9 CaseExecutionCommandBuilder (org.camunda.bpm.engine.runtime.CaseExecutionCommandBuilder)8 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)4 CaseInstance (org.camunda.bpm.engine.runtime.CaseInstance)4 DescribesScenario (org.camunda.bpm.qa.upgrade.DescribesScenario)4 ScenarioSetup (org.camunda.bpm.qa.upgrade.ScenarioSetup)4 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)3 CaseInstanceDto (org.camunda.bpm.engine.rest.dto.runtime.CaseInstanceDto)2 CaseExecutionQuery (org.camunda.bpm.engine.runtime.CaseExecutionQuery)2 URI (java.net.URI)1 ExternalTaskService (org.camunda.bpm.engine.ExternalTaskService)1 FilterService (org.camunda.bpm.engine.FilterService)1 FormService (org.camunda.bpm.engine.FormService)1 HistoryService (org.camunda.bpm.engine.HistoryService)1 IdentityService (org.camunda.bpm.engine.IdentityService)1 ManagementService (org.camunda.bpm.engine.ManagementService)1