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