Example #1
0
 @Test
 public void testSetAssignee() {
   ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
   IdentityService identityService = engine.getIdentityService();
   User user = creatUser(identityService, "user1", "张三", "last", "*****@*****.**", "123");
   TaskService taskService = engine.getTaskService();
   Task task1 = taskService.newTask("task1");
   task1.setName("申请任务");
   taskService.saveTask(task1);
   taskService.setAssignee(task1.getId(), user.getId());
   System.out.println(
       "用户张三受理的任务数量:" + taskService.createTaskQuery().taskAssignee(user.getId()).count());
 }
 /**
  * 会签操作
  *
  * @param taskId 当前任务ID
  * @param userCodes 会签人账号集合
  * @throws Exception
  */
 @Override
 public void jointProcess(String taskId, List<String> userCodes) throws Exception {
   for (String userCode : userCodes) {
     TaskEntity task = (TaskEntity) taskService.newTask(UUIDGenerator.generate(userCode));
     task.setAssignee(userCode);
     task.setName(findTaskById(taskId).getName() + "-会签");
     task.setProcessDefinitionId(findProcDefEntityByTaskId(taskId).getId());
     task.setProcessInstanceId(findProcInsByTaskId(taskId).getId());
     task.setParentTaskId(taskId);
     task.setDescription("jointProcess");
     taskService.saveTask(task);
   }
 }
Example #3
0
File: MyTask.java Project: mouge/pa
  public String getTask() {

    // Create and save task
    Task task = taskService.newTask();
    task.setName("test.....Task......(mouge)");
    taskService.saveTask(task);
    String taskId = task.getId();

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

    // Retrieve task list for jbarrez
    List<Task> tasks = taskService.createTaskQuery().taskCandidateUser("kermit").list();
    System.out.printf("kermit has %d task\n", tasks.size());
    return (tasks.get(0).getName());

    // Retrieve task list for tbaeyens
    /*tasks = taskService.createTaskQuery().taskCandidateUser("gonzo").list();
    System.out.printf("gonzo has %d task", tasks.size());
    System.out.printf("gonzo'task is %s", tasks.get(0).getName());

    // Claim task
    taskService.claim(taskId, "kermit");

    // Tasks shouldn't appear in the candidate tasklists anymore
    if (taskService.createTaskQuery().taskCandidateUser("kermit").list().isEmpty())
    	System.out.print("kermit's task is empty");
    if (taskService.createTaskQuery().taskCandidateUser("gonzo").list().isEmpty())
    	System.out.print("gonzo's task is empty");

    // Complete task
    taskService.deleteTask(taskId, true);

    // Task should be removed from runtime data
    // TODO: check for historic data when implemented!
    if (taskService.createTaskQuery().taskId(taskId).singleResult() == null)
    	System.out.print("task is empty");*/
  }
  protected void handleFormSubmit() {
    try {
      // Check for errors
      form.commit(); // will throw exception in case validation is false

      // Create task
      Task task = taskService.newTask();
      task.setName(nameField.getValue().toString());
      task.setDescription(descriptionArea.getValue().toString());
      task.setDueDate((Date) dueDateField.getValue());
      task.setPriority(priorityComboBox.getPriority());
      task.setOwner(ExplorerApp.get().getLoggedInUser().getId());
      taskService.saveTask(task);

      // close popup and navigate to new group
      close();
      ExplorerApp.get().getViewManager().showTasksPage(task.getId());

    } catch (InvalidValueException e) {
      // Do nothing: the Form component will render the errormsgs automatically
      setHeight(350, UNITS_PIXELS);
    }
  }