use of org.camunda.bpm.engine.RuntimeService in project camunda-bpm-platform by camunda.
the class ProcessDefinitionResourceImpl method createRestartProcessInstanceBuilder.
private RestartProcessInstanceBuilder createRestartProcessInstanceBuilder(RestartProcessInstanceDto restartProcessInstanceDto) {
RuntimeService runtimeService = engine.getRuntimeService();
RestartProcessInstanceBuilder builder = runtimeService.restartProcessInstances(processDefinitionId);
if (restartProcessInstanceDto.getProcessInstanceIds() != null) {
builder.processInstanceIds(restartProcessInstanceDto.getProcessInstanceIds());
}
if (restartProcessInstanceDto.getHistoricProcessInstanceQuery() != null) {
builder.historicProcessInstanceQuery(restartProcessInstanceDto.getHistoricProcessInstanceQuery().toQuery(engine));
}
if (restartProcessInstanceDto.isInitialVariables()) {
builder.initialSetOfVariables();
}
if (restartProcessInstanceDto.isWithoutBusinessKey()) {
builder.withoutBusinessKey();
}
if (restartProcessInstanceDto.isSkipCustomListeners()) {
builder.skipCustomListeners();
}
if (restartProcessInstanceDto.isSkipIoMappings()) {
builder.skipIoMappings();
}
restartProcessInstanceDto.applyTo(builder, engine, objectMapper);
return builder;
}
use of org.camunda.bpm.engine.RuntimeService in project camunda-bpm-platform by camunda.
the class ProcessInstanceResourceImpl method getProcessInstance.
@Override
public ProcessInstanceDto getProcessInstance() {
RuntimeService runtimeService = engine.getRuntimeService();
ProcessInstance instance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
if (instance == null) {
throw new InvalidRequestException(Status.NOT_FOUND, "Process instance with id " + processInstanceId + " does not exist");
}
ProcessInstanceDto result = ProcessInstanceDto.fromProcessInstance(instance);
return result;
}
use of org.camunda.bpm.engine.RuntimeService in project camunda-bpm-platform by camunda.
the class ProcessInstanceResourceImpl method getActivityInstanceTree.
@Override
public ActivityInstanceDto getActivityInstanceTree() {
RuntimeService runtimeService = engine.getRuntimeService();
ActivityInstance activityInstance = null;
try {
activityInstance = runtimeService.getActivityInstance(processInstanceId);
} catch (AuthorizationException e) {
throw e;
} catch (ProcessEngineException e) {
throw new InvalidRequestException(Status.INTERNAL_SERVER_ERROR, e, e.getMessage());
}
if (activityInstance == null) {
throw new InvalidRequestException(Status.NOT_FOUND, "Process instance with id " + processInstanceId + " does not exist");
}
ActivityInstanceDto result = ActivityInstanceDto.fromActivityInstance(activityInstance);
return result;
}
use of org.camunda.bpm.engine.RuntimeService in project camunda-bpm-platform by camunda.
the class MessageEventSubscriptionResource method triggerEvent.
@Override
public void triggerEvent(ExecutionTriggerDto triggerDto) {
RuntimeService runtimeService = engine.getRuntimeService();
try {
VariableMap variables = VariableValueDto.toMap(triggerDto.getVariables(), engine, objectMapper);
runtimeService.messageEventReceived(messageName, executionId, variables);
} catch (AuthorizationException e) {
throw e;
} catch (ProcessEngineException e) {
throw new RestException(Status.INTERNAL_SERVER_ERROR, e, String.format("Cannot trigger message %s for execution %s: %s", messageName, executionId, e.getMessage()));
} catch (RestException e) {
String errorMessage = String.format("Cannot trigger message %s for execution %s: %s", messageName, executionId, e.getMessage());
throw new InvalidRequestException(e.getStatus(), e, errorMessage);
}
}
use of org.camunda.bpm.engine.RuntimeService in project camunda-bpm-platform by camunda.
the class ExecutionResourceImpl method signalExecution.
@Override
public void signalExecution(ExecutionTriggerDto triggerDto) {
RuntimeService runtimeService = engine.getRuntimeService();
try {
VariableMap variables = VariableValueDto.toMap(triggerDto.getVariables(), engine, objectMapper);
runtimeService.signal(executionId, variables);
} catch (RestException e) {
String errorMessage = String.format("Cannot signal execution %s: %s", executionId, e.getMessage());
throw new InvalidRequestException(e.getStatus(), e, errorMessage);
} catch (AuthorizationException e) {
throw e;
} catch (ProcessEngineException e) {
throw new RestException(Status.INTERNAL_SERVER_ERROR, e, "Cannot signal execution " + executionId + ": " + e.getMessage());
}
}
Aggregations