Package org.jbpm.taskmgmt.def

Examples of org.jbpm.taskmgmt.def.Task


      "    </task>" +
      "  </task-node>" +
      "</process-definition>"
    );
    TaskNode taskNode = (TaskNode) processDefinition.getNode("a");
    Task task = taskNode.getTask("clean ceiling");
    Event event = task.getEvent(Event.EVENTTYPE_TASK_CREATE);
    assertNotNull(event);
    assertSame(CreateTimerAction.class, event.getActions().get(0).getClass());

    event = task.getEvent(Event.EVENTTYPE_TASK_START);
    assertNotNull(event);
    assertSame(CancelTimerAction.class, event.getActions().get(0).getClass());

    event = task.getEvent(Event.EVENTTYPE_TASK_ASSIGN);
    assertNotNull(event);
    assertSame(CancelTimerAction.class, event.getActions().get(0).getClass());

    event = task.getEvent(Event.EVENTTYPE_TASK_END);
    assertNotNull(event);
    assertSame(CancelTimerAction.class, event.getActions().get(0).getClass());
  }
View Full Code Here


  public static class CreateTasks implements ActionHandler {
    private static final long serialVersionUID = 1L;
    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

 
  public static class CreateTasks implements ActionHandler {
    private static final long serialVersionUID = 1L;
    public void execute(ExecutionContext executionContext) throws Exception {
      TaskMgmtDefinition tmd = (TaskMgmtDefinition) executionContext.getDefinition(TaskMgmtDefinition.class);
      Task task = tmd.getTask("watch movie amadeus");
   
      // create as many task instances as the scenario prescribes :
      //  0 tasks for scenario 1
      //  1 task for scenario 2
      //  2 tasks for scenario 3
View Full Code Here

    assertEquals(3, taskNode.getTasks().size());
   
    Map tasks = new HashMap();
    Iterator iter = taskNode.getTasks().iterator();
    while (iter.hasNext()) {
      Task task = (Task) iter.next();
      tasks.put(task.getName(), task);
    }
    Task task = (Task) tasks.get("change the world once");
    assertNotNull(task);
    assertSame(taskNode, task.getTaskNode());
    assertTrue(task.isBlocking());
    assertEquals("anyonebutme", task.getAssignmentDelegation().getClassName());
   
    task = (Task) tasks.get("change the world twice");
    assertNotNull(task);
    assertSame(taskNode, task.getTaskNode());
    assertFalse(task.isBlocking());

    assertTrue(tasks.containsKey("change the world three times") );
  }
View Full Code Here

  public void testTaskNodeEvents() {
    assertSupportedEvents(new TaskNode(), new String[] { "node-enter", "node-leave", "before-signal", "after-signal" });
  }

  public void testTaskEvents() {
    assertSupportedEvents(new Task(), new String[] { "task-create", "task-assign", "task-start", "task-end" });
  }
View Full Code Here

   * creates a task instance on the rootToken, and assigns it
   * to the currently authenticated user.
   */
  public TaskInstance createStartTaskInstance() {
    TaskInstance taskInstance = null;
    Task startTask = taskMgmtDefinition.getStartTask();
    Token rootToken = processInstance.getRootToken();
    ExecutionContext executionContext = new ExecutionContext(rootToken);
    taskInstance = createTaskInstance(startTask, executionContext);
    taskInstance.setActorId(SecurityHelper.getAuthenticatedActorId());
    return taskInstance;
View Full Code Here

          } else {
            Delegation assignmentDelegation = readAssignmentDelegation(assignmentElement);
            swimlane.setAssignmentDelegation(assignmentDelegation);
          }
        } else {
          Task startTask = taskMgmtDefinition.getStartTask();
          if ( (startTask==null)
               || (startTask.getSwimlane()!=swimlane)
             ) {
            addWarning("swimlane '"+swimlaneName+"' does not have an assignment");
          }
        }
        taskMgmtDefinition.addSwimlane(swimlane);
View Full Code Here

      }
    }
  }

  public Task readTask(Element taskElement, TaskMgmtDefinition taskMgmtDefinition, TaskNode taskNode) {
    Task task = new Task();
    task.setProcessDefinition(processDefinition);
   
    // get the task name
    String name = taskElement.attributeValue("name");
    if (name!=null) {
      task.setName(name);
      taskMgmtDefinition.addTask(task);
    } else if (taskNode!=null) {
      task.setName(taskNode.getName());
      taskMgmtDefinition.addTask(task);
    }
   
    // parse common subelements
    readTaskTimers(taskElement, task);
    readEvents(taskElement, task);
    readExceptionHandlers(taskElement, task);

    // description and duration
    task.setDescription(taskElement.attributeValue("description"));
    String duedateText = taskElement.attributeValue("duedate");
    if (duedateText==null) {
      duedateText = taskElement.attributeValue("dueDate");
    }
    task.setDueDate(duedateText);
    String priorityText = taskElement.attributeValue("priority");
    if (priorityText!=null) {
      task.setPriority(Task.parsePriority(priorityText));
    }
   
    // if this task is in the context of a taskNode, associate them
    if (taskNode!=null) {
      taskNode.addTask(task);
    }

    // blocking
    String blockingText = taskElement.attributeValue("blocking");
    if (blockingText!=null) {
      if ( ("true".equalsIgnoreCase(blockingText))
           || ("yes".equalsIgnoreCase(blockingText))
           || ("on".equalsIgnoreCase(blockingText)) ) {
        task.setBlocking(true);
      }
    }
   
    // signalling
    String signallingText = taskElement.attributeValue("signalling");
    if (signallingText!=null) {
      if ( ("false".equalsIgnoreCase(signallingText))
           || ("no".equalsIgnoreCase(signallingText))
           || ("off".equalsIgnoreCase(signallingText)) ) {
        task.setSignalling(false);
      }
    }
   
    // assignment
    String swimlaneName = taskElement.attributeValue("swimlane");
    Element assignmentElement = taskElement.element("assignment");

    // if there is a swimlane attribute specified
    if (swimlaneName!=null) {
      Swimlane swimlane = taskMgmtDefinition.getSwimlane(swimlaneName);
      if (swimlane==null) {
        addWarning("task references unknown swimlane '"+swimlaneName+"':"+taskElement.asXML());
      } else {
        task.setSwimlane(swimlane);
      }

    // else if there is a direct assignment specified
    } else if (assignmentElement!=null) {
      if ( (assignmentElement.attribute("actor-id")!=null)
           || (assignmentElement.attribute("pooled-actors")!=null)
         ) {
        task.setActorIdExpression(assignmentElement.attributeValue("actor-id"));
        task.setPooledActorsExpression(assignmentElement.attributeValue("pooled-actors"));
       
      } else {
        Delegation assignmentDelegation = readAssignmentDelegation(assignmentElement);
        task.setAssignmentDelegation(assignmentDelegation);
      }

    // if no assignment or swimlane is specified
    } else {
      // the user has to manage assignment manually, so we better warn him/her.
      addWarning("warning: no swimlane or assignment specified for task '"+taskElement.asXML()+"'");
    }
   
    // task controller
    Element taskControllerElement = taskElement.element("controller");
    if (taskControllerElement!=null) {
      task.setTaskController(readTaskController(taskControllerElement));
    }
   
    return task;
  }
View Full Code Here

    return variableAccesses;
  }

  public void readStartStateTask(Element startTaskElement, StartState startState) {
    TaskMgmtDefinition taskMgmtDefinition = processDefinition.getTaskMgmtDefinition();
    Task startTask = readTask(startTaskElement, taskMgmtDefinition, null);
    startTask.setStartState(startState);
    if (startTask.getName()==null) {
      startTask.setName(startState.getName());
    }
    taskMgmtDefinition.setStartTask(startTask);
  }
View Full Code Here

       ) {
      Iterator iter = taskMgmtDefinition.getSwimlanes().values().iterator();
      while (iter.hasNext()) {
        Swimlane swimlane = (Swimlane) iter.next();
       
        Task startTask = taskMgmtDefinition.getStartTask();
        Swimlane startTaskSwimlane = (startTask!=null ? startTask.getSwimlane() : null);
       
        if ( (swimlane.getAssignmentDelegation()==null)
             && (swimlane!=startTaskSwimlane)
           ) {
          addWarning("swimlane '"+swimlane.getName()+"' does not have an assignment");
View Full Code Here

TOP

Related Classes of org.jbpm.taskmgmt.def.Task

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.