Search in sources :

Example 6 with RuntimeService

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);
}
Also used : EventSubscription(org.camunda.bpm.engine.runtime.EventSubscription) RuntimeService(org.camunda.bpm.engine.RuntimeService) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException)

Example 7 with RuntimeService

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;
}
Also used : RuntimeService(org.camunda.bpm.engine.RuntimeService) StartProcess(org.camunda.bpm.engine.spring.annotations.StartProcess) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Method(java.lang.reflect.Method) AsyncResult(org.springframework.scheduling.annotation.AsyncResult)

Example 8 with RuntimeService

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());
}
Also used : RuntimeService(org.camunda.bpm.engine.RuntimeService) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Before(org.junit.Before)

Example 9 with RuntimeService

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;
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) RuntimeService(org.camunda.bpm.engine.RuntimeService) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)

Example 10 with RuntimeService

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;
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) TaskFormDataImpl(org.camunda.bpm.engine.impl.form.TaskFormDataImpl) RuntimeService(org.camunda.bpm.engine.RuntimeService) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)

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