Package org.jbpm.taskmgmt.def

Examples of org.jbpm.taskmgmt.def.Task


   * 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();
    if (startTask != null)
    {
      Token rootToken = processInstance.getRootToken();
      ExecutionContext executionContext = new ExecutionContext(rootToken);
      taskInstance = createTaskInstance(startTask, executionContext);
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);
    }

    // get the task description
    String description = taskElement.elementTextTrim("description");
    if (description != null)
    {
      task.setDescription(description);
    }
    else
    {
      task.setDescription(taskElement.attributeValue("description"));
    }

    // get the condition
    String condition = taskElement.elementTextTrim("condition");
    if (condition != null)
    {
      task.setCondition(condition);
    }
    else
    {
      task.setCondition(taskElement.attributeValue("condition"));
    }

    // parse common subelements
    readTaskTimers(taskElement, task);
    readEvents(taskElement, task);
    readExceptionHandlers(taskElement, task);

    // duedate and priority
    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 inform him/her.
      log.info("process xml information: no swimlane or assignment specified for task '" + taskElement.asXML() + "'");
    }

    // notify
    String notificationsText = taskElement.attributeValue("notify");
    if (notificationsText != null
        && ("true".equalsIgnoreCase(notificationsText) || "on".equalsIgnoreCase(notificationsText) || "yes".equalsIgnoreCase(notificationsText)))
    {
      String notificationEvent = Event.EVENTTYPE_TASK_ASSIGN;
      Event event = task.getEvent(notificationEvent);
      if (event == null)
      {
        event = new Event(notificationEvent);
        task.addEvent(event);
      }
      Delegation delegation = createMailDelegation(notificationEvent, null, null, null, null);
      Action action = new Action(delegation);
      action.setProcessDefinition(processDefinition);
      action.setName(task.getName());
      event.addAction(action);
    }

    // task controller
    Element taskControllerElement = taskElement.element("controller");
    if (taskControllerElement != null)
    {
      task.setTaskController(readTaskController(taskControllerElement));
    }

    return task;
  }
View Full Code Here

  }

  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

    TaskMgmtDefinition taskMgmtDefinition = processDefinition.getTaskMgmtDefinition();
    if ((taskMgmtDefinition != null) && (taskMgmtDefinition.getSwimlanes() != null))
    {
      for (Swimlane swimlane : taskMgmtDefinition.getSwimlanes().values())
      {
        Task startTask = taskMgmtDefinition.getStartTask();
        Swimlane startTaskSwimlane = (startTask != null ? startTask.getSwimlane() : null);

        if ((swimlane.getAssignmentDelegation() == null)
             && (swimlane.getActorIdExpression()==null)
             && (swimlane.getPooledActorsExpression()==null)
             && (swimlane != startTaskSwimlane))
View Full Code Here

    while (iter.hasNext())
    {
      TaskInstance ti = iter.next();

      // find new task
      Task oldTask = ti.getTask();
      Node oldNode = oldTask.getTaskNode();
     
      Task newTask = findReplacementTask(newDef, oldNode, oldTask);
      ti.setTask(newTask);
      log.debug("change dependent task-instance with id " + oldTask.getId());
    }
  }
View Full Code Here

        if (timer.getGraphElement()!=null) {
         
          // and change the reference (take name mappings into account!)
          if (timer.getGraphElement() instanceof Task) {
            // change to new task definition
            Task oldTask = (Task)timer.getGraphElement();
            TaskNode oldNode =  oldTask.getTaskNode();
            timer.setGraphElement(
                findReplacementTask(newDef, oldNode, oldTask));
          }
          else {
            // change to new node
View Full Code Here

   
    Query q = getJbpmContext().getSession().getNamedQuery("TaskMgmtSession.findTaskForNode");
    q.setString("taskName", replacementTaskName);
    q.setLong("taskNodeId", newTaskNode.getId());

    Task newTask = (Task)q.uniqueResult();   
    if (newTask == null)
    {
      throw new JbpmException("Task '" + replacementTaskName + "' for node '" + newTaskNode.getName() + "' not found in new process definition");
    }
    return newTask;
View Full Code Here

    processDefinition.addDefinition(taskMgmtDefinition);
    buyer = new Swimlane("buyer");
    taskMgmtDefinition.addSwimlane(buyer);
    seller = new Swimlane("seller");
    taskMgmtDefinition.addSwimlane(seller);
    laundry = new Task("laundry");
    taskMgmtDefinition.addTask(laundry);
    dishes = new Task("dishes");
    taskMgmtDefinition.addTask(dishes);
   
    graphSession.saveProcessDefinition(processDefinition);
   
    processInstance = new ProcessInstance(processDefinition);
View Full Code Here

    assertEquals(0, getNbrOfTasks(token));
  }

  private void addOneTask(Token token) {
    TaskMgmtDefinition tmd = (TaskMgmtDefinition) processDefinition.getDefinition(TaskMgmtDefinition.class);
    Task task = tmd.getTask("watch movie amadeus");
   
    TaskMgmtInstance tmi = token.getProcessInstance().getTaskMgmtInstance();
    tmi.createTaskInstance(task, token);
  }
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

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.