Package org.activiti.engine.history

Examples of org.activiti.engine.history.HistoricTaskInstance


    assertEquals("Task with category", taskService.createTaskQuery().taskCategory(testCategory).singleResult().getName());
    assertTrue(taskService.createTaskQuery().taskCategory("Does not exist").count() == 0);
   
    if(processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) {
      // Check historic task
      HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(task.getId()).singleResult();
      assertEquals(testCategory, historicTaskInstance.getCategory());
      assertEquals("Task with category", historyService.createHistoricTaskInstanceQuery().taskCategory(testCategory).singleResult().getName());
      assertTrue(historyService.createHistoricTaskInstanceQuery().taskCategory("Does not exist").count() == 0);
     
      // Update category
      String newCategory = "New Test Category";
      task.setCategory(newCategory);
      taskService.saveTask(task);
     
      task = taskService.createTaskQuery().singleResult();
      assertEquals(newCategory, task.getCategory());
      assertEquals("Task with category", taskService.createTaskQuery().taskCategory(newCategory).singleResult().getName());
      assertTrue(taskService.createTaskQuery().taskCategory(testCategory).count() == 0);
     
      // Complete task and verify history
      taskService.complete(task.getId());
      historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(task.getId()).singleResult();
      assertEquals(newCategory, historicTaskInstance.getCategory());
      assertEquals("Task with category", historyService.createHistoricTaskInstanceQuery().taskCategory(newCategory).singleResult().getName());
      assertTrue(historyService.createHistoricTaskInstanceQuery().taskCategory(testCategory).count() == 0);
    }
  }
View Full Code Here


  }
 
  @Deployment
  public void testOrQuery() {
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
      HistoricTaskInstance task = historyService.createHistoricTaskInstanceQuery()
          .includeTaskLocalVariables()
          .or()
            .taskAssignee("gonzo")
          .endOr()
          .singleResult();
      Map<String, Object> variableMap = task.getTaskLocalVariables();
      assertEquals(2, variableMap.size());
      assertEquals(0, task.getProcessVariables().size());
      assertNotNull(variableMap.get("testVar"));
      assertEquals("someVariable", variableMap.get("testVar"));
      assertNotNull(variableMap.get("testVar2"));
      assertEquals(123, variableMap.get("testVar2"));
     
      List<HistoricTaskInstance> tasks = historyService.createHistoricTaskInstanceQuery().list();
      assertEquals(3, tasks.size());
     
      task = historyService.createHistoricTaskInstanceQuery()
          .includeProcessVariables()
          .or()
            .taskAssignee("gonzo")
            .taskVariableValueEquals("localVar", "nonExisting")
          .endOr()
          .singleResult();
      assertEquals(0, task.getProcessVariables().size());
      assertEquals(0, task.getTaskLocalVariables().size());
     
      Map<String, Object> startMap = new HashMap<String, Object>();
      startMap.put("processVar", true);
      runtimeService.startProcessInstanceByKey("oneTaskProcess", startMap);
     
      task = historyService.createHistoricTaskInstanceQuery()
          .includeProcessVariables()
          .or()
            .taskAssignee("kermit")
            .taskVariableValueEquals("localVar", "nonExisting")
          .endOr()
          .singleResult();
      assertEquals(1, task.getProcessVariables().size());
      assertEquals(0, task.getTaskLocalVariables().size());
      assertTrue((Boolean) task.getProcessVariables().get("processVar"));
     
      taskService.setVariable(task.getId(), "anotherProcessVar", 123);
      taskService.setVariableLocal(task.getId(), "localVar", "test");
     
      task = historyService.createHistoricTaskInstanceQuery()
          .includeTaskLocalVariables()
          .or()
            .taskAssignee("kermit")
            .taskVariableValueEquals("localVar", "nonExisting")
          .endOr()
          .singleResult();
      assertEquals(0, task.getProcessVariables().size());
      assertEquals(1, task.getTaskLocalVariables().size());
      assertEquals("test", task.getTaskLocalVariables().get("localVar"));
     
      task = historyService.createHistoricTaskInstanceQuery()
          .includeProcessVariables()
          .or()
            .taskAssignee("kermit")
            .taskVariableValueEquals("localVar", "nonExisting")
          .endOr()
          .singleResult();
      assertEquals(2, task.getProcessVariables().size());
      assertEquals(0, task.getTaskLocalVariables().size());
      assertEquals(true, task.getProcessVariables().get("processVar"));
      assertEquals(123, task.getProcessVariables().get("anotherProcessVar"));
     
      tasks = historyService.createHistoricTaskInstanceQuery().includeTaskLocalVariables()
          .or()
            .taskInvolvedUser("kermit")
            .taskVariableValueEquals("localVar", "nonExisting")
          .endOr()
          .orderByHistoricTaskInstanceStartTime().asc().list();
      assertEquals(3, tasks.size());
      assertEquals(1, tasks.get(0).getTaskLocalVariables().size());
      assertEquals("test", tasks.get(0).getTaskLocalVariables().get("test"));
      assertEquals(0, tasks.get(0).getProcessVariables().size());
     
      tasks = historyService.createHistoricTaskInstanceQuery().includeProcessVariables()
          .or()
            .taskInvolvedUser("kermit")
            .taskVariableValueEquals("localVar", "nonExisting")
          .endOr()
          .orderByHistoricTaskInstanceStartTime().asc().list();
      assertEquals(3, tasks.size());
      assertEquals(0, tasks.get(0).getProcessVariables().size());
      assertEquals(0, tasks.get(0).getTaskLocalVariables().size());
     
      task = historyService.createHistoricTaskInstanceQuery().includeTaskLocalVariables()
          .taskAssignee("kermit")
          .or()
            .taskVariableValueEquals("localVar", "test")
            .taskVariableValueEquals("localVar", "nonExisting")
          .endOr()
          .singleResult();
      assertEquals(0, task.getProcessVariables().size());
      assertEquals(1, task.getTaskLocalVariables().size());
      assertEquals("test", task.getTaskLocalVariables().get("localVar"));
     
      task = historyService.createHistoricTaskInstanceQuery().includeProcessVariables()
          .taskAssignee("kermit")
          .or()
            .taskVariableValueEquals("localVar", "test")
            .taskVariableValueEquals("localVar", "nonExisting")
          .endOr()
          .singleResult();
      assertEquals(2, task.getProcessVariables().size());
      assertEquals(0, task.getTaskLocalVariables().size());
      assertEquals(true, task.getProcessVariables().get("processVar"));
      assertEquals(123, task.getProcessVariables().get("anotherProcessVar"));
     
      task = historyService.createHistoricTaskInstanceQuery().includeTaskLocalVariables()
          .includeProcessVariables()
          .or()
            .taskAssignee("kermit")
            .taskVariableValueEquals("localVar", "nonExisting")
          .endOr()
          .singleResult();
      assertEquals(2, task.getProcessVariables().size());
      assertEquals(1, task.getTaskLocalVariables().size());
      assertEquals("test", task.getTaskLocalVariables().get("localVar"));
      assertEquals(true, task.getProcessVariables().get("processVar"));
      assertEquals(123, task.getProcessVariables().get("anotherProcessVar"));
     
      task = historyService.createHistoricTaskInstanceQuery()
          .taskAssignee("gonzo")
          .singleResult();
      taskService.complete(task.getId());
      task = historyService.createHistoricTaskInstanceQuery().includeTaskLocalVariables()
          .or()
            .finished()
            .taskVariableValueEquals("localVar", "nonExisting")
          .endOr()
          .singleResult();
      variableMap = task.getTaskLocalVariables();
      assertEquals(2, variableMap.size());
      assertEquals(0, task.getProcessVariables().size());
      assertNotNull(variableMap.get("testVar"));
      assertEquals("someVariable", variableMap.get("testVar"));
      assertNotNull(variableMap.get("testVar2"));
      assertEquals(123, variableMap.get("testVar2"));
    }
View Full Code Here

          .includeTaskLocalVariables()
          .orderByTaskPriority()
          .desc()
          .listPage(0, 1);
      assertEquals(1, tasks.size());
      HistoricTaskInstance task = tasks.get(0);
      Map<String, Object> variableMap = task.getTaskLocalVariables();
      assertEquals(2, variableMap.size());
      assertEquals("someVariable", variableMap.get("testVar"));
      assertEquals(123, variableMap.get("testVar2"));
     
      tasks = historyService.createHistoricTaskInstanceQuery()
          .includeProcessVariables()
          .includeTaskLocalVariables()
          .orderByTaskPriority()
          .asc()
          .listPage(1, 2);
      assertEquals(2, tasks.size());
      task = tasks.get(1);
      variableMap = task.getTaskLocalVariables();
      assertEquals(2, variableMap.size());
      assertEquals("someVariable", variableMap.get("testVar"));
      assertEquals(123, variableMap.get("testVar2"));
     
      tasks = historyService.createHistoricTaskInstanceQuery()
          .includeProcessVariables()
          .includeTaskLocalVariables()
          .orderByTaskPriority()
          .asc()
          .listPage(2, 4);
      assertEquals(1, tasks.size());
      task = tasks.get(0);
      variableMap = task.getTaskLocalVariables();
      assertEquals(2, variableMap.size());
      assertEquals("someVariable", variableMap.get("testVar"));
      assertEquals(123, variableMap.get("testVar2"));
     
      tasks = historyService.createHistoricTaskInstanceQuery()
View Full Code Here

 
  @Deployment(resources={"org/activiti/engine/test/api/task/TaskQueryTest.testProcessDefinition.bpmn20.xml"})
  public void testWithoutDueDateQuery() throws Exception {
    if(processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) {
      ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
      HistoricTaskInstance historicTask = historyService.createHistoricTaskInstanceQuery().processInstanceId(processInstance.getId()).withoutTaskDueDate().singleResult();
      assertNotNull(historicTask);
      assertNull(historicTask.getDueDate());
     
      // Set due-date on task
      Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
      Date dueDate = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss").parse("01/02/2003 01:12:13");
      task.setDueDate(dueDate);
View Full Code Here

    centralLayout.addComponent(descriptionLayout);
  }

  protected void initParentTaskLink() {
    if (historicTask.getParentTaskId() != null) {
      final HistoricTaskInstance parentTask = historyService.createHistoricTaskInstanceQuery()
        .taskId(historicTask.getParentTaskId())
        .singleResult();
       
      Button showParentTaskButton = new Button(i18nManager.getMessage(
              Messages.TASK_SUBTASK_OF_PARENT_TASK, parentTask.getName()));
      showParentTaskButton.addStyleName(Reindeer.BUTTON_LINK);
      showParentTaskButton.addListener(new ClickListener() {
        public void buttonClick(ClickEvent event) {
          viewManager.showTaskPage(parentTask.getId());
        }
      });
     
      centralLayout.addComponent(showParentTaskButton);
    }
View Full Code Here

    taskService.saveTask(task);  

    taskService.complete(task.getId());
    assertEquals(1, historyService.createHistoricTaskInstanceQuery().count());

    HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult();
    assertEquals("Updated name", historicTaskInstance.getName());
    assertEquals("Updated description", historicTaskInstance.getDescription());
    assertEquals("gonzo", historicTaskInstance.getAssignee());
    assertEquals("task", historicTaskInstance.getTaskDefinitionKey());

   
    // Validate fix of ACT-1923: updating assignee to null should be reflected in history
    ProcessInstance secondInstance = runtimeService.startProcessInstanceByKey("HistoricTaskInstanceTest");
   
    task = taskService.createTaskQuery().singleResult();
   
    task.setDescription(null);
    task.setName(null);
    task.setAssignee(null);
    taskService.saveTask(task);  

    taskService.complete(task.getId());
    assertEquals(1, historyService.createHistoricTaskInstanceQuery().processInstanceId(secondInstance.getId()).count());

    historicTaskInstance = historyService.createHistoricTaskInstanceQuery().processInstanceId(secondInstance.getId()).singleResult();
    assertNull(historicTaskInstance.getName());
    assertNull(historicTaskInstance.getDescription());
    assertNull(historicTaskInstance.getAssignee());
  }
View Full Code Here

  }
 
  @Override
  protected Component createDetailComponent(String id) {
    HistoryService historyService = ProcessEngines.getDefaultProcessEngine().getHistoryService();
    HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(id).singleResult();
    taskEventPanel.setTaskId(historicTaskInstance.getId());
    return new HistoricTaskDetailPanel(historicTaskInstance, this);
  }
View Full Code Here

  }
 
  @Deployment
  public void testQuery() {
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
      HistoricTaskInstance task = historyService.createHistoricTaskInstanceQuery().includeTaskLocalVariables().taskAssignee("gonzo").singleResult();
      Map<String, Object> variableMap = task.getTaskLocalVariables();
      assertEquals(2, variableMap.size());
      assertEquals(0, task.getProcessVariables().size());
      assertNotNull(variableMap.get("testVar"));
      assertEquals("someVariable", variableMap.get("testVar"));
      assertNotNull(variableMap.get("testVar2"));
      assertEquals(123, variableMap.get("testVar2"));
     
      List<HistoricTaskInstance> tasks = historyService.createHistoricTaskInstanceQuery().list();
      assertEquals(3, tasks.size());
     
      task = historyService.createHistoricTaskInstanceQuery().includeProcessVariables().taskAssignee("gonzo").singleResult();
      assertEquals(0, task.getProcessVariables().size());
      assertEquals(0, task.getTaskLocalVariables().size());
     
      Map<String, Object> startMap = new HashMap<String, Object>();
      startMap.put("processVar", true);
      runtimeService.startProcessInstanceByKey("oneTaskProcess", startMap);
     
      task = historyService.createHistoricTaskInstanceQuery().includeProcessVariables().taskAssignee("kermit").singleResult();
      assertEquals(1, task.getProcessVariables().size());
      assertEquals(0, task.getTaskLocalVariables().size());
      assertTrue((Boolean) task.getProcessVariables().get("processVar"));
     
      taskService.setVariable(task.getId(), "anotherProcessVar", 123);
      taskService.setVariableLocal(task.getId(), "localVar", "test");
     
      task = historyService.createHistoricTaskInstanceQuery().includeTaskLocalVariables().taskAssignee("kermit").singleResult();
      assertEquals(0, task.getProcessVariables().size());
      assertEquals(1, task.getTaskLocalVariables().size());
      assertEquals("test", task.getTaskLocalVariables().get("localVar"));
     
      task = historyService.createHistoricTaskInstanceQuery().includeProcessVariables().taskAssignee("kermit").singleResult();
      assertEquals(2, task.getProcessVariables().size());
      assertEquals(0, task.getTaskLocalVariables().size());
      assertEquals(true, task.getProcessVariables().get("processVar"));
      assertEquals(123, task.getProcessVariables().get("anotherProcessVar"));
     
      tasks = historyService.createHistoricTaskInstanceQuery().includeTaskLocalVariables().taskInvolvedUser("kermit").orderByHistoricTaskInstanceStartTime().asc().list();
      assertEquals(3, tasks.size());
      assertEquals(1, tasks.get(0).getTaskLocalVariables().size());
      assertEquals("test", tasks.get(0).getTaskLocalVariables().get("test"));
      assertEquals(0, tasks.get(0).getProcessVariables().size());
     
      tasks = historyService.createHistoricTaskInstanceQuery().includeProcessVariables().taskInvolvedUser("kermit").orderByHistoricTaskInstanceStartTime().asc().list();
      assertEquals(3, tasks.size());
      assertEquals(0, tasks.get(0).getProcessVariables().size());
      assertEquals(0, tasks.get(0).getTaskLocalVariables().size());
     
      task = historyService.createHistoricTaskInstanceQuery().includeTaskLocalVariables().taskAssignee("kermit").taskVariableValueEquals("localVar", "test").singleResult();
      assertEquals(0, task.getProcessVariables().size());
      assertEquals(1, task.getTaskLocalVariables().size());
      assertEquals("test", task.getTaskLocalVariables().get("localVar"));
     
      task = historyService.createHistoricTaskInstanceQuery().includeProcessVariables().taskAssignee("kermit").taskVariableValueEquals("localVar", "test").singleResult();
      assertEquals(2, task.getProcessVariables().size());
      assertEquals(0, task.getTaskLocalVariables().size());
      assertEquals(true, task.getProcessVariables().get("processVar"));
      assertEquals(123, task.getProcessVariables().get("anotherProcessVar"));
     
      task = historyService.createHistoricTaskInstanceQuery().includeTaskLocalVariables().includeProcessVariables().taskAssignee("kermit").singleResult();
      assertEquals(2, task.getProcessVariables().size());
      assertEquals(1, task.getTaskLocalVariables().size());
      assertEquals("test", task.getTaskLocalVariables().get("localVar"));
      assertEquals(true, task.getProcessVariables().get("processVar"));
      assertEquals(123, task.getProcessVariables().get("anotherProcessVar"));
     
      task = historyService.createHistoricTaskInstanceQuery().taskAssignee("gonzo").singleResult();
      taskService.complete(task.getId());
      task = (HistoricTaskInstance) historyService.createHistoricTaskInstanceQuery().includeTaskLocalVariables().finished().singleResult();
      variableMap = task.getTaskLocalVariables();
      assertEquals(2, variableMap.size());
      assertEquals(0, task.getProcessVariables().size());
      assertNotNull(variableMap.get("testVar"));
      assertEquals("someVariable", variableMap.get("testVar"));
      assertNotNull(variableMap.get("testVar2"));
      assertEquals(123, variableMap.get("testVar2"));
    }
View Full Code Here

   
    // Validate history
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
      List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery().orderByTaskAssignee().asc().list();
      for (int i=0; i<historicTaskInstances.size(); i++) {
        HistoricTaskInstance hi = historicTaskInstances.get(i);
        assertNotNull(hi.getStartTime());
        assertNotNull(hi.getEndTime());
        assertEquals("kermit_"+i, hi.getAssignee());
      }
     
      List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().activityType("userTask").list();
      assertEquals(3, historicActivityInstances.size());
      for (HistoricActivityInstance hai : historicActivityInstances) {
View Full Code Here

              if (historicTaskInstances.isEmpty()) {
                continue;
              }

              // 查询有办理人的历史任务
              HistoricTaskInstance historySameKeyTask = null;
              for (HistoricTaskInstance historicTaskInstance : historicTaskInstances) {
                if (historicTaskInstance.getAssignee() != null) {
                  historySameKeyTask = historicTaskInstance;
                  break;
                }
              }

              // 如果这条任务已经办理过由系统自动签收分配给上一次办理的人
              if (historySameKeyTask != null && StringUtils.isNotBlank(historySameKeyTask.getAssignee())) {
                String lastAssignee = historySameKeyTask.getAssignee();
                taskService.claim(task.getId(), lastAssignee);
              }
             
            }
          }
View Full Code Here

TOP

Related Classes of org.activiti.engine.history.HistoricTaskInstance

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.