org.activiti.engine.history.HistoricDetail Java Examples

The following examples show how to use org.activiti.engine.history.HistoricDetail. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LeaveDynamicFormTest.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取历史变量并封装到Map中
 */
private Map<String, Object> packageVariables(ProcessInstance processInstance) {
    Map<String, Object> historyVariables = new HashMap<String, Object>();
    List<HistoricDetail> list = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).list();
    for (HistoricDetail historicDetail : list) {
        if (historicDetail instanceof HistoricFormProperty) {
            // 表单中的字段
            HistoricFormProperty field = (HistoricFormProperty) historicDetail;
            historyVariables.put(field.getPropertyId(), field.getPropertyValue());
            System.out.println("form field: taskId=" + field.getTaskId() + ", " + field.getPropertyId() + " = " + field.getPropertyValue());
        } else if (historicDetail instanceof HistoricVariableUpdate) {
            HistoricVariableUpdate variable = (HistoricVariableUpdate) historicDetail;
            historyVariables.put(variable.getVariableName(), variable.getValue());
            System.out.println("variable: " + variable.getVariableName() + " = " + variable.getValue());
        }
    }
    return historyVariables;
}
 
Example #2
Source File: LeaveDynamicFormTest.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取历史变量并封装到Map中
 */
private Map<String, Object> packageVariables(ProcessInstance processInstance) {
    Map<String, Object> historyVariables = new HashMap<String, Object>();
    List<HistoricDetail> list = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).list();
    for (HistoricDetail historicDetail : list) {
        if (historicDetail instanceof HistoricFormProperty) {
            // 表单中的字段
            HistoricFormProperty field = (HistoricFormProperty) historicDetail;
            historyVariables.put(field.getPropertyId(), field.getPropertyValue());
            System.out.println("form field: taskId=" + field.getTaskId() + ", " + field.getPropertyId() + " = " + field.getPropertyValue());
        } else if (historicDetail instanceof HistoricVariableUpdate) {
            HistoricVariableUpdate variable = (HistoricVariableUpdate) historicDetail;
            historyVariables.put(variable.getVariableName(), variable.getValue());
            System.out.println("variable: " + variable.getVariableName() + " = " + variable.getValue());
        }
    }
    return historyVariables;
}
 
Example #3
Source File: LeaveFormKeyTest.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取历史变量并封装到Map中
 */
private Map<String, Object> packageVariables(ProcessInstance processInstance) {
    Map<String, Object> historyVariables = new HashMap<String, Object>();
    List<HistoricDetail> list = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).list();
    for (HistoricDetail historicDetail : list) {
        if (historicDetail instanceof HistoricFormProperty) {
            // 表单中的字段
            HistoricFormProperty field = (HistoricFormProperty) historicDetail;
            historyVariables.put(field.getPropertyId(), field.getPropertyValue());
            System.out.println("form field: taskId=" + field.getTaskId() + ", " + field.getPropertyId() + " = " + field.getPropertyValue());
        } else if (historicDetail instanceof HistoricVariableUpdate) {
            HistoricVariableUpdate variable = (HistoricVariableUpdate) historicDetail;
            historyVariables.put(variable.getVariableName(), variable.getValue());
            System.out.println("variable: " + variable.getVariableName() + " = " + variable.getValue());
        }
    }
    return historyVariables;
}
 
Example #4
Source File: LeaveDynamicFormTest.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取历史变量并封装到Map中
 */
private Map<String, Object> packageVariables(ProcessInstance processInstance) {
    Map<String, Object> historyVariables = new HashMap<String, Object>();
    List<HistoricDetail> list = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).list();
    for (HistoricDetail historicDetail : list) {
        if (historicDetail instanceof HistoricFormProperty) {
            // 表单中的字段
            HistoricFormProperty field = (HistoricFormProperty) historicDetail;
            historyVariables.put(field.getPropertyId(), field.getPropertyValue());
            System.out.println("form field: taskId=" + field.getTaskId() + ", " + field.getPropertyId() + " = " + field.getPropertyValue());
        } else if (historicDetail instanceof HistoricVariableUpdate) {
            HistoricVariableUpdate variable = (HistoricVariableUpdate) historicDetail;
            historyVariables.put(variable.getVariableName(), variable.getValue());
            System.out.println("variable: " + variable.getVariableName() + " = " + variable.getValue());
        }
    }
    return historyVariables;
}
 
Example #5
Source File: LeaveDynamicFormTest.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取历史变量并封装到Map中
 */
private Map<String, Object> packageVariables(ProcessInstance processInstance) {
    Map<String, Object> historyVariables = new HashMap<String, Object>();
    List<HistoricDetail> list = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).list();
    for (HistoricDetail historicDetail : list) {
        if (historicDetail instanceof HistoricFormProperty) {
            // 表单中的字段
            HistoricFormProperty field = (HistoricFormProperty) historicDetail;
            historyVariables.put(field.getPropertyId(), field.getPropertyValue());
            System.out.println("form field: taskId=" + field.getTaskId() + ", " + field.getPropertyId() + " = " + field.getPropertyValue());
        } else if (historicDetail instanceof HistoricVariableUpdate) {
            HistoricVariableUpdate variable = (HistoricVariableUpdate) historicDetail;
            historyVariables.put(variable.getVariableName(), variable.getValue());
            System.out.println("variable: " + variable.getVariableName() + " = " + variable.getValue());
        }
    }
    return historyVariables;
}
 
Example #6
Source File: TaskServiceTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml" })
  public void testGetVariableByHistoricActivityInstance() {
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.FULL)) {
      ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
      assertNotNull(processInstance);
      Task task = taskService.createTaskQuery().singleResult();

      taskService.setVariable(task.getId(), "variable1", "value1");
      taskService.setVariable(task.getId(), "variable1", "value2");

      HistoricActivityInstance historicActivitiInstance = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstance.getId())
              .activityId("theTask").singleResult();
      assertNotNull(historicActivitiInstance);

      List<HistoricDetail> resultSet = historyService.createHistoricDetailQuery().variableUpdates().activityInstanceId(historicActivitiInstance.getId())
              .orderByTime().asc().list();

      assertEquals(2, resultSet.size());
      assertEquals("variable1", ((HistoricVariableUpdate) resultSet.get(0)).getVariableName());
      assertEquals("value1", ((HistoricVariableUpdate) resultSet.get(0)).getValue());
      assertEquals("variable1", ((HistoricVariableUpdate) resultSet.get(1)).getVariableName());
      assertEquals("value2", ((HistoricVariableUpdate) resultSet.get(1)).getValue());
    }
}
 
Example #7
Source File: LeaveFormKeyTest.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取历史变量并封装到Map中
 */
private Map<String, Object> packageVariables(ProcessInstance processInstance) {
    Map<String, Object> historyVariables = new HashMap<String, Object>();
    List<HistoricDetail> list = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).list();
    for (HistoricDetail historicDetail : list) {
        if (historicDetail instanceof HistoricFormProperty) {
            // 表单中的字段
            HistoricFormProperty field = (HistoricFormProperty) historicDetail;
            historyVariables.put(field.getPropertyId(), field.getPropertyValue());
            System.out.println("form field: taskId=" + field.getTaskId() + ", " + field.getPropertyId() + " = " + field.getPropertyValue());
        } else if (historicDetail instanceof HistoricVariableUpdate) {
            HistoricVariableUpdate variable = (HistoricVariableUpdate) historicDetail;
            historyVariables.put(variable.getVariableName(), variable.getValue());
            System.out.println("variable: " + variable.getVariableName() + " = " + variable.getValue());
        }
    }
    return historyVariables;
}
 
Example #8
Source File: TaskServiceTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
private void checkHistoricVariableUpdateEntity(String variableName, String processInstanceId) {
  if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.FULL)) {
    boolean deletedVariableUpdateFound = false;

    List<HistoricDetail> resultSet = historyService.createHistoricDetailQuery().processInstanceId(processInstanceId).list();
    for (HistoricDetail currentHistoricDetail : resultSet) {
      assertTrue(currentHistoricDetail instanceof HistoricDetailVariableInstanceUpdateEntity);
      HistoricDetailVariableInstanceUpdateEntity historicVariableUpdate = (HistoricDetailVariableInstanceUpdateEntity) currentHistoricDetail;

      if (historicVariableUpdate.getName().equals(variableName)) {
        if (historicVariableUpdate.getValue() == null) {
          if (deletedVariableUpdateFound) {
            fail("Mismatch: A HistoricVariableUpdateEntity with a null value already found");
          } else {
            deletedVariableUpdateFound = true;
          }
        }
      }
    }

    assertTrue(deletedVariableUpdateFound);
  }
}
 
Example #9
Source File: RuntimeServiceTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
private void checkHistoricVariableUpdateEntity(String variableName, String processInstanceId) {
  if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.FULL)) {
    boolean deletedVariableUpdateFound = false;

    List<HistoricDetail> resultSet = historyService.createHistoricDetailQuery().processInstanceId(processInstanceId).list();
    for (HistoricDetail currentHistoricDetail : resultSet) {
      assertTrue(currentHistoricDetail instanceof HistoricDetailVariableInstanceUpdateEntity);
      HistoricDetailVariableInstanceUpdateEntity historicVariableUpdate = (HistoricDetailVariableInstanceUpdateEntity) currentHistoricDetail;

      if (historicVariableUpdate.getName().equals(variableName)) {
        if (historicVariableUpdate.getValue() == null) {
          if (deletedVariableUpdateFound) {
            fail("Mismatch: A HistoricVariableUpdateEntity with a null value already found");
          } else {
            deletedVariableUpdateFound = true;
          }
        }
      }
    }

    assertTrue(deletedVariableUpdateFound);
  }
}
 
Example #10
Source File: LeaveFormKeyTest.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取历史变量并封装到Map中
 */
private Map<String, Object> packageVariables(ProcessInstance processInstance) {
    Map<String, Object> historyVariables = new HashMap<String, Object>();
    List<HistoricDetail> list = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).list();
    for (HistoricDetail historicDetail : list) {
        if (historicDetail instanceof HistoricFormProperty) {
            // 表单中的字段
            HistoricFormProperty field = (HistoricFormProperty) historicDetail;
            historyVariables.put(field.getPropertyId(), field.getPropertyValue());
            System.out.println("form field: taskId=" + field.getTaskId() + ", " + field.getPropertyId() + " = " + field.getPropertyValue());
        } else if (historicDetail instanceof HistoricVariableUpdate) {
            HistoricVariableUpdate variable = (HistoricVariableUpdate) historicDetail;
            historyVariables.put(variable.getVariableName(), variable.getValue());
            System.out.println("variable: " + variable.getVariableName() + " = " + variable.getValue());
        }
    }
    return historyVariables;
}
 
Example #11
Source File: LeaveFormKeyTest.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取历史变量并封装到Map中
 */
private Map<String, Object> packageVariables(ProcessInstance processInstance) {
    Map<String, Object> historyVariables = new HashMap<String, Object>();
    List<HistoricDetail> list = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).list();
    for (HistoricDetail historicDetail : list) {
        if (historicDetail instanceof HistoricFormProperty) {
            // 表单中的字段
            HistoricFormProperty field = (HistoricFormProperty) historicDetail;
            historyVariables.put(field.getPropertyId(), field.getPropertyValue());
            System.out.println("form field: taskId=" + field.getTaskId() + ", " + field.getPropertyId() + " = " + field.getPropertyValue());
        } else if (historicDetail instanceof HistoricVariableUpdate) {
            HistoricVariableUpdate variable = (HistoricVariableUpdate) historicDetail;
            historyVariables.put(variable.getVariableName(), variable.getValue());
            System.out.println("variable: " + variable.getVariableName() + " = " + variable.getValue());
        }
    }
    return historyVariables;
}
 
Example #12
Source File: RuntimeServiceTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
private void checkHistoricVariableUpdateEntity(String variableName, String processInstanceId) {
  if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.FULL)) {
    boolean deletedVariableUpdateFound = false;

    List<HistoricDetail> resultSet = historyService.createHistoricDetailQuery().processInstanceId(processInstanceId).list();
    for (HistoricDetail currentHistoricDetail : resultSet) {
      assertTrue(currentHistoricDetail instanceof HistoricDetailVariableInstanceUpdateEntity);
      HistoricDetailVariableInstanceUpdateEntity historicVariableUpdate = (HistoricDetailVariableInstanceUpdateEntity) currentHistoricDetail;
    
      if (historicVariableUpdate.getName().equals(variableName)) {
        if (historicVariableUpdate.getValue() == null) {
          if (deletedVariableUpdateFound) {
            fail("Mismatch: A HistoricVariableUpdateEntity with a null value already found");
          } else {
            deletedVariableUpdateFound = true;
          }
        }
      }
    }
    
    assertTrue(deletedVariableUpdateFound);
  }
}
 
Example #13
Source File: TaskServiceTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
private void checkHistoricVariableUpdateEntity(String variableName, String processInstanceId) {
  if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.FULL)) {
    boolean deletedVariableUpdateFound = false;

    List<HistoricDetail> resultSet = historyService.createHistoricDetailQuery().processInstanceId(processInstanceId).list();
    for (HistoricDetail currentHistoricDetail : resultSet) {
      assertTrue(currentHistoricDetail instanceof HistoricDetailVariableInstanceUpdateEntity);
      HistoricDetailVariableInstanceUpdateEntity historicVariableUpdate = (HistoricDetailVariableInstanceUpdateEntity) currentHistoricDetail;
    
      if (historicVariableUpdate.getName().equals(variableName)) {
        if (historicVariableUpdate.getValue() == null) {
          if (deletedVariableUpdateFound) {
            fail("Mismatch: A HistoricVariableUpdateEntity with a null value already found");
          } else {
            deletedVariableUpdateFound = true;
          }
        }
      }
    }
    
    assertTrue(deletedVariableUpdateFound);
  }
}
 
Example #14
Source File: LeaveDynamicFormTest.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取历史变量并封装到Map中
 */
private Map<String, Object> packageVariables(ProcessInstance processInstance) {
    Map<String, Object> historyVariables = new HashMap<String, Object>();
    List<HistoricDetail> list = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).list();
    for (HistoricDetail historicDetail : list) {
        if (historicDetail instanceof HistoricFormProperty) {
            // 表单中的字段
            HistoricFormProperty field = (HistoricFormProperty) historicDetail;
            historyVariables.put(field.getPropertyId(), field.getPropertyValue());
            System.out.println("form field: taskId=" + field.getTaskId() + ", " + field.getPropertyId() + " = " + field.getPropertyValue());
        } else if (historicDetail instanceof HistoricVariableUpdate) {
            HistoricVariableUpdate variable = (HistoricVariableUpdate) historicDetail;
            historyVariables.put(variable.getVariableName(), variable.getValue());
            System.out.println("variable: " + variable.getVariableName() + " = " + variable.getValue());
        }
    }
    return historyVariables;
}
 
Example #15
Source File: LeaveFormKeyTest.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取历史变量并封装到Map中
 */
private Map<String, Object> packageVariables(ProcessInstance processInstance) {
    Map<String, Object> historyVariables = new HashMap<String, Object>();
    List<HistoricDetail> list = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).list();
    for (HistoricDetail historicDetail : list) {
        if (historicDetail instanceof HistoricFormProperty) {
            // 表单中的字段
            HistoricFormProperty field = (HistoricFormProperty) historicDetail;
            historyVariables.put(field.getPropertyId(), field.getPropertyValue());
            System.out.println("form field: taskId=" + field.getTaskId() + ", " + field.getPropertyId() + " = " + field.getPropertyValue());
        } else if (historicDetail instanceof HistoricVariableUpdate) {
            HistoricVariableUpdate variable = (HistoricVariableUpdate) historicDetail;
            historyVariables.put(variable.getVariableName(), variable.getValue());
            System.out.println("variable: " + variable.getVariableName() + " = " + variable.getValue());
        }
    }
    return historyVariables;
}
 
Example #16
Source File: LeaveDynamicFormTest.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取历史变量并封装到Map中
 */
private Map<String, Object> packageVariables(ProcessInstance processInstance) {
    Map<String, Object> historyVariables = new HashMap<String, Object>();
    List<HistoricDetail> list = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).list();
    for (HistoricDetail historicDetail : list) {
        if (historicDetail instanceof HistoricFormProperty) {
            // 表单中的字段
            HistoricFormProperty field = (HistoricFormProperty) historicDetail;
            historyVariables.put(field.getPropertyId(), field.getPropertyValue());
            System.out.println("form field: taskId=" + field.getTaskId() + ", " + field.getPropertyId() + " = " + field.getPropertyValue());
        } else if (historicDetail instanceof HistoricVariableUpdate) {
            HistoricVariableUpdate variable = (HistoricVariableUpdate) historicDetail;
            historyVariables.put(variable.getVariableName(), variable.getValue());
            System.out.println("variable: " + variable.getVariableName() + " = " + variable.getValue());
        }
    }
    return historyVariables;
}
 
Example #17
Source File: LeaveFormKeyTest.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取历史变量并封装到Map中
 */
private Map<String, Object> packageVariables(ProcessInstance processInstance) {
    Map<String, Object> historyVariables = new HashMap<String, Object>();
    List<HistoricDetail> list = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).list();
    for (HistoricDetail historicDetail : list) {
        if (historicDetail instanceof HistoricFormProperty) {
            // 表单中的字段
            HistoricFormProperty field = (HistoricFormProperty) historicDetail;
            historyVariables.put(field.getPropertyId(), field.getPropertyValue());
            System.out.println("form field: taskId=" + field.getTaskId() + ", " + field.getPropertyId() + " = " + field.getPropertyValue());
        } else if (historicDetail instanceof HistoricVariableUpdate) {
            HistoricVariableUpdate variable = (HistoricVariableUpdate) historicDetail;
            historyVariables.put(variable.getVariableName(), variable.getValue());
            System.out.println("variable: " + variable.getVariableName() + " = " + variable.getValue());
        }
    }
    return historyVariables;
}
 
Example #18
Source File: LeaveDynamicFormTest.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取历史变量并封装到Map中
 */
private Map<String, Object> packageVariables(ProcessInstance processInstance) {
    Map<String, Object> historyVariables = new HashMap<String, Object>();
    List<HistoricDetail> list = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).list();
    for (HistoricDetail historicDetail : list) {
        if (historicDetail instanceof HistoricFormProperty) {
            // 表单中的字段
            HistoricFormProperty field = (HistoricFormProperty) historicDetail;
            historyVariables.put(field.getPropertyId(), field.getPropertyValue());
            System.out.println("form field: taskId=" + field.getTaskId() + ", " + field.getPropertyId() + " = " + field.getPropertyValue());
        } else if (historicDetail instanceof HistoricVariableUpdate) {
            HistoricVariableUpdate variable = (HistoricVariableUpdate) historicDetail;
            historyVariables.put(variable.getVariableName(), variable.getValue());
            System.out.println("variable: " + variable.getVariableName() + " = " + variable.getValue());
        }
    }
    return historyVariables;
}
 
Example #19
Source File: LeaveFormKeyTest.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取历史变量并封装到Map中
 */
private Map<String, Object> packageVariables(ProcessInstance processInstance) {
    Map<String, Object> historyVariables = new HashMap<String, Object>();
    List<HistoricDetail> list = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).list();
    for (HistoricDetail historicDetail : list) {
        if (historicDetail instanceof HistoricFormProperty) {
            // 表单中的字段
            HistoricFormProperty field = (HistoricFormProperty) historicDetail;
            historyVariables.put(field.getPropertyId(), field.getPropertyValue());
            System.out.println("form field: taskId=" + field.getTaskId() + ", " + field.getPropertyId() + " = " + field.getPropertyValue());
        } else if (historicDetail instanceof HistoricVariableUpdate) {
            HistoricVariableUpdate variable = (HistoricVariableUpdate) historicDetail;
            historyVariables.put(variable.getVariableName(), variable.getValue());
            System.out.println("variable: " + variable.getVariableName() + " = " + variable.getValue());
        }
    }
    return historyVariables;
}
 
Example #20
Source File: LeaveDynamicFormTest.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取历史变量并封装到Map中
 */
private Map<String, Object> packageVariables(ProcessInstance processInstance) {
    Map<String, Object> historyVariables = new HashMap<String, Object>();
    List<HistoricDetail> list = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).list();
    for (HistoricDetail historicDetail : list) {
        if (historicDetail instanceof HistoricFormProperty) {
            // 表单中的字段
            HistoricFormProperty field = (HistoricFormProperty) historicDetail;
            historyVariables.put(field.getPropertyId(), field.getPropertyValue());
            System.out.println("form field: taskId=" + field.getTaskId() + ", " + field.getPropertyId() + " = " + field.getPropertyValue());
        } else if (historicDetail instanceof HistoricVariableUpdate) {
            HistoricVariableUpdate variable = (HistoricVariableUpdate) historicDetail;
            historyVariables.put(variable.getVariableName(), variable.getValue());
            System.out.println("variable: " + variable.getVariableName() + " = " + variable.getValue());
        }
    }
    return historyVariables;
}
 
Example #21
Source File: LeaveFormKeyTest.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取历史变量并封装到Map中
 */
private Map<String, Object> packageVariables(ProcessInstance processInstance) {
    Map<String, Object> historyVariables = new HashMap<String, Object>();
    List<HistoricDetail> list = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).list();
    for (HistoricDetail historicDetail : list) {
        if (historicDetail instanceof HistoricFormProperty) {
            // 表单中的字段
            HistoricFormProperty field = (HistoricFormProperty) historicDetail;
            historyVariables.put(field.getPropertyId(), field.getPropertyValue());
            System.out.println("form field: taskId=" + field.getTaskId() + ", " + field.getPropertyId() + " = " + field.getPropertyValue());
        } else if (historicDetail instanceof HistoricVariableUpdate) {
            HistoricVariableUpdate variable = (HistoricVariableUpdate) historicDetail;
            historyVariables.put(variable.getVariableName(), variable.getValue());
            System.out.println("variable: " + variable.getVariableName() + " = " + variable.getValue());
        }
    }
    return historyVariables;
}
 
Example #22
Source File: LeaveFormKeyTest.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取历史变量并封装到Map中
 */
private Map<String, Object> packageVariables(ProcessInstance processInstance) {
    Map<String, Object> historyVariables = new HashMap<String, Object>();
    List<HistoricDetail> list = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).list();
    for (HistoricDetail historicDetail : list) {
        if (historicDetail instanceof HistoricFormProperty) {
            // 表单中的字段
            HistoricFormProperty field = (HistoricFormProperty) historicDetail;
            historyVariables.put(field.getPropertyId(), field.getPropertyValue());
            System.out.println("form field: taskId=" + field.getTaskId() + ", " + field.getPropertyId() + " = " + field.getPropertyValue());
        } else if (historicDetail instanceof HistoricVariableUpdate) {
            HistoricVariableUpdate variable = (HistoricVariableUpdate) historicDetail;
            historyVariables.put(variable.getVariableName(), variable.getValue());
            System.out.println("variable: " + variable.getVariableName() + " = " + variable.getValue());
        }
    }
    return historyVariables;
}
 
Example #23
Source File: LeaveDynamicFormTest.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取历史变量并封装到Map中
 */
private Map<String, Object> packageVariables(ProcessInstance processInstance) {
    Map<String, Object> historyVariables = new HashMap<String, Object>();
    List<HistoricDetail> list = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).list();
    for (HistoricDetail historicDetail : list) {
        if (historicDetail instanceof HistoricFormProperty) {
            // 表单中的字段
            HistoricFormProperty field = (HistoricFormProperty) historicDetail;
            historyVariables.put(field.getPropertyId(), field.getPropertyValue());
            System.out.println("form field: taskId=" + field.getTaskId() + ", " + field.getPropertyId() + " = " + field.getPropertyValue());
        } else if (historicDetail instanceof HistoricVariableUpdate) {
            HistoricVariableUpdate variable = (HistoricVariableUpdate) historicDetail;
            historyVariables.put(variable.getVariableName(), variable.getValue());
            System.out.println("variable: " + variable.getVariableName() + " = " + variable.getValue());
        }
    }
    return historyVariables;
}
 
Example #24
Source File: LeaveFormKeyTest.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取历史变量并封装到Map中
 */
private Map<String, Object> packageVariables(ProcessInstance processInstance) {
    Map<String, Object> historyVariables = new HashMap<String, Object>();
    List<HistoricDetail> list = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).list();
    for (HistoricDetail historicDetail : list) {
        if (historicDetail instanceof HistoricFormProperty) {
            // 表单中的字段
            HistoricFormProperty field = (HistoricFormProperty) historicDetail;
            historyVariables.put(field.getPropertyId(), field.getPropertyValue());
            System.out.println("form field: taskId=" + field.getTaskId() + ", " + field.getPropertyId() + " = " + field.getPropertyValue());
        } else if (historicDetail instanceof HistoricVariableUpdate) {
            HistoricVariableUpdate variable = (HistoricVariableUpdate) historicDetail;
            historyVariables.put(variable.getVariableName(), variable.getValue());
            System.out.println("variable: " + variable.getVariableName() + " = " + variable.getValue());
        }
    }
    return historyVariables;
}
 
Example #25
Source File: LeaveDynamicFormTest.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取历史变量并封装到Map中
 */
private Map<String, Object> packageVariables(ProcessInstance processInstance) {
    Map<String, Object> historyVariables = new HashMap<String, Object>();
    List<HistoricDetail> list = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).list();
    for (HistoricDetail historicDetail : list) {
        if (historicDetail instanceof HistoricFormProperty) {
            // 表单中的字段
            HistoricFormProperty field = (HistoricFormProperty) historicDetail;
            historyVariables.put(field.getPropertyId(), field.getPropertyValue());
            System.out.println("form field: taskId=" + field.getTaskId() + ", " + field.getPropertyId() + " = " + field.getPropertyValue());
        } else if (historicDetail instanceof HistoricVariableUpdate) {
            HistoricVariableUpdate variable = (HistoricVariableUpdate) historicDetail;
            historyVariables.put(variable.getVariableName(), variable.getValue());
            System.out.println("variable: " + variable.getVariableName() + " = " + variable.getValue());
        }
    }
    return historyVariables;
}
 
Example #26
Source File: LeaveFormKeyTest.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取历史变量并封装到Map中
 */
private Map<String, Object> packageVariables(ProcessInstance processInstance) {
    Map<String, Object> historyVariables = new HashMap<String, Object>();
    List<HistoricDetail> list = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).list();
    for (HistoricDetail historicDetail : list) {
        if (historicDetail instanceof HistoricFormProperty) {
            // 表单中的字段
            HistoricFormProperty field = (HistoricFormProperty) historicDetail;
            historyVariables.put(field.getPropertyId(), field.getPropertyValue());
            System.out.println("form field: taskId=" + field.getTaskId() + ", " + field.getPropertyId() + " = " + field.getPropertyValue());
        } else if (historicDetail instanceof HistoricVariableUpdate) {
            HistoricVariableUpdate variable = (HistoricVariableUpdate) historicDetail;
            historyVariables.put(variable.getVariableName(), variable.getValue());
            System.out.println("variable: " + variable.getVariableName() + " = " + variable.getValue());
        }
    }
    return historyVariables;
}
 
Example #27
Source File: LeaveDynamicFormTest.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取历史变量并封装到Map中
 */
private Map<String, Object> packageVariables(ProcessInstance processInstance) {
    Map<String, Object> historyVariables = new HashMap<String, Object>();
    List<HistoricDetail> list = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).list();
    for (HistoricDetail historicDetail : list) {
        if (historicDetail instanceof HistoricFormProperty) {
            // 表单中的字段
            HistoricFormProperty field = (HistoricFormProperty) historicDetail;
            historyVariables.put(field.getPropertyId(), field.getPropertyValue());
            System.out.println("form field: taskId=" + field.getTaskId() + ", " + field.getPropertyId() + " = " + field.getPropertyValue());
        } else if (historicDetail instanceof HistoricVariableUpdate) {
            HistoricVariableUpdate variable = (HistoricVariableUpdate) historicDetail;
            historyVariables.put(variable.getVariableName(), variable.getValue());
            System.out.println("variable: " + variable.getVariableName() + " = " + variable.getValue());
        }
    }
    return historyVariables;
}
 
Example #28
Source File: FullHistoryTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
/**
 * Test created to validate ACT-621 fix.
 */
@Deployment
public void testHistoricFormPropertiesOnReEnteringActivity() {
  Map<String, Object> variables = new HashMap<String, Object>();
  variables.put("comeBack", Boolean.TRUE);

  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("HistoricFormPropertiesProcess", variables);
  assertNotNull(processInstance);

  // Submit form on task
  Map<String, String> data = new HashMap<String, String>();
  data.put("formProp1", "Property value");

  Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
  formService.submitTaskFormData(task.getId(), data);

  // Historic property should be available
  List<HistoricDetail> details = historyService.createHistoricDetailQuery().formProperties().processInstanceId(processInstance.getId()).list();
  assertNotNull(details);
  assertEquals(1, details.size());

  // Task should be active in the same activity as the previous one
  task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
  formService.submitTaskFormData(task.getId(), data);

  details = historyService.createHistoricDetailQuery().formProperties().processInstanceId(processInstance.getId()).list();
  assertNotNull(details);
  assertEquals(2, details.size());

  // Should have 2 different historic activity instance ID's, with the
  // same activityId
  assertNotSame(details.get(0).getActivityInstanceId(), details.get(1).getActivityInstanceId());

  HistoricActivityInstance historicActInst1 = historyService.createHistoricActivityInstanceQuery().activityInstanceId(details.get(0).getActivityInstanceId()).singleResult();

  HistoricActivityInstance historicActInst2 = historyService.createHistoricActivityInstanceQuery().activityInstanceId(details.get(1).getActivityInstanceId()).singleResult();

  assertEquals(historicActInst1.getActivityId(), historicActInst2.getActivityId());
}
 
Example #29
Source File: TraceProcessController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 读取历史数据
 *
 * @return
 */
@RequestMapping(value = "trace/view/{executionId}")
public ModelAndView historyDatas(@PathVariable("executionId") String executionId) {
    ModelAndView mav = new ModelAndView("chapter13/trace-process");

    // 查询Execution对象
    Execution execution = runtimeService.createExecutionQuery().executionId(executionId).singleResult();

    // 查询所有的历史活动记录
    String processInstanceId = execution.getProcessInstanceId();
    List<HistoricActivityInstance> activityInstances = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).list();

    // 查询历史流程实例
    HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery()
            .processInstanceId(processInstanceId).singleResult();

    // 查询流程有关的变量
    List<HistoricVariableInstance> variableInstances = historyService.createHistoricVariableInstanceQuery()
            .processInstanceId(processInstanceId).list();

    List<HistoricDetail> formProperties = historyService.createHistoricDetailQuery().processInstanceId(processInstanceId).formProperties().list();

    // 查询流程定义对象
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
            .processDefinitionId(historicProcessInstance.getProcessDefinitionId()).singleResult();

    // 查询运行时流程实例
    ProcessInstance parentProcessInstance = runtimeService.createProcessInstanceQuery()
            .subProcessInstanceId(execution.getProcessInstanceId()).singleResult();

    mav.addObject("parentProcessInstance", parentProcessInstance);
    mav.addObject("historicProcessInstance", historicProcessInstance);
    mav.addObject("variableInstances", variableInstances);
    mav.addObject("activities", activityInstances);
    mav.addObject("formProperties", formProperties);
    mav.addObject("processDefinition", processDefinition);
    mav.addObject("executionId", executionId);

    return mav;
}
 
Example #30
Source File: HistoricDetailEntityManager.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public void deleteHistoricDetailsByTaskId(String taskId) {
    if (getHistoryManager().isHistoryLevelAtLeast(HistoryLevel.FULL)) {
        HistoricDetailQueryImpl detailsQuery = new HistoricDetailQueryImpl().taskId(taskId);
        List<HistoricDetail> details = detailsQuery.list();
        for (HistoricDetail detail : details) {
            ((HistoricDetailEntity) detail).delete();
        }
    }
}