Ejemplo n.º 1
0
  /** 历史节点. */
  public Page findHistoricActivityInstances(String tenantId, Page page) {
    HistoryService historyService = processEngine.getHistoryService();

    long count =
        historyService.createHistoricActivityInstanceQuery().activityTenantId(tenantId).count();
    List<HistoricActivityInstance> historicActivityInstances =
        historyService
            .createHistoricActivityInstanceQuery()
            .activityTenantId(tenantId)
            .listPage((int) page.getStart(), page.getPageSize());
    page.setResult(historicActivityInstances);
    page.setTotalCount(count);

    return page;
  }
Ejemplo n.º 2
0
  public String listHistoricActivityInstances() {
    HistoryService historyService = processEngine.getHistoryService();

    historicActivityInstances = historyService.createHistoricActivityInstanceQuery().list();

    return "listHistoricActivityInstances";
  }
Ejemplo n.º 3
0
  @Test
  @Deployment(resources = {PROCESS_RESOURCE})
  public void processRejected() throws InterruptedException {
    Map<String, Object> procVars = createStartFormVariables();

    ProcessInstance pi =
        activitiRule
            .getProcessEngine()
            .getRuntimeService()
            .startProcessInstanceByKey(PROCESS_KEY, procVars);

    //		assertNotNull(pi);

    Task task = activitiRule.getTaskService().createTaskQuery().singleResult();
    //		assertNotNull(task);

    Map<String, Object> taskVars = new HashMap<String, Object>();
    taskVars.put("decide", "reject");
    activitiRule.getProcessEngine().getTaskService().complete(task.getId(), taskVars);

    HistoryService historyService = activitiRule.getHistoryService();

    HistoricProcessInstance historicProcessInstance =
        historyService
            .createHistoricProcessInstanceQuery()
            .processInstanceId(pi.getProcessInstanceId())
            .singleResult();

    //		assertNotNull(historicProcessInstance);
    // check that only one process running
    //		assertEquals(pi.getProcessInstanceId(), historicProcessInstance.getId());

    List<HistoricActivityInstance> activityList =
        historyService
            .createHistoricActivityInstanceQuery()
            .processInstanceId(pi.getProcessInstanceId())
            .list();

    JobQuery jquery = activitiRule.getManagementService().createJobQuery();

    // check how many tasks must be done
    //		assertEquals("done task count", 6, activityList.size());

    // and the job is done
    //		assertEquals("job is done", 0, jquery.count());

    //		assertEquals(0, activitiRule.getProcessEngine().getRuntimeService()
    //				.createProcessInstanceQuery().count());

  }
Ejemplo n.º 4
0
  /**
   * 查询指定任务节点的最新记录
   *
   * @param procInst 流程实例
   * @param activityId
   * @return
   */
  private HistoricActivityInstance findHistoricUserTask(
      ProcessInstance procInst, String activityId) {
    HistoricActivityInstance rtnVal = null;
    // 查询当前流程实例审批结束的历史节点
    List<HistoricActivityInstance> historicActivityInstances =
        historyService
            .createHistoricActivityInstanceQuery()
            .activityType("userTask")
            .processInstanceId(procInst.getId())
            .activityId(activityId)
            .finished()
            .orderByHistoricActivityInstanceEndTime()
            .desc()
            .list();
    if (historicActivityInstances.size() > 0) {
      rtnVal = historicActivityInstances.get(0);
    }

    return rtnVal;
  }
 @Test
 @Deployment(resources = {"chapter4/bookorder.bpmn20.xml"})
 public void queryHistoricActivities() {
   startAndComplete();
   HistoryService historyService = activitiRule.getHistoryService();
   List<HistoricActivityInstance> activityList =
       historyService.createHistoricActivityInstanceQuery().list();
   assertEquals(4, activityList.size());
   for (HistoricActivityInstance historicActivityInstance : activityList) {
     assertNotNull(historicActivityInstance.getActivityId());
     System.out.println(
         "history activity "
             + historicActivityInstance.getActivityName()
             + ", type "
             + historicActivityInstance.getActivityType()
             + ", starttime "
             + historicActivityInstance.getStartTime()
             + ", endtime "
             + historicActivityInstance.getEndTime()
             + ", duration was "
             + historicActivityInstance.getDurationInMillis());
   }
 }