use of org.camunda.bpm.engine.RuntimeService in project camunda-bpm-platform by camunda.
the class MessageEventSubscriptionResource method getEventSubscription.
@Override
public EventSubscriptionDto getEventSubscription() {
RuntimeService runtimeService = engine.getRuntimeService();
EventSubscription eventSubscription = runtimeService.createEventSubscriptionQuery().executionId(executionId).eventName(messageName).eventType(MESSAGE_EVENT_TYPE).singleResult();
if (eventSubscription == null) {
String errorMessage = String.format("Message event subscription for execution %s named %s does not exist", executionId, messageName);
throw new InvalidRequestException(Status.NOT_FOUND, errorMessage);
}
return EventSubscriptionDto.fromEventSubscription(eventSubscription);
}
use of org.camunda.bpm.engine.RuntimeService in project camunda-bpm-platform by camunda.
the class ProcessStartingMethodInterceptor method invoke.
public Object invoke(MethodInvocation invocation) throws Throwable {
Method method = invocation.getMethod();
StartProcess startProcess = AnnotationUtils.getAnnotation(method, StartProcess.class);
String processKey = startProcess.processKey();
Assert.hasText(processKey, "you must provide the name of process to start");
Object result;
try {
result = invocation.proceed();
Map<String, Object> vars = this.processVariablesFromAnnotations(invocation);
String businessKey = this.processBusinessKey(invocation);
log.info("variables for the started process: " + vars.toString());
RuntimeService runtimeService = this.processEngine.getRuntimeService();
ProcessInstance pi;
if (null != businessKey && StringUtils.hasText(businessKey)) {
pi = runtimeService.startProcessInstanceByKey(processKey, businessKey, vars);
log.info("the business key for the started process is '" + businessKey + "' ");
} else {
pi = runtimeService.startProcessInstanceByKey(processKey, vars);
}
String pId = pi.getId();
if (invocation.getMethod().getReturnType().equals(void.class))
return null;
if (shouldReturnProcessInstance(startProcess, invocation, result))
return pi;
if (shouldReturnProcessInstanceId(startProcess, invocation, result))
return pId;
if (shouldReturnAsyncResultWithProcessInstance(startProcess, invocation, result)) {
return new AsyncResult<ProcessInstance>(pi);
}
} catch (Throwable th) {
throw new RuntimeException(th);
}
return result;
}
use of org.camunda.bpm.engine.RuntimeService in project camunda-bpm-platform by camunda.
the class SetExternalTasksRetriesTest method deployTestProcesses.
@Before
public void deployTestProcesses() throws Exception {
org.camunda.bpm.engine.repository.Deployment deployment = engineRule.getRepositoryService().createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml").addClasspathResource("org/camunda/bpm/engine/test/api/externaltask/externalTaskPriorityExpression.bpmn20.xml").deploy();
engineRule.manageDeployment(deployment);
RuntimeService runtimeService = engineRule.getRuntimeService();
processInstanceIds = new ArrayList<String>();
for (int i = 0; i < 4; i++) {
processInstanceIds.add(runtimeService.startProcessInstanceByKey(PROCESS_DEFINITION_KEY, i + "").getId());
}
processInstanceIds.add(runtimeService.startProcessInstanceByKey(PROCESS_DEFINITION_KEY_2).getId());
}
use of org.camunda.bpm.engine.RuntimeService in project camunda-bpm-platform by camunda.
the class MyFormFieldValidator method validate.
public boolean validate(Object submittedValue, FormFieldValidatorContext validatorContext) {
ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
IdentityService identityService = processEngineConfiguration.getIdentityService();
RuntimeService runtimeService = processEngineConfiguration.getRuntimeService();
logAuthentication(identityService);
logInstancesCount(runtimeService);
return true;
}
use of org.camunda.bpm.engine.RuntimeService in project camunda-bpm-platform by camunda.
the class MyTaskFormHandler method createTaskForm.
public TaskFormData createTaskForm(TaskEntity task) {
ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
IdentityService identityService = processEngineConfiguration.getIdentityService();
RuntimeService runtimeService = processEngineConfiguration.getRuntimeService();
logAuthentication(identityService);
logInstancesCount(runtimeService);
TaskFormDataImpl result = new TaskFormDataImpl();
result.setTask(task);
return result;
}
Aggregations