示例#1
0
 /**
  * 获取流程详细及工作流参数
  *
  * @param id
  */
 @SuppressWarnings("unchecked")
 public Leave get(String id) {
   Leave leave = leaveDao.get(id);
   Map<String, Object> variables = null;
   HistoricProcessInstance historicProcessInstance =
       historyService
           .createHistoricProcessInstanceQuery()
           .processInstanceId(leave.getProcessInstanceId())
           .singleResult();
   if (historicProcessInstance != null) {
     variables =
         Collections3.extractToMap(
             historyService
                 .createHistoricVariableInstanceQuery()
                 .processInstanceId(historicProcessInstance.getId())
                 .list(),
             "variableName",
             "value");
   } else {
     variables =
         runtimeService.getVariables(
             runtimeService
                 .createProcessInstanceQuery()
                 .processInstanceId(leave.getProcessInstanceId())
                 .active()
                 .singleResult()
                 .getId());
   }
   leave.setVariables(variables);
   return leave;
 }
  private Object getProccessVariableValue(String processInstance_ID, String variableName) {

    HistoricVariableInstance historicVariableInstance =
        historyService
            .createHistoricVariableInstanceQuery()
            .processInstanceId(processInstance_ID)
            .variableName(variableName)
            .singleResult();
    return (Object) historicVariableInstance.getValue();
  }
示例#3
0
 @Test
 public void exportJavaDelegate() throws Exception {
   // wait for deployment to be done
   Thread.sleep(5000);
   ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("osgiProcess");
   assertTrue(processInstance.isEnded());
   HistoricVariableInstance variable =
       historyService
           .createHistoricVariableInstanceQuery()
           .processInstanceId(processInstance.getId())
           .variableName("visited")
           .singleResult();
   assertTrue((Boolean) variable.getValue());
 }
  /**
   * 查看历史【包含流程跟踪、任务列表(完成和未完成)、流程变量】
   *
   * @return
   */
  public String viewHistory() {
    HistoryService historyService = processEngine.getHistoryService();
    historicTasks =
        historyService
            .createHistoricTaskInstanceQuery()
            .processInstanceId(processInstanceId)
            .list();
    historicVariableInstances =
        historyService
            .createHistoricVariableInstanceQuery()
            .processInstanceId(processInstanceId)
            .list();

    return "viewHistory";
  }