Flowable:BpmnModel API

news2025/2/28 21:40:34

之前都是使用工具在绘制流程图,但是还是很少去认真的去看这个xml,有时候我们要从xml中分析获取一些结果,这个时候就要对xml及对应的api有足够的认识。

一:重新认识bpmn

在这里插入图片描述

  • definitions:根节点用于定义流程。
    • bpmndi:BPMNDiagram:绘制流程图,主要用于描述控件的id、坐标(x, y)、尺寸(width, height)等,这个节点不用关注。
    • process:定义流程,常用的属性id、name等,里面放bpmn支持的各种FlowElement流元素、流节点FlowNode。org.flowable.bpmn.model.Process
      • startEvent:开始事件,常用的属性id、name、initiatorformKey
      • userTask:用户任务,常用的属性id、name、assigneeformKey
      • parallelGateway:并行网关
      • endEvent:结束事件
      • sequenceFlow:序列流(线),常用的属性 id、sourceReftargetRef
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" xmlns:tns="http://www.activiti.org/test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" expressionLanguage="http://www.w3.org/1999/XPath" id="m1705288913012" name="" targetNamespace="http://www.activiti.org/test" typeLanguage="http://www.w3.org/2001/XMLSchema">
  <process id="VacationProcess" isClosed="false" isExecutable="true" name="请假流程" processType="None">
    <startEvent activiti:initiator="starter" id="mainStart" name="StartEvent"/>
    <userTask activiti:assignee="${starter}" activiti:exclusive="true" id="submitApply" name="提交申请"/>
    <userTask activiti:exclusive="true" id="vgm" name="副经理审批"/>
    <parallelGateway gatewayDirection="Unspecified" id="forkParallelGateway" name="ParallelGateway"/>
    <userTask activiti:exclusive="true" id="gm" name="总经理审批"/>
    <userTask activiti:exclusive="true" id="hr" name="人事审批"/>
    <parallelGateway gatewayDirection="Unspecified" id="joinParallelGateway" name="ParallelGateway"/>
    <userTask activiti:exclusive="true" id="notifyResult" name="结果通知"/>
    <endEvent id="mainEnd" name="EndEvent"/>
    
    <sequenceFlow id="_8" sourceRef="mainStart" targetRef="submitApply"/>
    <sequenceFlow id="_9" sourceRef="submitApply" targetRef="vgm"/>
    <sequenceFlow id="_10" sourceRef="vgm" targetRef="forkParallelGateway"/>
    <sequenceFlow id="_11" sourceRef="forkParallelGateway" targetRef="gm"/>
    <sequenceFlow id="_12" sourceRef="forkParallelGateway" targetRef="hr"/>
    <sequenceFlow id="_13" sourceRef="gm" targetRef="joinParallelGateway"/>
    <sequenceFlow id="_14" sourceRef="hr" targetRef="joinParallelGateway"/>
    <sequenceFlow id="_16" sourceRef="joinParallelGateway" targetRef="notifyResult"/>
    <sequenceFlow id="_18" sourceRef="notifyResult" targetRef="mainEnd"/>
  </process>


  <bpmndi:BPMNDiagram documentation="background=#3C3F41;count=1;horizontalcount=1;orientation=0;width=842.4;height=1195.2;imageableWidth=832.4;imageableHeight=1185.2;imageableX=5.0;imageableY=5.0" id="Diagram-_1" name="New Diagram">
    <bpmndi:BPMNPlane bpmnElement="VacationProcess">
      <bpmndi:BPMNShape bpmnElement="mainStart" id="Shape-mainStart">
        <omgdc:Bounds height="32.0" width="32.0" x="5.0" y="120.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="submitApply" id="Shape-submitApply">
        <omgdc:Bounds height="55.0" width="85.0" x="100.0" y="110.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="vgm" id="Shape-vgm">
        <omgdc:Bounds height="55.0" width="85.0" x="275.0" y="110.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="forkParallelGateway" id="Shape-forkParallelGateway">
        <omgdc:Bounds height="32.0" width="32.0" x="425.0" y="120.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="gm" id="Shape-gm">
        <omgdc:Bounds height="55.0" width="85.0" x="570.0" y="60.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="hr" id="Shape-hr">
        <omgdc:Bounds height="55.0" width="85.0" x="575.0" y="180.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="joinParallelGateway" id="Shape-joinParallelGateway">
        <omgdc:Bounds height="32.0" width="32.0" x="775.0" y="130.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="notifyResult" id="Shape-notifyResult">
        <omgdc:Bounds height="55.0" width="85.0" x="875.0" y="120.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="mainEnd" id="Shape-mainEnd">
        <omgdc:Bounds height="32.0" width="32.0" x="1035.0" y="130.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="_13" id="BPMNEdge__13" sourceElement="_6" targetElement="_3">
        <omgdi:waypoint x="655.0" y="87.5"/>
        <omgdi:waypoint x="775.0" y="146.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_12" id="BPMNEdge__12" sourceElement="ParallelGateway" targetElement="_7">
        <omgdi:waypoint x="457.0" y="136.0"/>
        <omgdi:waypoint x="575.0" y="207.5"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_14" id="BPMNEdge__14" sourceElement="_7" targetElement="_3">
        <omgdi:waypoint x="660.0" y="207.5"/>
        <omgdi:waypoint x="775.0" y="146.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_16" id="BPMNEdge__16" sourceElement="_3" targetElement="_15">
        <omgdi:waypoint x="807.0" y="146.0"/>
        <omgdi:waypoint x="875.0" y="147.5"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_18" id="BPMNEdge__18" sourceElement="_15" targetElement="_17">
        <omgdi:waypoint x="960.0" y="147.5"/>
        <omgdi:waypoint x="1035.0" y="146.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_8" id="BPMNEdge__8" sourceElement="_2" targetElement="submitApply">
        <omgdi:waypoint x="37.0" y="136.0"/>
        <omgdi:waypoint x="100.0" y="137.5"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_9" id="BPMNEdge__9" sourceElement="submitApply" targetElement="_4">
        <omgdi:waypoint x="185.0" y="137.5"/>
        <omgdi:waypoint x="275.0" y="137.5"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_11" id="BPMNEdge__11" sourceElement="ParallelGateway" targetElement="_6">
        <omgdi:waypoint x="457.0" y="136.0"/>
        <omgdi:waypoint x="570.0" y="87.5"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_10" id="BPMNEdge__10" sourceElement="_4" targetElement="ParallelGateway">
        <omgdi:waypoint x="360.0" y="137.5"/>
        <omgdi:waypoint x="425.0" y="136.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

二:API

2.1 xml与BpmnModel互相转换

String bpmnXml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" +
        "<definitions xmlns=\"http://www.omg.org/spec/BPMN/20100524/MODEL\" xmlns:activiti=\"http://activiti.org/bpmn\" xmlns:bpmndi=\"http://www.omg.org/spec/BPMN/20100524/DI\" xmlns:omgdc=\"http://www.omg.org/spec/DD/20100524/DC\" xmlns:omgdi=\"http://www.omg.org/spec/DD/20100524/DI\" xmlns:tns=\"http://www.activiti.org/test\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" expressionLanguage=\"http://www.w3.org/1999/XPath\" id=\"m1705288913012\" name=\"\" targetNamespace=\"http://www.activiti.org/test\" typeLanguage=\"http://www.w3.org/2001/XMLSchema\">\n" +
        "  <process id=\"VacationProcess\" isClosed=\"false\" isExecutable=\"true\" name=\"请假流程\" processType=\"None\">\n" +
        "    <startEvent activiti:initiator=\"starter\" id=\"mainStart\" name=\"StartEvent\"/>\n" +
        "    <userTask activiti:assignee=\"${starter}\" activiti:exclusive=\"true\" id=\"submitApply\" name=\"提交申请\"/>\n" +
        "    <userTask activiti:exclusive=\"true\" id=\"vgm\" name=\"副经理审批\"/>\n" +
        "    <parallelGateway gatewayDirection=\"Unspecified\" id=\"forkParallelGateway\" name=\"ParallelGateway\"/>\n" +
        "    <userTask activiti:exclusive=\"true\" id=\"gm\" name=\"总经理审批\"/>\n" +
        "    <userTask activiti:exclusive=\"true\" id=\"hr\" name=\"人事审批\"/>\n" +
        "    <parallelGateway gatewayDirection=\"Unspecified\" id=\"joinParallelGateway\" name=\"ParallelGateway\"/>\n" +
        "    <userTask activiti:exclusive=\"true\" id=\"notifyResult\" name=\"结果通知\"/>\n" +
        "    <endEvent id=\"mainEnd\" name=\"EndEvent\"/>\n" +
        "    \n" +
        "    <sequenceFlow id=\"_8\" sourceRef=\"mainStart\" targetRef=\"submitApply\"/>\n" +
        "    <sequenceFlow id=\"_9\" sourceRef=\"submitApply\" targetRef=\"vgm\"/>\n" +
        "    <sequenceFlow id=\"_10\" sourceRef=\"vgm\" targetRef=\"forkParallelGateway\"/>\n" +
        "    <sequenceFlow id=\"_11\" sourceRef=\"forkParallelGateway\" targetRef=\"gm\"/>\n" +
        "    <sequenceFlow id=\"_12\" sourceRef=\"forkParallelGateway\" targetRef=\"hr\"/>\n" +
        "    <sequenceFlow id=\"_13\" sourceRef=\"gm\" targetRef=\"joinParallelGateway\"/>\n" +
        "    <sequenceFlow id=\"_14\" sourceRef=\"hr\" targetRef=\"joinParallelGateway\"/>\n" +
        "    <sequenceFlow id=\"_16\" sourceRef=\"joinParallelGateway\" targetRef=\"notifyResult\"/>\n" +
        "    <sequenceFlow id=\"_18\" sourceRef=\"notifyResult\" targetRef=\"mainEnd\"/>\n" +
        "  </process>\n" +
        "  <bpmndi:BPMNDiagram documentation=\"background=#3C3F41;count=1;horizontalcount=1;orientation=0;width=842.4;height=1195.2;imageableWidth=832.4;imageableHeight=1185.2;imageableX=5.0;imageableY=5.0\" id=\"Diagram-_1\" name=\"New Diagram\">\n" +
        "    <bpmndi:BPMNPlane bpmnElement=\"VacationProcess\">\n" +
        "      <bpmndi:BPMNShape bpmnElement=\"mainStart\" id=\"Shape-mainStart\">\n" +
        "        <omgdc:Bounds height=\"32.0\" width=\"32.0\" x=\"5.0\" y=\"120.0\"/>\n" +
        "        <bpmndi:BPMNLabel>\n" +
        "          <omgdc:Bounds height=\"32.0\" width=\"32.0\" x=\"0.0\" y=\"0.0\"/>\n" +
        "        </bpmndi:BPMNLabel>\n" +
        "      </bpmndi:BPMNShape>\n" +
        "      <bpmndi:BPMNShape bpmnElement=\"submitApply\" id=\"Shape-submitApply\">\n" +
        "        <omgdc:Bounds height=\"55.0\" width=\"85.0\" x=\"100.0\" y=\"110.0\"/>\n" +
        "        <bpmndi:BPMNLabel>\n" +
        "          <omgdc:Bounds height=\"55.0\" width=\"85.0\" x=\"0.0\" y=\"0.0\"/>\n" +
        "        </bpmndi:BPMNLabel>\n" +
        "      </bpmndi:BPMNShape>\n" +
        "      <bpmndi:BPMNShape bpmnElement=\"vgm\" id=\"Shape-vgm\">\n" +
        "        <omgdc:Bounds height=\"55.0\" width=\"85.0\" x=\"275.0\" y=\"110.0\"/>\n" +
        "        <bpmndi:BPMNLabel>\n" +
        "          <omgdc:Bounds height=\"55.0\" width=\"85.0\" x=\"0.0\" y=\"0.0\"/>\n" +
        "        </bpmndi:BPMNLabel>\n" +
        "      </bpmndi:BPMNShape>\n" +
        "      <bpmndi:BPMNShape bpmnElement=\"forkParallelGateway\" id=\"Shape-forkParallelGateway\">\n" +
        "        <omgdc:Bounds height=\"32.0\" width=\"32.0\" x=\"425.0\" y=\"120.0\"/>\n" +
        "        <bpmndi:BPMNLabel>\n" +
        "          <omgdc:Bounds height=\"32.0\" width=\"32.0\" x=\"0.0\" y=\"0.0\"/>\n" +
        "        </bpmndi:BPMNLabel>\n" +
        "      </bpmndi:BPMNShape>\n" +
        "      <bpmndi:BPMNShape bpmnElement=\"gm\" id=\"Shape-gm\">\n" +
        "        <omgdc:Bounds height=\"55.0\" width=\"85.0\" x=\"570.0\" y=\"60.0\"/>\n" +
        "        <bpmndi:BPMNLabel>\n" +
        "          <omgdc:Bounds height=\"55.0\" width=\"85.0\" x=\"0.0\" y=\"0.0\"/>\n" +
        "        </bpmndi:BPMNLabel>\n" +
        "      </bpmndi:BPMNShape>\n" +
        "      <bpmndi:BPMNShape bpmnElement=\"hr\" id=\"Shape-hr\">\n" +
        "        <omgdc:Bounds height=\"55.0\" width=\"85.0\" x=\"575.0\" y=\"180.0\"/>\n" +
        "        <bpmndi:BPMNLabel>\n" +
        "          <omgdc:Bounds height=\"55.0\" width=\"85.0\" x=\"0.0\" y=\"0.0\"/>\n" +
        "        </bpmndi:BPMNLabel>\n" +
        "      </bpmndi:BPMNShape>\n" +
        "      <bpmndi:BPMNShape bpmnElement=\"joinParallelGateway\" id=\"Shape-joinParallelGateway\">\n" +
        "        <omgdc:Bounds height=\"32.0\" width=\"32.0\" x=\"775.0\" y=\"130.0\"/>\n" +
        "        <bpmndi:BPMNLabel>\n" +
        "          <omgdc:Bounds height=\"32.0\" width=\"32.0\" x=\"0.0\" y=\"0.0\"/>\n" +
        "        </bpmndi:BPMNLabel>\n" +
        "      </bpmndi:BPMNShape>\n" +
        "      <bpmndi:BPMNShape bpmnElement=\"notifyResult\" id=\"Shape-notifyResult\">\n" +
        "        <omgdc:Bounds height=\"55.0\" width=\"85.0\" x=\"875.0\" y=\"120.0\"/>\n" +
        "        <bpmndi:BPMNLabel>\n" +
        "          <omgdc:Bounds height=\"55.0\" width=\"85.0\" x=\"0.0\" y=\"0.0\"/>\n" +
        "        </bpmndi:BPMNLabel>\n" +
        "      </bpmndi:BPMNShape>\n" +
        "      <bpmndi:BPMNShape bpmnElement=\"mainEnd\" id=\"Shape-mainEnd\">\n" +
        "        <omgdc:Bounds height=\"32.0\" width=\"32.0\" x=\"1035.0\" y=\"130.0\"/>\n" +
        "        <bpmndi:BPMNLabel>\n" +
        "          <omgdc:Bounds height=\"32.0\" width=\"32.0\" x=\"0.0\" y=\"0.0\"/>\n" +
        "        </bpmndi:BPMNLabel>\n" +
        "      </bpmndi:BPMNShape>\n" +
        "      <bpmndi:BPMNEdge bpmnElement=\"_13\" id=\"BPMNEdge__13\" sourceElement=\"_6\" targetElement=\"_3\">\n" +
        "        <omgdi:waypoint x=\"655.0\" y=\"87.5\"/>\n" +
        "        <omgdi:waypoint x=\"775.0\" y=\"146.0\"/>\n" +
        "        <bpmndi:BPMNLabel>\n" +
        "          <omgdc:Bounds height=\"0.0\" width=\"0.0\" x=\"0.0\" y=\"0.0\"/>\n" +
        "        </bpmndi:BPMNLabel>\n" +
        "      </bpmndi:BPMNEdge>\n" +
        "      <bpmndi:BPMNEdge bpmnElement=\"_12\" id=\"BPMNEdge__12\" sourceElement=\"ParallelGateway\" targetElement=\"_7\">\n" +
        "        <omgdi:waypoint x=\"457.0\" y=\"136.0\"/>\n" +
        "        <omgdi:waypoint x=\"575.0\" y=\"207.5\"/>\n" +
        "        <bpmndi:BPMNLabel>\n" +
        "          <omgdc:Bounds height=\"0.0\" width=\"0.0\" x=\"0.0\" y=\"0.0\"/>\n" +
        "        </bpmndi:BPMNLabel>\n" +
        "      </bpmndi:BPMNEdge>\n" +
        "      <bpmndi:BPMNEdge bpmnElement=\"_14\" id=\"BPMNEdge__14\" sourceElement=\"_7\" targetElement=\"_3\">\n" +
        "        <omgdi:waypoint x=\"660.0\" y=\"207.5\"/>\n" +
        "        <omgdi:waypoint x=\"775.0\" y=\"146.0\"/>\n" +
        "        <bpmndi:BPMNLabel>\n" +
        "          <omgdc:Bounds height=\"0.0\" width=\"0.0\" x=\"0.0\" y=\"0.0\"/>\n" +
        "        </bpmndi:BPMNLabel>\n" +
        "      </bpmndi:BPMNEdge>\n" +
        "      <bpmndi:BPMNEdge bpmnElement=\"_16\" id=\"BPMNEdge__16\" sourceElement=\"_3\" targetElement=\"_15\">\n" +
        "        <omgdi:waypoint x=\"807.0\" y=\"146.0\"/>\n" +
        "        <omgdi:waypoint x=\"875.0\" y=\"147.5\"/>\n" +
        "        <bpmndi:BPMNLabel>\n" +
        "          <omgdc:Bounds height=\"0.0\" width=\"0.0\" x=\"0.0\" y=\"0.0\"/>\n" +
        "        </bpmndi:BPMNLabel>\n" +
        "      </bpmndi:BPMNEdge>\n" +
        "      <bpmndi:BPMNEdge bpmnElement=\"_18\" id=\"BPMNEdge__18\" sourceElement=\"_15\" targetElement=\"_17\">\n" +
        "        <omgdi:waypoint x=\"960.0\" y=\"147.5\"/>\n" +
        "        <omgdi:waypoint x=\"1035.0\" y=\"146.0\"/>\n" +
        "        <bpmndi:BPMNLabel>\n" +
        "          <omgdc:Bounds height=\"0.0\" width=\"0.0\" x=\"0.0\" y=\"0.0\"/>\n" +
        "        </bpmndi:BPMNLabel>\n" +
        "      </bpmndi:BPMNEdge>\n" +
        "      <bpmndi:BPMNEdge bpmnElement=\"_8\" id=\"BPMNEdge__8\" sourceElement=\"_2\" targetElement=\"submitApply\">\n" +
        "        <omgdi:waypoint x=\"37.0\" y=\"136.0\"/>\n" +
        "        <omgdi:waypoint x=\"100.0\" y=\"137.5\"/>\n" +
        "        <bpmndi:BPMNLabel>\n" +
        "          <omgdc:Bounds height=\"0.0\" width=\"0.0\" x=\"0.0\" y=\"0.0\"/>\n" +
        "        </bpmndi:BPMNLabel>\n" +
        "      </bpmndi:BPMNEdge>\n" +
        "      <bpmndi:BPMNEdge bpmnElement=\"_9\" id=\"BPMNEdge__9\" sourceElement=\"submitApply\" targetElement=\"_4\">\n" +
        "        <omgdi:waypoint x=\"185.0\" y=\"137.5\"/>\n" +
        "        <omgdi:waypoint x=\"275.0\" y=\"137.5\"/>\n" +
        "        <bpmndi:BPMNLabel>\n" +
        "          <omgdc:Bounds height=\"0.0\" width=\"0.0\" x=\"0.0\" y=\"0.0\"/>\n" +
        "        </bpmndi:BPMNLabel>\n" +
        "      </bpmndi:BPMNEdge>\n" +
        "      <bpmndi:BPMNEdge bpmnElement=\"_11\" id=\"BPMNEdge__11\" sourceElement=\"ParallelGateway\" targetElement=\"_6\">\n" +
        "        <omgdi:waypoint x=\"457.0\" y=\"136.0\"/>\n" +
        "        <omgdi:waypoint x=\"570.0\" y=\"87.5\"/>\n" +
        "        <bpmndi:BPMNLabel>\n" +
        "          <omgdc:Bounds height=\"0.0\" width=\"0.0\" x=\"0.0\" y=\"0.0\"/>\n" +
        "        </bpmndi:BPMNLabel>\n" +
        "      </bpmndi:BPMNEdge>\n" +
        "      <bpmndi:BPMNEdge bpmnElement=\"_10\" id=\"BPMNEdge__10\" sourceElement=\"_4\" targetElement=\"ParallelGateway\">\n" +
        "        <omgdi:waypoint x=\"360.0\" y=\"137.5\"/>\n" +
        "        <omgdi:waypoint x=\"425.0\" y=\"136.0\"/>\n" +
        "        <bpmndi:BPMNLabel>\n" +
        "          <omgdc:Bounds height=\"0.0\" width=\"0.0\" x=\"0.0\" y=\"0.0\"/>\n" +
        "        </bpmndi:BPMNLabel>\n" +
        "      </bpmndi:BPMNEdge>\n" +
        "    </bpmndi:BPMNPlane>\n" +
        "  </bpmndi:BPMNDiagram>\n" +
        "</definitions>\n";
BpmnXMLConverter bpmnXMLConverter = new BpmnXMLConverter();
BpmnModel bpmnModel = bpmnXMLConverter.convertToBpmnModel(new StringStreamSource(bpmnXml), false, false);

byte[] bytes = bpmnXMLConverter.convertToXML(bpmnModel);
String xml = StrUtil.utf8Str(bytes);

根据taskId获取BpmnModel。

String taskId = "11";
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(task.getProcessDefinitionId()).singleResult();
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId());

保存act_ge_model。

BpmnModel bpmnModel = null;
Process process = bpmnModel.getMainProcess();
String modelKey = "model" + new Date().getTime();
Map<String, Object> metaInfo = new HashMap<>();
metaInfo.put("createUser", "zhangsan");
metaInfo.put("description", "拓展用的元数据可以存任意参数");
metaInfo.put("formId", "关联的表单主键id");

Model model = repositoryService.newModel();
model.setName(process.getName());
model.setKey(modelKey);
model.setCategory("Category1");
// 存一个拓展信息的json: 比如描述,创建人,外键id等
model.setMetaInfo(new JSONObject(metaInfo).toString());
model.setVersion(1);
repositoryService.saveModel(model);

// 保存act_ge_bytearray.bytes_
Model model1 = repositoryService.createModelQuery().modelKey(modelKey).singleResult();
byte[] bpmnXmlBytes = StringUtils.getBytes(bpmnXml, StandardCharsets.UTF_8);
// ACT_RE_MODEL.editor_source_value_id = re_re_bytearry.id_
repositoryService.addModelEditorSource(model1.getId(), bpmnXmlBytes);

根据modelId获取BpmnModel对象。

String modeId = "2501";
Model model = repositoryService.createModelQuery().modelId(modeId).singleResult();

byte[] bytes = repositoryService.getModelEditorSource(modeId);
String bpmnXml = StringUtils.toEncodedString(bytes, StandardCharsets.UTF_8);
BpmnXMLConverter bpmnXMLConverter = new BpmnXMLConverter();
BpmnModel bpmnModel = bpmnXMLConverter.convertToBpmnModel(new StringStreamSource(bpmnXml), false, false);
System.out.println(bpmnModel);

三:BpmnModel

StartEvent extends Event extends FlowNode extends FlowElement extends BaseElement.

UserTask extends Task extends Activity extends FlowNode extends FlowElement extends BaseElement.

public class BpmnModel {
	// 获取流程图中的第一个Process对象
	public Process getMainProcess();
}
public class Process {
	// 获取所有流元素
	public Collection<FlowElement> getFlowElements();
	// 获取所有流元素
	public Map<String, FlowElement> getFlowElementMap();
	// 根据taskDefKey获取元素
	public FlowElement getFlowElement(String flowElementId);
	// 获取初始化元素(开始节点)
	public FlowElement getInitialFlowElement();
	// 获取元素父容器:EventSubProcess、SubProcess、Processs等
	public FlowElementsContainer getFlowElementsContainer(String flowElementId);
}

一般情况一个节点至少有一个入口连线,一个出口连线。
注意:StrartEvent只有一个出口连线,EndEvent没有出口连线。

public abstract class FlowNode extends FlowElement {
	// 入口
	public List<SequenceFlow> getIncomingFlows();
	// 出口
	public List<SequenceFlow> getOutgoingFlows();

}

public abstract class Activity extends FlowNode {
	// 是否多实例
	public boolean hasMultiInstanceLoopCharacteristics();
}

注意:Process下面元素都属于FlowElement的子类(StartEvent、UserTask、Gateway、SubProcess、EndEvent、SequenceFlow等)。

public abstract class FlowElement extends BaseElement {
	public FlowElementsContainer getParentContainer();
}
public class SequenceFlow extends FlowElement {
	// 获取id
	public String getId();
	// 获取源流元素
	public FlowElement getSourceFlowElement();
	// 获取目标流元素
	public FlowElement getTargetFlowElement();
}
public abstract class BaseElement {
	// 获取扩展属性
	public Map<String, List<ExtensionAttribute>> getAttributes();
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1388215.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

台式OLED透明屏的6大基本要素

台式 OLED 透明屏作为一种创新的显示技术&#xff0c;正逐渐走进人们的视野。本文将为您全面介绍台式 OLED 透明屏的各个方面&#xff0c;包括类别、尺寸、技术参数原理、应用、主要厂家&#xff08;尼伽&#xff09;以及价格因素。 一、类别台式 OLED 透明屏根据不同的需求和应…

Java 实现双链表

文章目录 双链表&#xff08;Doubly Linked List&#xff09;是一种常用的数据结构&#xff0c;它与单链表相似&#xff0c;但每个节点除了包含指向下一个节点的指针外&#xff0c;还包含一个指向前一个节点的指针。 双链表的节点由三部分组成&#xff1a;数据域&#xff08;存…

帆软报表11.0.19增加postgres数据源方案

项目使用postgres数据库&#xff0c;帆软报表集成开发时需要手工增加该数据源。 https://help.fanruan.com/finereport/doc-view-2563.html 但增加数据源后测试报告无此驱动&#xff0c;经查看文档&#xff0c;现在是通过驱动管理来上传&#xff0c; 但新版又不允许上传驱动JAR…

威尔·库尔特《趣学贝叶斯统计:橡皮鸭、乐高和星球大战中的统计学》学习笔记(1):以A/B测试为例学习贝叶斯统计

主要是新学期的概率论的作业要求&#xff1a;Write a summary (no more than of a page) of your experience with an application of probability to a real-life situation (e.g., an engineering problem. –How was probability used to model the phenomena/situation?…

力扣刷题(无重复字符的最长子串)

3. 无重复字符的最长子串https://leetcode.cn/problems/longest-substring-without-repeating-characters/ 给定一个字符串 s &#xff0c;请你找出其中不含有重复字符的 最长子串 的长度。 示例 1: 输入: s "abcabcbb" 输出: 3 解释: 因为无重复字符的最长子串是…

【Emgu.CV教程】5.3、几何变换之金字塔变换

这一段文字描述来自百度百科&#xff1a; 图像金字塔是图像多尺度表达的一种&#xff0c;是一种以多分辨率来解释图像的有效但概念简单的结构。一幅图像的图像金字塔是一系列以金字塔形状&#xff08;自下而上&#xff09;逐步降低&#xff0c;且来源于同一张原始图的图像分辨率…

6、CLIP:连接文本和视觉世界的预训练模型

目录 一、论文题目 二、背景与动机 三、创新与卖点 四、技术细节 模型结构 简易代码 clip实现zero shot分类 五、为什么是CLIP?为什么是对比学习&#xff1f; 六、一些资料 在人工智能领域&#xff0c;文本和图像是两个极其重要的数据形式。传统上&#xff0c;机器学…

python 集合的详细用法

当前版本&#xff1a; Python 3.8.4 简介 Python中的集合是一种无序、可哈希的且不重复的数据类型&#xff0c;用于存储唯一的元素。集合的实现基于哈希表&#xff0c;因此在插入、查找和删除元素时具有高效性能。集合的每个元素都必须是不可变的&#xff0c;可以是数字、字符…

阿里AnyText:多语种图像文字嵌入的突破

模型简介 随着Midjourney、Stable Difusion等产品的兴起&#xff0c;文生图像技术迅速发展。然而&#xff0c;在图像中生成或嵌入精准文本一直是一个挑战&#xff0c;尤其是对中文的支持。阿里巴巴的研究人员开发了AnyText&#xff0c;这是一个多语言视觉文字生成与编辑模型&a…

SpringBoot 全局异常统一处理:BindException(绑定异常)

概述 在Spring Boot应用中&#xff0c;数据绑定是一个至关重要的环节&#xff0c;它负责将HTTP请求中的参数映射到控制器方法的入参对象上。在这个过程中如果遇到任何问题&#xff0c;如参数缺失、类型不匹配或验证失败等&#xff0c;Spring MVC将会抛出一个org.springframewo…

安达发|APS工序排程甘特图功能介绍

工序排程甘特图的主要功能 1. 显示工序时间安排&#xff1a;工序排程甘特图可以清晰地展示生产过程中各个工序的开始时间、结束时间和持续时间&#xff0c;从而帮助企业了解生产过程中各个环节的时间安排。 2. 显示工序进度情况&#xff1a;通过工序排程甘特图&#xff0c;企业…

通过myBatis将sql语句返回的值自动包装成一个java对象(3)

1.如果sql字段和java字段名字不一样怎么办&#xff1f; 之前我们将sql返回值转换为java对象时&#xff0c;每条sql的返回值的字段名和java类中的字段名是一一对应的&#xff0c;ie&#xff1a;sql选择的user有username和password两个字段&#xff0c;java中的user对象也有两个…

开源项目CuteSqlite开发笔记(七):CuteSqlite释放BETA版本啦

经过大半年的开发&#xff0c;CuteSqlite程序代码不知不觉来到了6万行&#xff0c;有效行数4万行&#xff0c;CuteSqlite开发完成了一个小版本&#xff0c;进入下一个阶段&#xff0c;并于2024元旦释放BETA版本&#xff0c;有兴趣的朋友可以下载试用。 GitHub下载https://gith…

Linux系统下编译MPlayer

一、编译MPlayer 在 http://www.mplayerhq.hu/design7/dload.html 下载MPlayer源码 执行命令&#xff1a; tar -xf MPlayer-1.5.tar.xz cd MPlayer-1.5 ./configure --prefix$(pwd)/install --yasm make make install 然后在install/bin目录下即会生成mplayer的可执行文件 二…

基于Java+SSM的技术的社区人口管理系统详细设计和实现【附源码】

基于JavaSSM的技术的社区人口管理系统详细设计和实现 &#x1f345; 作者主页 央顺技术团队 &#x1f345; 欢迎点赞 &#x1f44d; 收藏 ⭐留言 &#x1f4dd; &#x1f345; 文末获取源码联系方式 &#x1f4dd; &#x1f345; 查看下方微信号获取联系方式 承接各种定制系统 …

elasticsearch[一]-索引库操作(轻松创建)、文档增删改查、批量写入(效率倍增)

elasticsearch[一]-索引库操作(轻松创建)、文档增删改查、批量写入(效率倍增) 1、初始化 RestClient 在 elasticsearch 提供的 API 中&#xff0c;与 elasticsearch 一切交互都封装在一个名为 RestHighLevelClient 的类中&#xff0c;必须先完成这个对象的初始化&#xff0c;…

Vue知识总结-下

VUE-组件间通信 组件的自定义事件 概述&#xff1a;是一种组件间通信的方式,适用于&#xff1a;子组件>父组件使用场景&#xff1a;A是父组件,B是子组件,B给A传递数据,那么需要在A组件中绑定自定义事件(事件的回调也在A中)使用步骤 绑定自定义事件&#xff1a; 第一种方式…

2024年AMC8历年真题练一练和答案详解(9),以及全真模拟题

“熟读唐诗三百首,不会作诗也会吟”&#xff0c;反复做真题、吃透真题、查漏补缺并举一反三是在各类考试、比赛中得高分的重要学习方法之一&#xff0c;参加AMC8竞赛也是如此。 六分成长继续为您分享AMC8历年真题&#xff0c;最后几天&#xff0c;通过高质量的真题来体会快速思…

dp--62. 不同路径/medium 理解度A

62. 不同路径 1、题目2、题目分析3、复杂度最优解代码示例4、抽象与扩展 1、题目 给定一个包含非负整数的 m x n 网格 grid &#xff0c;请找出一条从左上角到右下角的路径&#xff0c;使得路径上的数字总和为最小。 说明&#xff1a;每次只能向下或者向右移动一步。 示例 1&…

Rust-NLL(Non-Lexical-Lifetime)

Rust防范“内存不安全”代码的原则极其清晰明了。 如果你对同一块内存存在多个引用&#xff0c;就不要试图对这块内存做修改&#xff1b;如果你需要对一块内存做修改&#xff0c;就不要同时保留多个引用。 只要保证了这个原则&#xff0c;我们就可以保证内存安全。 它在实践…