Search in sources :

Example 1 with RuntimeService

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

the class ProcessInstanceRestServiceImpl method deleteAsync.

@Override
public BatchDto deleteAsync(DeleteProcessInstancesDto dto) {
    RuntimeService runtimeService = getProcessEngine().getRuntimeService();
    ProcessInstanceQuery processInstanceQuery = null;
    if (dto.getProcessInstanceQuery() != null) {
        processInstanceQuery = dto.getProcessInstanceQuery().toQuery(getProcessEngine());
    }
    Batch batch = null;
    try {
        batch = runtimeService.deleteProcessInstancesAsync(dto.getProcessInstanceIds(), processInstanceQuery, dto.getDeleteReason(), dto.isSkipCustomListeners(), dto.isSkipSubprocesses());
        return BatchDto.fromBatch(batch);
    } catch (BadUserRequestException e) {
        throw new InvalidRequestException(Status.BAD_REQUEST, e.getMessage());
    }
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) RuntimeService(org.camunda.bpm.engine.RuntimeService) Batch(org.camunda.bpm.engine.batch.Batch) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException)

Example 2 with RuntimeService

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

the class SignalRestServiceImpl method createSignalEventReceivedBuilder.

protected SignalEventReceivedBuilder createSignalEventReceivedBuilder(SignalDto dto) {
    RuntimeService runtimeService = processEngine.getRuntimeService();
    String name = dto.getName();
    SignalEventReceivedBuilder signalEvent = runtimeService.createSignalEvent(name);
    String executionId = dto.getExecutionId();
    if (executionId != null) {
        signalEvent.executionId(executionId);
    }
    Map<String, VariableValueDto> variablesDto = dto.getVariables();
    if (variablesDto != null) {
        Map<String, Object> variables = VariableValueDto.toMap(variablesDto, processEngine, objectMapper);
        signalEvent.setVariables(variables);
    }
    String tenantId = dto.getTenantId();
    if (tenantId != null) {
        signalEvent.tenantId(tenantId);
    }
    boolean isWithoutTenantId = dto.isWithoutTenantId();
    if (isWithoutTenantId) {
        signalEvent.withoutTenantId();
    }
    return signalEvent;
}
Also used : SignalEventReceivedBuilder(org.camunda.bpm.engine.runtime.SignalEventReceivedBuilder) VariableValueDto(org.camunda.bpm.engine.rest.dto.VariableValueDto) RuntimeService(org.camunda.bpm.engine.RuntimeService)

Example 3 with RuntimeService

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

the class MessageRestServiceImpl method createMessageCorrelationBuilder.

protected MessageCorrelationBuilder createMessageCorrelationBuilder(CorrelationMessageDto messageDto) {
    RuntimeService runtimeService = processEngine.getRuntimeService();
    ObjectMapper objectMapper = getObjectMapper();
    Map<String, Object> correlationKeys = VariableValueDto.toMap(messageDto.getCorrelationKeys(), processEngine, objectMapper);
    Map<String, Object> localCorrelationKeys = VariableValueDto.toMap(messageDto.getLocalCorrelationKeys(), processEngine, objectMapper);
    Map<String, Object> processVariables = VariableValueDto.toMap(messageDto.getProcessVariables(), processEngine, objectMapper);
    MessageCorrelationBuilder builder = runtimeService.createMessageCorrelation(messageDto.getMessageName());
    if (processVariables != null) {
        builder.setVariables(processVariables);
    }
    if (messageDto.getBusinessKey() != null) {
        builder.processInstanceBusinessKey(messageDto.getBusinessKey());
    }
    if (correlationKeys != null && !correlationKeys.isEmpty()) {
        for (Entry<String, Object> correlationKey : correlationKeys.entrySet()) {
            String name = correlationKey.getKey();
            Object value = correlationKey.getValue();
            builder.processInstanceVariableEquals(name, value);
        }
    }
    if (localCorrelationKeys != null && !localCorrelationKeys.isEmpty()) {
        for (Entry<String, Object> correlationKey : localCorrelationKeys.entrySet()) {
            String name = correlationKey.getKey();
            Object value = correlationKey.getValue();
            builder.localVariableEquals(name, value);
        }
    }
    if (messageDto.getTenantId() != null) {
        builder.tenantId(messageDto.getTenantId());
    } else if (messageDto.isWithoutTenantId()) {
        builder.withoutTenantId();
    }
    String processInstanceId = messageDto.getProcessInstanceId();
    if (processInstanceId != null) {
        builder.processInstanceId(processInstanceId);
    }
    return builder;
}
Also used : RuntimeService(org.camunda.bpm.engine.RuntimeService) MessageCorrelationBuilder(org.camunda.bpm.engine.runtime.MessageCorrelationBuilder) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 4 with RuntimeService

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

the class MigrationRestServiceImpl method generateMigrationPlan.

public MigrationPlanDto generateMigrationPlan(MigrationPlanGenerationDto generationDto) {
    RuntimeService runtimeService = processEngine.getRuntimeService();
    String sourceProcessDefinitionId = generationDto.getSourceProcessDefinitionId();
    String targetProcessDefinitionId = generationDto.getTargetProcessDefinitionId();
    try {
        MigrationInstructionsBuilder instructionsBuilder = runtimeService.createMigrationPlan(sourceProcessDefinitionId, targetProcessDefinitionId).mapEqualActivities();
        if (generationDto.isUpdateEventTriggers()) {
            instructionsBuilder = instructionsBuilder.updateEventTriggers();
        }
        MigrationPlan migrationPlan = instructionsBuilder.build();
        return MigrationPlanDto.from(migrationPlan);
    } catch (BadUserRequestException e) {
        throw new InvalidRequestException(Status.BAD_REQUEST, e, e.getMessage());
    }
}
Also used : RuntimeService(org.camunda.bpm.engine.RuntimeService) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) MigrationInstructionsBuilder(org.camunda.bpm.engine.migration.MigrationInstructionsBuilder) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException)

Example 5 with RuntimeService

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

the class ExecutionResourceImpl method getExecution.

@Override
public ExecutionDto getExecution() {
    RuntimeService runtimeService = engine.getRuntimeService();
    Execution execution = runtimeService.createExecutionQuery().executionId(executionId).singleResult();
    if (execution == null) {
        throw new InvalidRequestException(Status.NOT_FOUND, "Execution with id " + executionId + " does not exist");
    }
    return ExecutionDto.fromExecution(execution);
}
Also used : Execution(org.camunda.bpm.engine.runtime.Execution) RuntimeService(org.camunda.bpm.engine.RuntimeService) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException)

Aggregations

RuntimeService (org.camunda.bpm.engine.RuntimeService)51 Test (org.junit.Test)12 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)10 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)9 IdentityService (org.camunda.bpm.engine.IdentityService)6 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)6 TaskService (org.camunda.bpm.engine.TaskService)5 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)5 Batch (org.camunda.bpm.engine.batch.Batch)4 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)4 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)4 Task (org.camunda.bpm.engine.task.Task)4 ArrayList (java.util.ArrayList)3 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)3 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)3 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)3 ProcessEngineServices (org.camunda.bpm.engine.ProcessEngineServices)3 RepositoryService (org.camunda.bpm.engine.RepositoryService)3 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)3 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)3