/** * 获取指定历史流程的变量列表 */ public Map<String, Object> getHistoricProcessVariables(String processId) { List<HistoricVariableInstance> list = _processEngine.getHistoryService().createHistoricVariableInstanceQuery() .processInstanceId(processId).list(); Map<String, Object> vars = new HashMap<String, Object>(); for (HistoricVariableInstance var : list) { vars.put(var.getVariableName(), var.getValue()); } return vars; }
historicVariableInstance.getValue();
public HistoricVariableInstanceResponse createHistoricVariableInstanceResponse(HistoricVariableInstance variableInstance, RestUrlBuilder urlBuilder) { HistoricVariableInstanceResponse result = new HistoricVariableInstanceResponse(); result.setId(variableInstance.getId()); result.setProcessInstanceId(variableInstance.getProcessInstanceId()); if (variableInstance.getProcessInstanceId() != null) { result.setProcessInstanceUrl(urlBuilder.buildUrl(RestUrls.URL_HISTORIC_PROCESS_INSTANCE, variableInstance.getProcessInstanceId())); } result.setTaskId(variableInstance.getTaskId()); result.setVariable(createRestVariable(variableInstance.getVariableName(), variableInstance.getValue(), null, variableInstance.getId(), VARIABLE_HISTORY_VARINSTANCE, false, urlBuilder)); return result; }
public List<String> getHistoricSubProcessIds(String superProcessId) { List<String> subProcessIds = new ArrayList<>(); List<HistoricVariableInstance> variablesWithSuperProcessId = retrieveVariablesByCorrelationId(superProcessId); for (HistoricVariableInstance historicVariableInstance : variablesWithSuperProcessId) { if (!historicVariableInstance.getProcessInstanceId().equals(superProcessId)) { subProcessIds.add(historicVariableInstance.getProcessInstanceId()); } } return subProcessIds; }
public String getServiceId(String processInstanceId) { HistoricVariableInstance historicVariableInstance = getHistoricVariableInstance(processInstanceId, Constants.VARIABLE_NAME_SERVICE_ID); return historicVariableInstance != null ? (String) historicVariableInstance.getValue() : null; }
ProcessEngineConfigurationImpl processEngineController = processArchiveServices.getProcessEngineController().getProcessEngineConfiguration(); String processInstanceId = historicVar.getProcessInstanceId(); String processDefId = processEngineController.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult().getProcessDefinitionId(); String processDefKey = processEngineController.getRepositoryService().createProcessDefinitionQuery().processDefinitionId(processDefId).singleResult().getKey();
/** * 获取历史审批结果和审批意见 * * @param activityInstance 历史任务节点 * @return */ public Map<String, String> getApproveMap(HistoricActivityInstance activityInstance) { //审批结果和审批意见为Local变量 Map<String, String> map = new HashMap<>(); if (StrUtil.isEmpty(activityInstance.getTaskId())) return map; List<HistoricVariableInstance> variableInstances = historyService.createHistoricVariableInstanceQuery() .processInstanceId(activityInstance.getProcessInstanceId()).taskId(activityInstance.getTaskId()).list(); for (HistoricVariableInstance variableInstance : variableInstances) { if (variableInstance.getVariableName().equals(Constants.APPROVE_RESULT)) { map.put(Constants.APPROVE_RESULT, variableInstance.getValue().toString()); } else { map.put(Constants.APPROVE_SUGGESTION, variableInstance.getValue().toString()); } } return map; }
@Override public List<Object> getVariablesIncludingFromSubProcesses(String variableName) { List<Object> variableValues = new ArrayList<>(); HistoricVariableInstance variable = getHistoricVariableInstanceFromProcess(processInstanceId, variableName); if (variable != null) { variableValues.add(variable.getValue()); } for (String subProcessId : subProcessIds) { variable = getHistoricVariableInstanceFromProcess(subProcessId, variableName); if (variable != null) { variableValues.add(variable.getValue()); } } return variableValues; }
int complete = 0;//完成数 for (HistoricVariableInstance historicVariableInstance : list) { if (historicVariableInstance.getVariableName().equals("confirmSts")) { if (historicVariableInstance.getValue().toString().equals("0")) { refuse++; } else { pass++; } else if (historicVariableInstance.getVariableName().equals("nrOfInstances")) { total = Integer.parseInt(historicVariableInstance.getValue().toString()); } else if (historicVariableInstance.getVariableName().equals("nrOfCompletedInstances")) { complete = Integer.parseInt(historicVariableInstance.getValue().toString());
protected void initForm() { // Report dataset is stored as historical variable as json HistoricVariableInstance historicVariableInstance = ProcessEngines.getDefaultProcessEngine().getHistoryService() .createHistoricVariableInstanceQuery() .processInstanceId(historicProcessInstance.getId()) .variableName("reportData") .singleResult(); // Generate chart byte[] reportData = (byte[]) historicVariableInstance.getValue(); ChartComponent chart = ChartGenerator.generateChart(reportData); chart.setWidth(100, UNITS_PERCENTAGE); chart.setHeight(100, UNITS_PERCENTAGE); // Put chart on screen detailContainer.addComponent(chart); }
public RestVariable getVariableFromRequest(boolean includeBinary, String varInstanceId, HttpServletRequest request) { HistoricVariableInstance varObject = historyService.createHistoricVariableInstanceQuery().id(varInstanceId).singleResult(); if (varObject == null) { throw new ActivitiObjectNotFoundException("Historic variable instance '" + varInstanceId + "' couldn't be found.", VariableInstanceEntity.class); } else { return restResponseFactory.createRestVariable(varObject.getVariableName(), varObject.getValue(), null, varInstanceId, RestResponseFactory.VARIABLE_HISTORY_VARINSTANCE, includeBinary); } } }
protected void generateReport(ProcessInstance processInstance) { // Report dataset is stored as historical variable as json HistoricVariableInstance historicVariableInstance = ProcessEngines.getDefaultProcessEngine() .getHistoryService() .createHistoricVariableInstanceQuery() .processInstanceId(processInstance.getId()) .variableName("reportData") .singleResult(); // Generate chart byte[] reportData = (byte[]) historicVariableInstance.getValue(); ChartComponent chart = ChartGenerator.generateChart(reportData); chart.setWidth(100, UNITS_PERCENTAGE); chart.setHeight(100, UNITS_PERCENTAGE); // Put chart on screen if (processDefinitionStartForm != null) { detailContainer.removeComponent(processDefinitionStartForm); processDefinitionStartForm = null; } detailContainer.addComponent(chart); // The historic process instance can now be removed from the system // Only when save is clicked, the report will be regenerated ProcessEngines.getDefaultProcessEngine().getHistoryService().deleteHistoricProcessInstance(processInstance.getId()); }
@Override public List<TaskHistoryVo> records(String busykey) { List<TaskHistoryVo> result = new ArrayList<TaskHistoryVo>(); List<HistoricTaskInstance> instances = historyService.createHistoricTaskInstanceQuery().processInstanceBusinessKey(busykey).list(); if (instances != null) { for (HistoricTaskInstance historicTaskInstance : instances) { List<HistoricVariableInstance> v = historyService.createHistoricVariableInstanceQuery().taskId(historicTaskInstance.getId()).list(); Map<String, Object> maxps = new HashMap<String, Object>(); if (v != null) { for (HistoricVariableInstance historicVariableInstance : v) { maxps.put(historicVariableInstance.getVariableName(), historicVariableInstance.getValue()); } } TaskHistoryVo vo = new TaskHistoryVo(); vo.setNote("" + maxps.get("note")); vo.setUser("" + maxps.get("user")); vo.setState("" + maxps.get("state")); vo.setAddDate(historicTaskInstance.getTime()); if (vo.getState() != null && !"null".equals(vo.getState())) { result.add(vo); } } } return result; }
historicVariableInstance.getValue();
Integer nrOfActiveInstances = 0; for (HistoricVariableInstance var : list) { if (var.getVariableName().equals("nrOfInstances")) { nrOfInstances = (Integer) var.getValue(); } else if (var.getVariableName().equals("nrOfActiveInstances")) { nrOfActiveInstances = (Integer) var.getValue();
historicVariableInstance.getValue();
if (v != null) { for (HistoricVariableInstance historicVariableInstance : v) { map.put(historicVariableInstance.getVariableName(), historicVariableInstance.getValue());
assertEquals("bar", persistedVariable.getValue());
if (historicVariableList != null) { for (HistoricVariableInstance historicVariable : historicVariableList) { result.addVariable(createRestVariable(historicVariable.getVariableName(), historicVariable.getValue(), RestVariableScope.LOCAL, processInstance.getId(), VARIABLE_PROCESS, false, urlBuilder));