Package org.activiti.engine.runtime

Examples of org.activiti.engine.runtime.Execution


    rating.setScore(score);
   
    entityManager.persist(rating);
    entityManager.flush();
   
    Execution execution = runtimeService.createExecutionQuery()
      .processInstanceId(loanApplicationEvent.getCorrelationId())
      .activityId("receiveRating")
      .singleResult();
       
    businessProcess.associateExecutionById(execution.getId());   
    businessProcess.setVariable("ratingId", rating.getId());
    businessProcess.signalExecution();   
  }
View Full Code Here


        rating.setScore(score);
       
        entityManager.persist(rating);
        entityManager.flush();

        Execution execution = runtimeService.createExecutionQuery()
          .processInstanceId(message.getStringProperty("correlationId"))
          .activityId("receiveRating")
          .singleResult();
           
        businessProcess.associateExecutionById(execution.getId());   
        businessProcess.setVariable("ratingId", rating.getId());
        businessProcess.signalExecution();   
       
      } catch (JMSException e) {
        throw new EJBException("Could not unwrap object message" + e.getMessage(), e);
View Full Code Here

    if(Context.getCommandContext() != null) {
      throw new ActivitiCdiException("Cannot work with scoped associations inside command context.");
    }
   
    ScopedAssociation scopedAssociation = getScopedAssociation();
    Execution associatedExecution = scopedAssociation.getExecution();
    if(associatedExecution!=null && !associatedExecution.getId().equals(execution.getId())) {
      throw new ActivitiCdiException("Cannot associate "+execution+", already associated with "+associatedExecution+". Disassociate first!");
    }
   
    if (log.isTraceEnabled()) {
      log.trace("Associating {} (@{})", execution,
View Full Code Here

    scopedAssociation.setTask(null);
  }
 
  @Override
  public String getExecutionId() {
    Execution execution = getExecution();
    if (execution != null) {
      return execution.getId();
    } else {
      return null;
    }
  }
View Full Code Here

   *          the id of the execution to associate with.
   * @throw ActivitiCdiException
   *          if no such execution exists
   */
  public void associateExecutionById(String executionId) {
    Execution execution = processEngine.getRuntimeService()
      .createExecutionQuery()
      .executionId(executionId)
      .singleResult();
    if(execution == null) {
      throw new ActivitiCdiException("Cannot associate execution by id: no execution with id '"+executionId+"' found.");
View Full Code Here

  /**
   * Returns the id of the currently associated process instance or 'null'
   */
  public String getProcessInstanceId() {
    Execution execution = associationManager.getExecution();
    return execution != null ? execution.getProcessInstanceId() : null;
  }
View Full Code Here

 
  /**
   * @see #getExecution()
   */
  public String getExecutionId() {
    Execution e = getExecution();
    return e != null ? e.getId() : null;
  }
View Full Code Here

   * @throws ActivitiCdiException
   *           if no {@link Execution} is associated. Use
   *           {@link #isAssociated()} to check whether an association exists.
   */
  public ProcessInstance getProcessInstance() {
    Execution execution = getExecution();   
    if(execution != null && !(execution.getProcessInstanceId().equals(execution.getId()))){
      return processEngine
            .getRuntimeService()
            .createProcessInstanceQuery()
            .processInstanceId(execution.getProcessInstanceId())
            .singleResult();
    }
    return (ProcessInstance) execution;   
  }
View Full Code Here

    String processInstanceId = findProcessInstanceId(exchange);
   
    boolean firstTime = true;
    long initialTime  = System.currentTimeMillis();
  
    Execution execution = null;
    while (firstTime || (timeout > 0 && (System.currentTimeMillis() - initialTime < timeout))) {
       execution = runtimeService.createExecutionQuery()
          .processDefinitionKey(processKey)
          .processInstanceId(processInstanceId)
          .activityId(activity).singleResult();
       try {
         Thread.sleep(timeResolution);
       } catch (InterruptedException e) {
         throw new RuntimeException("error occured while waiting for activiti=" + activity + " for processInstanceId=" + processInstanceId);
       }
       firstTime = false;
       if (execution != null) {
         break;
       }
    }
    if (execution == null) {
      throw new RuntimeException("Couldn't find activity "+activity+" for processId " + processInstanceId + " in defined timeout.");
    }
   
    runtimeService.setVariables(execution.getId(), ExchangeUtils.prepareVariables(exchange, getActivitiEndpoint()));
    runtimeService.signal(execution.getId());
  }
View Full Code Here

  /**
   * Test getting a single execution.
   */
  @Deployment(resources = {"org/activiti/rest/service/api/runtime/ExecutionResourceTest.process-with-subprocess.bpmn20.xml"})
  public void testGetExecution() throws Exception {
    Execution parentExecution = runtimeService.startProcessInstanceByKey("processOne");
    Execution childExecution = runtimeService.createExecutionQuery().activityId("processTask").singleResult();
    assertNotNull(childExecution);
   
    CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX +
        RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION, parentExecution.getId())), HttpStatus.SC_OK);
   
    // Check resulting parent execution
    JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
    closeResponse(response);
    assertNotNull(responseNode);
    assertEquals(parentExecution.getId(), responseNode.get("id").textValue());
    assertTrue(responseNode.get("activityId").isNull());
    assertFalse(responseNode.get("suspended").booleanValue());
    assertTrue(responseNode.get("parentUrl").isNull());
    assertFalse(responseNode.get("suspended").booleanValue());
   
    assertTrue(responseNode.get("url").asText().endsWith(
            RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION, parentExecution.getId())));
   
    assertTrue(responseNode.get("processInstanceUrl").asText().endsWith(
            RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE, parentExecution.getId())));
   
    // Check resulting child execution
    response = executeRequest(new HttpGet(SERVER_URL_PREFIX +
        RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION, childExecution.getId())), HttpStatus.SC_OK);
   
    responseNode = objectMapper.readTree(response.getEntity().getContent());
    closeResponse(response);
    assertNotNull(responseNode);
    assertEquals(childExecution.getId(), responseNode.get("id").textValue());
    assertEquals("processTask", responseNode.get("activityId").textValue());
    assertFalse(responseNode.get("suspended").booleanValue());
    assertFalse(responseNode.get("suspended").booleanValue());
   
    assertTrue(responseNode.get("url").asText().endsWith(
            RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION, childExecution.getId())));
   
    assertTrue(responseNode.get("parentUrl").asText().endsWith(
            RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION, parentExecution.getId())));
   
    assertTrue(responseNode.get("processInstanceUrl").asText().endsWith(
View Full Code Here

TOP

Related Classes of org.activiti.engine.runtime.Execution

Copyright © 2018 www.massapicom. 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.