Examples of RuntimeService


Examples of org.camunda.bpm.engine.RuntimeService

    if (params > 1) {
      String message = "Only one of processInstanceId, processDefinitionId or processDefinitionKey should be set to update the suspension state.";
      throw new InvalidRequestException(Status.BAD_REQUEST, message);
    }

    RuntimeService runtimeService = engine.getRuntimeService();

    if (processInstanceId != null) {
      // activate/suspend process instance by id
      if (getSuspended()) {
        runtimeService.suspendProcessInstanceById(processInstanceId);
      } else {
        runtimeService.activateProcessInstanceById(processInstanceId);
      }
    } else

    if (processDefinitionId != null) {
      // activate/suspend process instances by process definition id
      if (getSuspended()) {
        runtimeService.suspendProcessInstanceByProcessDefinitionId(processDefinitionId);
      } else {
        runtimeService.activateProcessInstanceByProcessDefinitionId(processDefinitionId);
      }
    } else

    if (processDefinitionKey != null) {
      // activate/suspend process instances by process definition key
      if (getSuspended()) {
        runtimeService.suspendProcessInstanceByProcessDefinitionKey(processDefinitionKey);
      } else {
        runtimeService.activateProcessInstanceByProcessDefinitionKey(processDefinitionKey);
      }
    } else {
      String message = "Either processInstanceId, processDefinitionId or processDefinitionKey should be set to update the suspension state.";
      throw new InvalidRequestException(Status.BAD_REQUEST, message);
    }
View Full Code Here

Examples of org.camunda.bpm.engine.RuntimeService

    this.objectMapper = objectMapper;
  }

  @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");
    }
View Full Code Here

Examples of org.camunda.bpm.engine.RuntimeService

    return ExecutionDto.fromExecution(execution);
  }

  @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);
View Full Code Here

Examples of org.camunda.bpm.engine.RuntimeService

    return result;
  }

  @Override
  public ProcessInstanceDto startProcessInstance(UriInfo context, StartProcessInstanceDto parameters) {
    RuntimeService runtimeService = engine.getRuntimeService();

    ProcessInstance instance = null;
    try {
      Map<String, Object> variables = VariableValueDto.toMap(parameters.getVariables(), engine, objectMapper);
      String businessKey = parameters.getBusinessKey();
      String caseInstanceId = parameters.getCaseInstanceId();

      instance = runtimeService.startProcessInstanceById(processDefinitionId, businessKey, caseInstanceId, variables);

    } catch (ProcessEngineException e) {
      String errorMessage = String.format("Cannot instantiate process definition %s: %s", processDefinitionId, e.getMessage());
      throw new RestException(Status.INTERNAL_SERVER_ERROR, e, errorMessage);
View Full Code Here

Examples of org.camunda.bpm.engine.RuntimeService

    this.objectMapper = objectMapper;
  }

  @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);
View Full Code Here

Examples of org.camunda.bpm.engine.RuntimeService

    return EventSubscriptionDto.fromEventSubscription(eventSubscription);
  }

  @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 (ProcessEngineException e) {
      throw new RestException(Status.INTERNAL_SERVER_ERROR, e, String.format("Cannot trigger message %s for execution %s: %s",
        messageName, executionId, e.getMessage()));
View Full Code Here

Examples of org.camunda.bpm.engine.RuntimeService

    this.objectMapper = objectMapper;
  }

  @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");
    }
View Full Code Here

Examples of org.camunda.bpm.engine.RuntimeService

    return result;
  }

  @Override
  public void deleteProcessInstance() {
    RuntimeService runtimeService = engine.getRuntimeService();
    try {
      runtimeService.deleteProcessInstance(processInstanceId, null);
    } catch (ProcessEngineException e) {
      throw new InvalidRequestException(Status.NOT_FOUND, e, "Process instance with id " + processInstanceId + " does not exist");
    }

  }
View Full Code Here

Examples of org.camunda.bpm.engine.RuntimeService

    return new ExecutionVariablesResource(engine, processInstanceId, true, objectMapper);
  }

  @Override
  public ActivityInstanceDto getActivityInstanceTree() {
    RuntimeService runtimeService = engine.getRuntimeService();

    ActivityInstance activityInstance = null;

    try {
      activityInstance = runtimeService.getActivityInstance(processInstanceId);
    } catch (ProcessEngineException e) {
      throw new InvalidRequestException(Status.INTERNAL_SERVER_ERROR, e, e.getMessage());
    }

    if (activityInstance == null) {
View Full Code Here

Examples of org.camunda.bpm.engine.RuntimeService

  public ProcessEngineRule activitiRule = new ProcessEngineRule();
 
  @Test
  @Deployment
  public void ruleUsageExample() {
    RuntimeService runtimeService = activitiRule.getRuntimeService();
    runtimeService.startProcessInstanceByKey("ruleUsage");
   
    TaskService taskService = activitiRule.getTaskService();
    Task task = taskService.createTaskQuery().singleResult();
    assertEquals("My Task", task.getName());
   
    taskService.complete(task.getId());
    assertEquals(0, runtimeService.createProcessInstanceQuery().count());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.