Activiti7 獲取當前任務節點出口連線(動態生成處理節點)

Activiti7 獲取當前任務節點出口連線(動態生成處理節點)

Activiti7 中 PVM,ActivitiImpl,PvmTransition ,ExecutionImpl, TransitionImpl 替代方法

通過閱讀官方文檔:

PVM classes
All classes from the org.activiti.engine.impl.pvm package (and subpackages) have been removed. This is because the PVM (Process Virtual Machine) model has been removed and replaced by a simpler and more lightweight model.

This means that usages of ActivitiImpl, ProcessDefinitionImpl, ExecutionImpl, TransitionImpl are invalid.

Generally, most of the usage of these classes in version 5 came down to getting information that was contained in the process definition. In version 6, all the process definition information can be found through the BpmnModel, which is a Java representation of the BPMN 2.0 XML for the process definition (enhanced to make certain operations and searches easier).

The quickest way to get the BpmnModel for a process definition is to use the org.activiti.engine.impl.util.ProcessDefinitionUtil class:

// The whole model
ProcessDefinitionUtil.getBpmnModel(String processDefinitionId);

// Only the specific process definition
ProcessDefinitionUtil.getProcess(String processDefinitionId);

大致是說:官方爲了輕量化,所以就把原來的PVM 流程引擎給優化了、
刪了後推薦我們獲取bpmnModel或者process來獲取模型的參數。

BpmnModel獲取方式可以使用官方推薦的,我這邊交互剛好只有taskId,就用這個做個demo;

// 獲取當前任務
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
//獲取當前模型
BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
// 獲取當前節點
FlowElement flowElement = bpmnModel.getFlowElement(task.getTaskDefinitionKey());
// 這裏不轉也有方法拿到,我這是爲了後人閱讀方便
UserTask userTask = (UserTask)flowElement;
//獲取節點出口線段
List<SequenceFlow> outgoingFlows = userTask.getOutgoingFlows();
// 我這邊暫時是解析expression 獲取條件和約定的值返回到前端構造button
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章