Package org.activiti.engine.task

Examples of org.activiti.engine.task.Task


            if (tasksForUser.isEmpty()) {
                throw new WorkflowException(new RuntimeException(username + " is not candidate for task " + taskId));
            }
        }

        Task task;
        try {
            taskService.setOwner(taskId, username);
            task = taskService.createTaskQuery().taskId(taskId).singleResult();
        } catch (ActivitiException e) {
            throw new WorkflowException(e);
View Full Code Here


    assertTrue(tasks.isEmpty());

    // The task should be visible in the candidate task list
    tasks = taskService.createTaskQuery().taskCandidateUser(KERMIT).list();
    assertEquals(1, tasks.size());
    Task task = tasks.get(0);
    assertEquals("Pay out expenses", task.getName());

    // Claim the task
    taskService.claim(task.getId(), KERMIT);

    // The task must now be gone from the candidate task list
    tasks = taskService.createTaskQuery().taskCandidateUser(KERMIT).list();
    assertTrue(tasks.isEmpty());

    // The task will be visible on the personal task list
    tasks = taskService
      .createTaskQuery()
      .taskAssignee(KERMIT)
      .list();
    assertEquals(1, tasks.size());
    task = tasks.get(0);
    assertEquals("Pay out expenses", task.getName());

    // Completing the task ends the process
    taskService.complete(task.getId());

    assertNull("Process ended", activitiRule
               .getRuntimeService()
               .createProcessInstanceQuery()
               .processInstanceId(processInstance.getId())
View Full Code Here

    assertEquals(1, taskService.createTaskQuery().taskCandidateGroup("accountancy").count());
    assertEquals(0, taskService.createTaskQuery().taskCandidateGroup("sales").count());

    // Gonzo claims the task
    tasks = taskService.createTaskQuery().taskCandidateUser(GONZO).list();
    Task task = tasks.get(0);
    assertEquals("Approve expenses", task.getName());
    taskService.claim(task.getId(), GONZO);

    // The task must now be gone from the candidate task lists
    assertTrue(taskService.createTaskQuery().taskCandidateUser(KERMIT).list().isEmpty());
    assertTrue(taskService.createTaskQuery().taskCandidateUser(GONZO).list().isEmpty());
    assertEquals(0, taskService.createTaskQuery().taskCandidateGroup("management").count());

    // The task will be visible on the personal task list of Gonzo
    assertEquals(1, taskService
      .createTaskQuery()
      .taskAssignee(GONZO)
      .count());

    // But not on the personal task list of (for example) Kermit
    assertEquals(0, taskService.createTaskQuery().taskAssignee(KERMIT).count());

    // Completing the task ends the process
    taskService.complete(task.getId());

    assertNull("Process ended", activitiRule
               .getRuntimeService()
               .createProcessInstanceQuery()
               .processInstanceId(processInstance.getId())
View Full Code Here

    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("financialReport");
   
    TaskService taskService = activitiRule.getTaskService();
    List<Task> tasks = taskService.createTaskQuery().taskCandidateUser("fozzie").list();
    assertEquals(1, tasks.size());
    Task task = tasks.get(0);
    assertEquals("Write monthly financial report", task.getName());
   
    taskService.claim(task.getId(), "fozzie");
    tasks = taskService
      .createTaskQuery()
      .taskAssignee("fozzie")
      .list();
   
    assertEquals(1, tasks.size());
    taskService.complete(task.getId());

    tasks = taskService.createTaskQuery().taskCandidateUser("fozzie").list();
    assertEquals(0, tasks.size());
    tasks = taskService.createTaskQuery().taskCandidateUser("kermit").list();
    assertEquals(1, tasks.size());
View Full Code Here

    List<Task> tasks = taskService
      .createTaskQuery()
      .taskAssignee("kermit")
      .list();
    assertEquals(1, tasks.size());
    Task myTask = tasks.get(0);
    assertEquals("Schedule meeting", myTask.getName());
    assertEquals("Schedule an engineering meeting for next week with the new hire.", myTask.getDescription());

    // Complete task. Process is now finished
    taskService.complete(myTask.getId());
    // assert if the process instance completed
    assertNull("Process ended", activitiRule
               .getRuntimeService()
               .createProcessInstanceQuery()
               .processInstanceId(processInstance.getId())
View Full Code Here

  @Test
  public void testCreateToComplete() {

    // Create and save task
    TaskService taskService = activitiRule.getTaskService();
    Task task = taskService.newTask();
    task.setName("testTask");
    taskService.saveTask(task);
    String taskId = task.getId();

    // Add user as candidate user
    taskService.addCandidateUser(taskId, "kermit");
    taskService.addCandidateUser(taskId, "gonzo");
View Full Code Here

        return processEntity;
    }
   
  @Override
  public boolean isProcessForGivenTaskActive(String taskId) {
    Task activeTask = this.getTaskById(taskId);
    long size = runtimeService.createProcessInstanceQuery()
        .processInstanceId(activeTask.getProcessInstanceId()).count();
    return size == 0 ? false : true;
 
View Full Code Here

    @Override
    public void cancelAllPendingTasksByTaskTrigger(String procId, String deletingTaskId) {
      List<Task> pendingTasks = readAllPendingTasksForProcessInstance(procId);
      Iterator<Task> it = pendingTasks.iterator();
      while(it.hasNext()) {
        Task currentTask = it.next();
        if (!currentTask.getId().equals(deletingTaskId)) {
          taskService.setAssignee(currentTask.getId(), PROCESS_DELETE);
            /* second argument indicates that task historic instance should
               be also deleted along with runtime instance
            */
          taskService.deleteTask(currentTask.getId(), true);
        }
      }
    }
View Full Code Here

   
  public List<SolutionTaskInboxData> constructInboxDataList(List<Task> tasks, Locale currentLocale) {
    List<SolutionTaskInboxData> inboxList = new ArrayList<SolutionTaskInboxData>();
    Iterator<Task> taskIt = tasks.iterator();
    while(taskIt.hasNext()) {
      Task taskRecord = taskIt.next();
      Solution linkedSolution = solutionService.findEntityByProcessId(taskRecord.getProcessInstanceId());
      SolutionTaskInboxData inboxData = new SolutionTaskInboxData(linkedSolution, taskRecord, messageSource, currentLocale);
      inboxList.add(inboxData);
    }
    return inboxList;
  }
View Full Code Here

  @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  public String showTask(@PathVariable("id") String id,
      @RequestParam(value = TASK_HISTORY_PARAM, required = true) Boolean historyParam,
      @RequestParam(value = PROC_ID, required = true) String procId, Model model,
      HttpServletRequest request) throws TaskHandlerException {
        Task currentTask = null;
        HistoricTaskInstance historyTask = null;
        IProcessEntity linkedObject = getLinkedObject(procId);
        if (Boolean.FALSE.equals(historyParam)) {
          request.setAttribute(TASK_HISTORY_PARAM, false);
            currentTask = getCurrentTask(id);
            // living task instance requested, but already completed by other actor
            if (currentTask == null) {
              historyTask = getHistoryTask(id);
              if (historyTask != null) {
                // force historic view with additional info, who and when already completed task
                request.setAttribute(TASK_HISTORY_PARAM, true);
                Object[] arguments = new Object[2];
                arguments[0] = historyTask.getAssignee();
                arguments[1] = new SimpleDateFormat(InfrastructureConstants.ISO_DATE_TIME_FORMAT)
                  .format(historyTask.getEndTime());
                model.addAttribute(MODEL_ATTR_TASK_COMPLETED,
                  messageSource.getMessage(InfrastructureConstants.TASK_ALREADY_COMPLETED,
              arguments, InfrastructureConstants.UNDEFINED_MESSAGE, request.getLocale()));
              } else {
                // there is not living, nor historic instance, task is non existing / was deleted
                request.getSession()
                  .setAttribute(InfrastructureConstants.SESSION_ATTR_FROM_NON_EXISTING_TASK, true);
                return "redirect:/" + getLinkedObjectViewPath() +
                    WebUtil.encodeUrlPathSegment(linkedObject.getId().toString(),
                    request);
              }
          }
        } else {
          request.setAttribute(TASK_HISTORY_PARAM, true);
          historyTask = getHistoryTask(id);
        }
    String taskName = currentTask != null ? currentTask.getName() : historyTask.getName();
    // taskId is the same for active or history process task
    String taskId = currentTask != null ? currentTask.getId() : historyTask.getId();
    if (Boolean.FALSE.equals(historyParam)) {
      request.getSession().setAttribute(SESSION_ATTR_TASK_ID, taskId);
      request.getSession().setAttribute(SESSION_ATTR_PROC_ID, procId);
    }
    String path = UNDEFINED_TASK; // unknown task type
View Full Code Here

TOP

Related Classes of org.activiti.engine.task.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.