Package org.jbpm.api

Examples of org.jbpm.api.Execution


  public void assertProcessInstanceEnded(ProcessInstance processInstance) {
    assertExecutionEnded(processInstance.getId());
  }
 
  public void assertActiveActivity(String activityName, String executionId) {
    Execution execution = executionService.findExecutionById(executionId);
    assertTrue("The given execution (or any child execution) isn't in the activity '" + activityName
            + "' (current activities : " + listAllActiveActivites(executionId) + ")",
            execution.isActive(activityName));
  }
View Full Code Here


               "Current activitites are: " + listAllActiveActivites(executionId),
               executionService.findExecutionById(executionId).isActive(activityName));
  }
 
  private String listAllActiveActivites(String executionId) {
    Execution execution = executionService.findExecutionById(executionId);
    Set<String> activeActivities = execution.findActiveActivityNames();
    StringBuilder result = new StringBuilder();
    for (String activeActivity : activeActivities) {
      result.append("'" + activeActivity + "', ");
    }
    result.setLength(result.length() - 2); // remove the last ', '
View Full Code Here

    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();

    try
    {
      ExecutionService execService = this.processEngine.getExecutionService();
      Execution exec = execService.startProcessInstanceById(definitionId);
      return ModelAdaptor.adoptExecution((ExecutionImpl)exec);
    }
    finally{
      env.close();
    }
View Full Code Here

    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();

    try
    {
      ExecutionService execService = this.processEngine.getExecutionService();
      Execution exec = execService.startProcessInstanceById(definitionId);
      execService.setVariables(exec.getId(), processVars);
     
      return ModelAdaptor.adoptExecution((ExecutionImpl)exec);
    }
    finally{
      env.close();
View Full Code Here

    try
    {

      ExecutionService execService = this.processEngine.getExecutionService();
      Execution exec = execService.findExecutionById(instanceId);
      if(null==exec)
        throw new IllegalArgumentException("No such execution with id "+ instanceId);

      ProcessInstanceRef.RESULT actualResult = result!=null ? result : ProcessInstanceRef.RESULT.COMPLETED;
      execService.endProcessInstance(instanceId, actualResult.toString());
View Full Code Here

    try
    {

      ExecutionService execService = this.processEngine.getExecutionService();
      Execution exec = execService.findExecutionById(instanceId);
      if(null==exec)
        throw new IllegalArgumentException("No such execution with id "+ instanceId);

      execService.deleteProcessInstance(instanceId);
    }
View Full Code Here

    }

    @Test
    public void testWaitStatesSequence() {
        ProcessInstance processInstance = executionService.startProcessInstanceByKey("StateSequence");
        Execution executionInA = processInstance.findActiveExecutionIn("a");
        assertNotNull(executionInA);

        processInstance = executionService.signalExecutionById(executionInA.getId());
        Execution executionInB = processInstance.findActiveExecutionIn("b");
        assertNotNull(executionInB);

        processInstance = executionService.signalExecutionById(executionInB.getId());
        Execution executionInC = processInstance.findActiveExecutionIn("c");
        assertNotNull(executionInC);
    }
View Full Code Here

     * @return the updated ProcessInstance
     */
    public Object advanceProcess(Object executionId, Object signalName, Map variables) throws Exception
    {
        int waitTime = 0;
        Execution execution = processEngine.getExecutionService().findExecutionById((String) executionId);
        while (execution == null && waitTime < PROCESS_CREATION_WAIT)
        {
            // Given the multi-threaded nature of Mule, sometimes a response message will arrive to advance the
            // process before the creation of the process has fully terminated (e.g., during in-memory unit tests).
            // We delay for awhile to make sure this is not the case before giving up and throwing an exception.
            Thread.sleep(PROCESS_CREATION_WAIT / 10);
            waitTime += (PROCESS_CREATION_WAIT / 10);
            execution = processEngine.getExecutionService().findExecutionById((String) executionId);
        }
        if (execution == null)
        {
            throw new IllegalArgumentException("No process execution found with id = " + executionId + " (it may have already terminated)");
        }

        String processId;
        if (execution.getProcessInstance() != null)
        {
            processId = execution.getProcessInstance().getId();
        }
        else
        {
            processId = execution.getId();
        }

        // Set any process variables.
        if (variables != null && !variables.isEmpty())
        {
View Full Code Here

     */
    public Object updateProcess(Object executionId, Map variables) throws Exception
    {
        // Get Process ID
        String processId;
        Execution execution = processEngine.getExecutionService().findExecutionById((String) executionId);
        if (execution == null)
        {
            throw new IllegalArgumentException("No process execution found with id = " + executionId + " (it may have already terminated)");
        }
        if (execution.getProcessInstance() != null)
        {
            processId = execution.getProcessInstance().getId();
        }
        else
        {
            processId = execution.getId();
        }

        // Set any process variables.
        if (variables != null && !variables.isEmpty())
        {
View Full Code Here

     */
    @Override
    public Object advanceProcess(Object executionId, Object signalName, Map variables) throws Exception
    {
        int waitTime = 0;
        Execution execution = processEngine.getExecutionService().findExecutionById((String) executionId);
        while (execution == null && waitTime < PROCESS_CREATION_WAIT)
        {
            // Given the multi-threaded nature of Mule, sometimes a response message will arrive to advance the
            // process before the creation of the process has fully terminated (e.g., during in-memory unit tests).
            // We delay for awhile to make sure this is not the case before giving up and throwing an exception.
            Thread.sleep(PROCESS_CREATION_WAIT / 10);
            waitTime += (PROCESS_CREATION_WAIT / 10);
            execution = processEngine.getExecutionService().findExecutionById((String) executionId);
        }
        if (execution == null)
        {
            throw new IllegalArgumentException("No process execution found with id = " + executionId + " (it may have already terminated)");
        }

        String processId;
        if (execution.getProcessInstance() != null)
        {
            processId = execution.getProcessInstance().getId();
        }
        else
        {
            processId = execution.getId();
        }

        // Set any process variables.
        if (variables != null && !variables.isEmpty())
        {
View Full Code Here

TOP

Related Classes of org.jbpm.api.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.