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