Package org.activiti.engine

Examples of org.activiti.engine.TaskService


    variableMap.put("name", "Activiti");
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("AutoCompleteTask", variableMap);
    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());
   
    TaskService taskService = activitiRule.getTaskService();
    long count = taskService.createTaskQuery().count();
    assertEquals(0, count);
   
    Execution exec = runtimeService.createExecutionQuery().singleResult();
    System.out.println(exec.getActivityId());
  }
View Full Code Here


    variableMap.put("name", "Activiti");
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("ParallelGateway", variableMap);
    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());

    TaskService taskService = activitiRule.getTaskService();
    Task task = taskService.createTaskQuery().taskAssignee("user1").singleResult();
    taskService.complete(task.getId());

    Task task2 = taskService.createTaskQuery().taskCandidateUser("user2").singleResult();
    assertNotNull(task2);
    Task task3 = taskService.createTaskQuery().taskCandidateUser("user3").singleResult();
    assertNotNull(task3);

    taskService.complete(task2.getId());
    task2 = taskService.createTaskQuery().taskCandidateUser("user2").singleResult();
    assertNull(task2);

    taskService.complete(task3.getId());
    task3 = taskService.createTaskQuery().taskCandidateUser("user3").singleResult();
    assertNull(task3);

    task = taskService.createTaskQuery().taskAssignee("user1").singleResult();
    taskService.complete(task.getId());
   
    // 验证历史数据
    HistoryService historyService = activitiRule.getHistoryService();
    List<HistoricActivityInstance> list = historyService.createHistoricActivityInstanceQuery().list();
    for (HistoricActivityInstance activity : list) {
View Full Code Here

    variableMap.put("name", "Activiti");
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("ThrowException", variableMap);
    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());
   
    TaskService taskService = activitiRule.getTaskService();
    Task task = taskService.createTaskQuery().singleResult();
    try {
      taskService.complete(task.getId());
    } catch (RuntimeException e) {
     
      System.out.println("我捕获到了" + e.getMessage());
     
      Throwable cause = e.getCause();
View Full Code Here

    variableMap.put("name", "Activiti");
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process1", variableMap);
    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());
   
    TaskService taskService = activitiRule.getTaskService();
    assertEquals(1, taskService.createTaskQuery().taskCandidateUser("1").count());
    assertEquals(1, taskService.createTaskQuery().taskCandidateUser("2").count());
    assertEquals(1, taskService.createTaskQuery().taskCandidateUser("3").count());
    Task task = taskService.createTaskQuery().taskCandidateUser("1").list().get(0);
    taskService.claim(task.getId(), "1");
    assertEquals(1, taskService.createTaskQuery().taskAssignee("1").count());
    assertEquals(0, taskService.createTaskQuery().taskCandidateUser("1").count());
    assertEquals(0, taskService.createTaskQuery().taskCandidateUser("2").count());
    assertEquals(0, taskService.createTaskQuery().taskCandidateUser("3").count());
  }
View Full Code Here

    variableMap.put("name", "Activiti");
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("billing", variableMap);
    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());
   
    TaskService taskService = activitiRule.getTaskService();
    Task task = taskService.createTaskQuery().taskCandidateGroup("drawer").singleResult();
    taskService.claim(task.getId(), "aa");
   
    variableMap = new HashMap<String, Object>();
    variableMap.put("approved", true);
    taskService.complete(task.getId(), variableMap);
   
    HistoryService historyService = activitiRule.getHistoryService();
    long count = historyService.createHistoricProcessInstanceQuery().finished().count();
    assertEquals(1, count);
  }
View Full Code Here

    variableMap.put("name", "Activiti");
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("billing", variableMap);
    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());
   
    TaskService taskService = activitiRule.getTaskService();
    Task task = taskService.createTaskQuery().taskCandidateGroup("drawer").singleResult();
    taskService.claim(task.getId(), "aa");
   
    variableMap = new HashMap<String, Object>();
    variableMap.put("approved", false);
    variableMap.put("applyer", "bb");
    taskService.complete(task.getId(), variableMap);
   
    task = taskService.createTaskQuery().taskAssignee("bb").singleResult();
    variableMap = new HashMap<String, Object>();
    variableMap.put("reApply", false);
    taskService.complete(task.getId(), variableMap);
   
    HistoryService historyService = activitiRule.getHistoryService();
    long count = historyService.createHistoricProcessInstanceQuery().finished().count();
    assertEquals(1, count);
  }
View Full Code Here

    variableMap.put("name", "Activiti");
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("billing", variableMap);
    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());
   
    TaskService taskService = activitiRule.getTaskService();
    Task task = taskService.createTaskQuery().taskCandidateGroup("drawer").singleResult();
    taskService.claim(task.getId(), "aa");
   
    variableMap = new HashMap<String, Object>();
    variableMap.put("approved", false);
    variableMap.put("applyer", "bb");
    taskService.complete(task.getId(), variableMap);
   
    task = taskService.createTaskQuery().taskAssignee("bb").singleResult();
    variableMap = new HashMap<String, Object>();
    variableMap.put("reApply", true);
    taskService.complete(task.getId(), variableMap);
   
    task = taskService.createTaskQuery().taskCandidateGroup("drawer").singleResult();
    assertNotNull(task);
  }
View Full Code Here

  }

  public void click(ClickEvent event) {
    I18nManager i18nManager = ExplorerApp.get().getI18nManager();
    ViewManager viewManager = ExplorerApp.get().getViewManager();
    final TaskService taskService = ProcessEngines.getDefaultProcessEngine().getTaskService();
   
    ConfirmationDialogPopupWindow popup = new ConfirmationDialogPopupWindow(
            i18nManager.getMessage(Messages.TASK_CONFIRM_DELETE_SUBTASK, subTask.getName()));
    popup.addListener(new ConfirmationEventListener() {
      private static final long serialVersionUID = 1L;
      protected void rejected(ConfirmationEvent event) {
      }
      protected void confirmed(ConfirmationEvent event) {
        // delete subtask
        taskService.deleteTask(subTask.getId());
       
        // Refresh UI
        subTaskComponent.refreshSubTasks();
      }
    });
View Full Code Here

//    runtimeService.suspendProcessInstanceById(processInstance.getId());
    activitiRule.getRepositoryService().suspendProcessDefinitionById(processInstance.getProcessDefinitionId(), true, null);
    System.err.println("=============");
    long count = runtimeService.createProcessInstanceQuery().active().count();
    assertEquals(0, count);
    TaskService taskService = activitiRule.getTaskService();
    long count2 = taskService.createTaskQuery().active().count();
    assertEquals(0, count2);
   
    runtimeService.activateProcessInstanceById(processInstance.getId());
    count = runtimeService.createProcessInstanceQuery().active().count();
    assertEquals(1, count);
    count2 = taskService.createTaskQuery().active().count();
    assertEquals(1, count2);
  }
View Full Code Here

   
    variableMap.put("assigneeList", Arrays.asList("user1", "user2", "user3"));
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("MultiInstanceUseAssigneeList", variableMap);
    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());
    TaskService taskService = activitiRule.getTaskService();
    long count = taskService.createTaskQuery().count();
    assertEquals(count, 3);
    for (int i = 0; i < 3; i++) {
      long count2 = taskService.createTaskQuery().taskAssignee("user" + (i + 1)).count();
      assertEquals(count2, 1);
    }
  }
View Full Code Here

TOP

Related Classes of org.activiti.engine.TaskService

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.