Package org.activiti.engine

Examples of org.activiti.engine.HistoryService


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


    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

    // Map<历史活动ID, Map<变量名称, 变量值>>
    Map<String, Map<String, Object>> activiy_name_value = new HashMap<String, Map<String, Object>>();

    // 从历史中读取变量
    HistoryService historyService = activitiRule.getHistoryService();
    List<HistoricDetail> list = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).list();
    for (HistoricDetail historicDetail : list) {
      HistoricVariableUpdate variable = (HistoricVariableUpdate) historicDetail;
      // System.out.println(variable.getName() + " = " + variable.getValue());
      String activityInstanceId = variable.getActivityInstanceId();

      // 初始化
      Map<String, Object> tempVariableMap = activiy_name_value.get(activityInstanceId);
      if (tempVariableMap == null) {
        tempVariableMap = new HashMap<String, Object>();
        activiy_name_value.put(activityInstanceId, tempVariableMap);
      }

      tempVariableMap.put(variable.getVariableName(), variable.getValue());

    }

    // 从历史读取用户任务的活动记录
    List<HistoricActivityInstance> activityList = historyService.createHistoricActivityInstanceQuery().activityType("userTask").list();
    for (HistoricActivityInstance historicActivityInstance : activityList) {
      String activityName = historicActivityInstance.getActivityName();
      System.out.println(activityName);
      Map<String, Object> map = activiy_name_value.get(historicActivityInstance.getId());
      Set<Entry<String, Object>> entrySet = map.entrySet();
View Full Code Here

   
    TaskService taskService = activitiRule.getTaskService();
    List<Task> list = taskService.createTaskQuery().list();
    assertEquals(0, list.size());
   
    HistoryService historyService = activitiRule.getHistoryService();
   
    // 读取所有的activity
    List<HistoricActivityInstance> activityList = historyService.createHistoricActivityInstanceQuery().executionId(processInstance.getId()).list();
    for (HistoricActivityInstance historicActivityInstance : activityList) {
      System.out.println("task of :" + historicActivityInstance.getActivityName() + "\t" + historicActivityInstance.getActivityType());
    }
   
    // 只读取receive task
    activityList = historyService.createHistoricActivityInstanceQuery().activityType("receiveTask").executionId(processInstance.getId()).list();
    assertEquals(1, activityList.size());
   
    // 触发receive task
    System.out.println("begin invoke receive task...");
    runtimeService.signal(processInstance.getId());
   
    // 验证是否已经结束
    long count = historyService.createHistoricProcessInstanceQuery().finished().count();
    assertEquals(1, count);
  }
View Full Code Here

    variableMap = new HashMap<String, Object>();
    variableMap.put("userId", "henryyan");
    ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("gateway", variableMap);
    System.out.println("id " + processInstance2.getId() + " " + processInstance2.getProcessDefinitionId());
   
    HistoryService historyService = activitiRule.getHistoryService();
    long count = historyService.createHistoricVariableInstanceQuery().count();
    assertEquals(2, count);
   
    //historyService.deleteHistoricProcessInstance(processInstance2.getId());
    runtimeService.deleteProcessInstance(processInstance2.getId(), "test");
    count = historyService.createHistoricVariableInstanceQuery().count();
    assertEquals(2, count);
    System.out.println("==============");
    historyService.deleteHistoricProcessInstance(processInstance2.getId());
    count = historyService.createHistoricVariableInstanceQuery().count();
    assertEquals(1, count);
  }
View Full Code Here

       
        String procId = proc.getId();
        System.out.println("procId="+procId);
       
        long timeout = System.currentTimeMillis()+15*1000;
        HistoryService hstSvc = eng.getHistoryService();
        while (true){
            if (System.currentTimeMillis() > timeout) throw new TimeoutException();
            HistoricProcessInstance hProcInst = hstSvc.createHistoricProcessInstanceQuery().processInstanceId(procId).singleResult();
            if (hProcInst.getEndTime() != null){
                System.out.println(wfn+" ended");
                break;
            }
            Thread.sleep(1000);
View Full Code Here

    for (Entry<String, Object> entry : entrySet) {
      System.out.println(entry.getKey() + "=" + entry.getValue());
    }
   
    // 历史记录
    HistoryService historyService = activitiRule.getHistoryService();
    List<HistoricDetail> list = historyService.createHistoricDetailQuery().formProperties().list();
    assertEquals(1, list.size());
   
    // 获取第一个节点
    TaskService taskService = activitiRule.getTaskService();
    Task task = taskService.createTaskQuery().singleResult();
    assertEquals("First Step", task.getName());
   
    TaskFormData taskFormData = formService.getTaskFormData(task.getId());
    assertNotNull(taskFormData);
    assertNull(taskFormData.getFormKey());
    List<FormProperty> taskFormProperties = taskFormData.getFormProperties();
    assertNotNull(taskFormProperties);
    for (FormProperty formProperty : taskFormProperties) {
      System.out.println(ToStringBuilder.reflectionToString(formProperty));
    }
    formProperties = new HashMap<String, String>();
    formProperties.put("setInFirstStep", "01/12/2012");
    formService.submitTaskFormData(task.getId(), formProperties);
   
    // 获取第二个节点
    task = taskService.createTaskQuery().taskName("Second Step").singleResult();
    assertNotNull(task);
    taskFormData = formService.getTaskFormData(task.getId());
    assertNotNull(taskFormData);
    List<FormProperty> formProperties2 = taskFormData.getFormProperties();
    assertNotNull(formProperties2);
    assertEquals(1, formProperties2.size());
    assertNotNull(formProperties2.get(0).getValue());
    assertEquals(formProperties2.get(0).getValue(), "01/12/2012");
   
    List<HistoricDetail> details = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).list();
    for (HistoricDetail historicDetail : details) {
      if (historicDetail instanceof HistoricFormPropertyEntity) {
        HistoricFormPropertyEntity formEntity = (HistoricFormPropertyEntity) historicDetail;
        System.out.println(String.format("form->, key: %s, value: %s", formEntity.getPropertyId(), formEntity.getPropertyValue()));
      } else if (historicDetail instanceof HistoricVariableUpdate) {
        HistoricVariableUpdate varEntity = (HistoricVariableUpdate) historicDetail;
        System.out.println(String.format("variable->, key: %s, value: %s", varEntity.getVariableName(), varEntity.getValue()));
      }
    }
   
    long count = historyService.createHistoricDetailQuery().count();
    System.out.println(count);
  }
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());

    HistoryService historyService = activitiRule.getHistoryService();
    List<HistoricDetail> list = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).list();
    for (HistoricDetail historicDetail : list) {
      HistoricVariableUpdate variable = (HistoricVariableUpdate) historicDetail;
      System.out.println(variable.getVariableName() + " = " + variable.getValue());
    }
  }
View Full Code Here

    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("juelMap", variableMap);
    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " "
        + processInstance.getProcessDefinitionId());
   
    HistoryService historyService = activitiRule.getHistoryService();
    System.out.println(historyService.createHistoricVariableInstanceQuery().variableName("a").singleResult().getValue()); ;
  }
View Full Code Here

        try {
            procId = WfUtil.launchWf(log,workflowName,build.getParent().getName(),build.getNumber());
           
            if (procId != null){
                // TODO 5: is there a better way than polling to detect the termination of a process?
                HistoryService hstSvc = eng.getHistoryService();
                while (true){
                    // TODO 8: can we get a hold of any exception the engine is throwing and show it at least in the log?
                    // TODO 8: builder should log each time the process makes a state change
                    HistoricProcessInstance hProcInst = hstSvc.createHistoricProcessInstanceQuery().processInstanceId(procId).singleResult();
                    if (hProcInst.getEndTime() != null){
                        String wbr = getWorkflowBuildResult(hstSvc,procId);
                        log.println(Consts.UI_PREFIX+": \""+workflowName+"\" ended ("+wbr+")");
                        if (Result.FAILURE.toString().equals(wbr)) result = false;
                        break;
View Full Code Here

TOP

Related Classes of org.activiti.engine.HistoryService

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.