Package org.activiti.engine

Examples of org.activiti.engine.TaskService


    RuntimeService runtimeService = activitiRule.getRuntimeService();
    Map<String, Object> variableMap = new HashMap<String, Object>();
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process1", variableMap);
    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());
    TaskService taskService = activitiRule.getTaskService();
    assertEquals(3, taskService.createTaskQuery().taskAssignee("henryyan").count());
    Task task = taskService.createTaskQuery().taskAssignee("henryyan").listPage(0, 1).get(0);

    ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService)
            .getDeployedProcessDefinition(processInstance.getProcessDefinitionId());
    List<ActivityImpl> activitiList = processDefinition.getActivities();

    for (ActivityImpl activity : activitiList) {
      ActivityBehavior activityBehavior = activity.getActivityBehavior();
      boolean multiinstance = false;
      if (activityBehavior instanceof MultiInstanceActivityBehavior) {
        multiinstance = true;
      }
      System.out.println(String.format("activiti id: %s, behavior type: %s, multiinstance: %b", activity.getId(), activityBehavior, multiinstance));
    }

    taskService.complete(task.getId());

    task = taskService.createTaskQuery().taskAssignee("henryyan").listPage(0, 1).get(0);
    taskService.complete(task.getId());
  }
View Full Code Here


  @Test
  public void startProcess() throws Exception {
    IdentityService identityService = activitiRule.getIdentityService();
    identityService.setAuthenticatedUserId("henryyan");
    RepositoryService repositoryService = activitiRule.getRepositoryService();
    TaskService taskService = activitiRule.getTaskService();
    repositoryService.createDeployment().addInputStream("process1.bpmn20.xml", new FileInputStream(filename)).deploy();
    RuntimeService runtimeService = activitiRule.getRuntimeService();
    Map<String, Object> variableMap = new HashMap<String, Object>();
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process1", variableMap);
    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());

    HistoryService historyService = activitiRule.getHistoryService();
    List<HistoricProcessInstance> list2 = historyService.createHistoricProcessInstanceQuery().startedBy("henryyan").list();
    assertEquals(false, list2.isEmpty());

    Task task = taskService.createTaskQuery().taskAssignee("henryyan").singleResult();
    taskService.complete(task.getId());

    List<HistoricProcessInstance> list = historyService.createHistoricProcessInstanceQuery().finished().list();
    assertEquals(false, list.isEmpty());

    list2 = historyService.createHistoricProcessInstanceQuery().startedBy("henryyan").list();
View Full Code Here

            "process1", variableMap);
    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " "
            + processInstance.getProcessDefinitionId());

    TaskService taskService = activitiRule.getTaskService();
    long count = taskService.createTaskQuery().taskCandidateUser("user1")
            .count();
    assertEquals(1, count);
  }
View Full Code Here

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

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

    TaskService taskService = activitiRule.getTaskService();

    Task task = taskService.createTaskQuery().singleResult();
    assertNull(task.getAssignee());

    // 签收
    taskService.claim(task.getId(), "user1");
    task = taskService.createTaskQuery().singleResult();
    assertNull(task.getOwner());
    assertNotNull(task.getAssignee());

    // 委派
    taskService.delegateTask(task.getId(), "henryyan");
   
    task = taskService.createTaskQuery().singleResult();
    assertEquals("user1", task.getOwner());

    // 查询被委派的任务
    task = taskService.createTaskQuery().taskAssignee("henryyan").taskDelegationState(DelegationState.PENDING).singleResult();
    assertNotNull(task);

    // 被委派人完成任务
    taskService.resolveTask(task.getId());
   
    // 查询已完成的委派任务
    task = taskService.createTaskQuery().taskDelegationState(DelegationState.RESOLVED).singleResult();
    assertNotNull(task);
    assertEquals("user1", task.getAssignee());
    assertEquals("user1", task.getOwner());
    //    taskService.complete(task.getId(), Collections.singletonMap("taskTwoAssignee", "user2"));
  }
View Full Code Here

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

    TaskService taskService = activitiRule.getTaskService();
    Map<String, Object> vars = new HashMap<String, Object>();

    // 签收并完成第一个任务
    Task task = taskService.createTaskQuery().singleResult();
    taskService.claim(task.getId(), "user1");
    vars.put("taskTwoAssignee", "user2");
    taskService.complete(task.getId(), vars);

    // 完成第二个任务
    Task task2 = taskService.createTaskQuery().taskAssignee("user2").singleResult();
    vars = new HashMap<String, Object>();
    vars.put("pass", false);
    taskService.complete(task2.getId(), vars);

    // 验证任务回到第一个节点
    Task taskOne = taskService.createTaskQuery().taskName("Task One").singleResult();
    assertNotNull(taskOne);

    // 自动签收
    autoClaim(processInstance.getId());

    // 验证是否已自动签收
    taskOne = taskService.createTaskQuery().taskName("Task One").taskAssignee("user1").singleResult();
    assertNotNull(taskOne);
  }
View Full Code Here

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

    // task 1111111
    TaskService taskService = activitiRule.getTaskService();
    Task task111111 = taskService.createTaskQuery().taskName("11111").singleResult();
    taskService.complete(task111111.getId());

    // 两个并行任务
    long count = taskService.createTaskQuery().count();
    assertEquals(2, count);

    // 完成任务:22222222,回到任务11111
    Task task22222222 = taskService.createTaskQuery().taskName("22222222").singleResult();
    variableMap = new HashMap<String, Object>();
    variableMap.put("type", "back");
    taskService.complete(task22222222.getId(), variableMap);

    // 统计任务数量
    count = taskService.createTaskQuery().count();
    assertEquals(2, count);

    // 再次完成任务111111
    task111111 = taskService.createTaskQuery().taskName("11111").singleResult();
    taskService.complete(task111111.getId());

    count = taskService.createTaskQuery().count();
    assertEquals(3, count);
   
    // 清理未完成的流程,避免影响其他测试方法
    runtimeService.deleteProcessInstance(processInstance.getId(), "");
    HistoryService historyService = activitiRule.getHistoryService();
View Full Code Here

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

    // task 1111111
    TaskService taskService = activitiRule.getTaskService();
    Task task111111 = taskService.createTaskQuery().taskName("11111").singleResult();
    taskService.complete(task111111.getId());

    // 两个并行任务
    long count = taskService.createTaskQuery().count();
    assertEquals(2, count);

    // 完成任务:22222222,回到任务11111
    Task task22222222 = taskService.createTaskQuery().taskName("22222222").singleResult();
    variableMap = new HashMap<String, Object>();
    variableMap.put("type", "back");
    taskService.complete(task22222222.getId(), variableMap);

    // 统计任务数量
    count = taskService.createTaskQuery().count();
    assertEquals(1, count);

    // 再次完成任务111111
    task111111 = taskService.createTaskQuery().taskName("11111").singleResult();
    taskService.complete(task111111.getId());

    count = taskService.createTaskQuery().count();
    assertEquals(2, count);
  }
View Full Code Here

    }

    List<ProcessInstance> list2 = runtimeService.createProcessInstanceQuery().processDefinitionKey("process1").list();
    System.out.println("processInstance.size=" + list2.size());

    TaskService taskService = activitiRule.getTaskService();
    Task task = taskService.createTaskQuery().singleResult();
    System.out.println("tid=" + task.getId() + "\t eid=" + task.getExecutionId() + "\t pid=" + task.getProcessInstanceId());
    taskService.complete(task.getId());

    task = taskService.createTaskQuery().singleResult();
    System.out.println("tid=" + task.getId() + "\t eid=" + task.getExecutionId() + "\t pid=" + task.getProcessInstanceId());
    taskService.complete(task.getId());

    // one,two,three
    List<Task> list3 = taskService.createTaskQuery().list();
    assertEquals(3, list3.size());
    for (Task task2 : list3) {
      System.out.println(task2.getAssignee());
    }
/*    assertEquals("one", list3.get(0).getAssignee());
View Full Code Here

    Map<String, Object> variableMap = new HashMap<String, Object>();
    variableMap.put("name", "Activiti");
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("NoUserSet", variableMap);
    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());
    TaskService taskService = activitiRule.getTaskService();
    Task task = taskService.createTaskQuery().singleResult();
    variableMap = new HashMap<String, Object>();
    variableMap.put("task2Users", new ArrayList<String>());
    taskService.complete(task.getId(), variableMap);
   
    task = taskService.createTaskQuery().singleResult();
    variableMap = new HashMap<String, Object>();
    variableMap.put("multiUsers", new ArrayList<String>());
    taskService.complete(task.getId(), variableMap);
   
   
    HistoryService historyService = activitiRule.getHistoryService();
    long count = historyService.createHistoricProcessInstanceQuery().finished().count();
    assertEquals(1, count);
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.