Package org.jbpm.taskmgmt.exe

Examples of org.jbpm.taskmgmt.exe.TaskMgmtInstance


    TaskMgmtInstance tmi = token.getProcessInstance().getTaskMgmtInstance();
    tmi.createTaskInstance(task, token);
  }

  private int getNbrOfTasks(Token token) {
    TaskMgmtInstance tmi = (TaskMgmtInstance) token.getProcessInstance().getInstance(TaskMgmtInstance.class);
    return tmi.getUnfinishedTasks(token).size();
  }
View Full Code Here


    TaskMgmtInstance tmi = (TaskMgmtInstance) token.getProcessInstance().getInstance(TaskMgmtInstance.class);
    return tmi.getUnfinishedTasks(token).size();
  }

  public static void endOneTask(Token token) {
    TaskMgmtInstance tmi = (TaskMgmtInstance)token.getProcessInstance().getInstance(TaskMgmtInstance.class);
    TaskInstance taskInstance = (TaskInstance) tmi.getUnfinishedTasks(token).iterator().next();
    taskInstance.end();
  }
View Full Code Here

      // create as many task instances as the scenario prescribes :
      //  0 tasks for scenario 1
      //  1 task for scenario 2
      //  2 tasks for scenario 3
      //  3 tasks for scenario 4
      TaskMgmtInstance tmi = executionContext.getTaskMgmtInstance();
      for (int i = 1; i<scenario; i++) {
        tmi.createTaskInstance(task, executionContext.getToken());
      }
    }
View Full Code Here

      "  <state name='c' />" +
      "</process-definition>"
    );

    ProcessInstance pi = new ProcessInstance( pd );
    TaskMgmtInstance taskMgmtInstance = (TaskMgmtInstance) pi.getInstance(TaskMgmtInstance.class);
   
    pi.signal();
    Token token = pi.getRootToken();

    // after start, the token is waiting in state b
    assertSame( pd.getNode("b"), token.getNode() );
   
    // and no tasks have been created yet
    assertEquals(0, taskMgmtInstance.getUnfinishedTasks(token).size() );

    // now we signal the process to move on.
    // execution will arrive at the task-node
    // the default behaviour of the task node is to create each task and wait till the last one finishes
    pi.signal();

    // now, 3 tasks have been created...
    List tasks = new ArrayList( taskMgmtInstance.getUnfinishedTasks(token) );
    assertEquals(3, tasks.size());
    // ... and the process is in the task state
    assertSame( pd.getNode("t"), token.getNode() );

    // now we finish the tasks one by one
    // finish task 0
    ((TaskInstance)tasks.get(0)).end();
   
    // still 2 tasks remaining
    assertEquals(2, taskMgmtInstance.getUnfinishedTasks(token).size() );
    // and the process is still in node t
    assertSame( pd.getNode("t"), token.getNode() );
   
    // finish task 1
    ((TaskInstance)tasks.get(1)).end();
   
    // still 1 task remaining
    assertEquals(1, taskMgmtInstance.getUnfinishedTasks(token).size() );
    // and the process is still in node t
    assertSame( pd.getNode("t"), token.getNode() );
   
    // finish task 2
    ((TaskInstance)tasks.get(2)).end();
   
    // no more tasks remaining
    assertEquals(0, taskMgmtInstance.getUnfinishedTasks(token).size() );
    // and the process has moved to node c
    assertEquals( pd.getNode("c"), token.getNode() );
  }
View Full Code Here

    pi.signal();
    assertNbrOfTasks(3);
  }

  private void assertNbrOfTasks(int nbrOfTasks) {
    TaskMgmtInstance taskMgmtInstance = (TaskMgmtInstance) pi.getInstance(TaskMgmtInstance.class);
    Token token = pi.getRootToken();
   
    assertEquals( nbrOfTasks, taskMgmtInstance.getUnfinishedTasks( token ).size() );
    assertSame( pd.getNode("c"), token.getNode() );
  }
View Full Code Here

    public void execute(ExecutionContext executionContext) throws Exception {
      // this piece of code is executed at runtime
      TaskMgmtDefinition taskMgmtDefinition = (TaskMgmtDefinition) executionContext.getDefinition(TaskMgmtDefinition.class);
      Task task = taskMgmtDefinition.getTask("undress");
     
      TaskMgmtInstance tmi = executionContext.getTaskMgmtInstance();
      for (int i = 1; i<scenario; i++) {
        tmi.createTaskInstance(task, executionContext.getToken());
      }
    }
View Full Code Here

    assertSame(c, token.getNode());
  }

  public static void endOneTask(Token token) {
    TaskMgmtInstance tmi = (TaskMgmtInstance)token.getProcessInstance().getInstance(TaskMgmtInstance.class);
    TaskInstance taskInstance = (TaskInstance) tmi.getUnfinishedTasks(token).iterator().next();
    taskInstance.end();
  }
View Full Code Here

      // create as many task instances as the scenario prescribes :
      //  0 tasks for scenario 1
      //  1 task for scenario 2
      //  2 tasks for scenario 3
      //  3 tasks for scenario 4
      TaskMgmtInstance tmi = executionContext.getTaskMgmtInstance();
      for (int i = 1; i<scenario; i++) {
        tmi.createTaskInstance(task, executionContext.getToken());
      }
    }
View Full Code Here

  }
 
  public void testProcessInstanceModuleInstances() {
    ProcessInstance processInstance = new ProcessInstance();
    processInstance.addInstance(new ContextInstance());
    processInstance.addInstance(new TaskMgmtInstance());
  
    processInstance = saveAndReload(processInstance);

    assertNotNull(processInstance.getInstances());
    assertEquals(2, processInstance.getInstances().size());
View Full Code Here

      messageService.suspendMessages(this);
    }
  }

  void suspendTaskInstances() {
    TaskMgmtInstance taskMgmtInstance = (processInstance!=null ? processInstance.getTaskMgmtInstance() : null);
    if (taskMgmtInstance!=null) {
      taskMgmtInstance.suspend(this);
    }
  }
View Full Code Here

TOP

Related Classes of org.jbpm.taskmgmt.exe.TaskMgmtInstance

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.