activiti官网实例项目activiti-explorer之获取流程节点

如上图在保存步骤中添加获取节点信息方法nodes();

方法如下:

  //获取所有节点
    JsonNode modelNode = new ObjectMapper().readTree(repositoryService.getModelEditorSource(model.getId()));
    BpmnModel model1 = new BpmnJsonConverter().convertToBpmnModel(modelNode);
    if(model1 != null) {
       Process process = model1.getProcesses().get(0);//process对象封装了全部的节点、连线、以及关口等信息
       Collection<FlowElement> flowElements = process.getFlowElements();//获得所有节点
       for(FlowElement flowElement : flowElements) {
          if(flowElement instanceof SequenceFlow){return;}//此处判断如果是“连线节点”,则跳过处理。
          System.out.println("flowelement id:" + flowElement.getId() + "  name:" + flowElement.getName() + "   class:" + flowElement.getClass().toString());
          if(flowElement instanceof EndEvent){//此处判断是否为结束节点,对应还有StartEvent开始节点
              String idd = "";
                List<SequenceFlow> alowList = ((org.activiti.bpmn.model.FlowNode) flowElement).getIncomingFlows();//获取入线信息-->获取所有上级节点
                List<SequenceFlow> sequenceFlowList = ((org.activiti.bpmn.model.FlowNode) flowElement).getOutgoingFlows();//获取出线信息-->获取所有下级节点
                for (SequenceFlow sequenceFlow : alowList) {//循环并可以获得所有上级节点id(父节点id),用于存储本地数据库
      sequenceFlow.getSourceRef();//对应父节点和子节点的id

      //其余属性可根据自己的需求来进行查看获取
                }

猜你喜欢

转载自www.cnblogs.com/mangwusuozhi/p/10460085.html
今日推荐