如何使用 Activiti 向工作流添加注释



我正在尝试使用Java和Activiti可视化现有的工作流程。

我在后台使用自己的工作流引擎,但确实不清楚,因为它只是以表格形式呈现工作流数据。这就是为什么我想将表中的数据转换为标准的BPMN 2.0表单。因此,使用包org.activiti.bpmn.model。不同的任务由UserTask类创建,SequenceFlows按预期生成,布局由Activiti的自动bpmn布局功能设计。我现在的问题是不同的前提条件和用户任务的影响。在某些情况下,它们太多了,以至于仅将它们添加为序列流的名称会是太多的文本。我的想法只是向用户任务添加一个节点,我可以在其中添加一个包含这些内容的字符串,但我没有找到解决此问题的合适对象。我已经尝试将消息对象与 MessageFlow 对象结合使用,但它没有像我希望的那样工作。

创建工作流后,它被保存为 XML 文件,为了检查转换后的工作流的外观,它会在 bpmn.io 处上传(目前包括一个 Message 对象,如果在 bpmn.io 上传 XML 文件,则不会显示该对象(:

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" 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" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
<message id="message123" name="This is a test message" itemRef="ut5"></message>
<process id="process" name="New Prod" isExecutable="true">
<startEvent id="startEvent" name="New Product"></startEvent>
<exclusiveGateway id="exclusiveGateway1"></exclusiveGateway>
<sequenceFlow id="sequenceFlow-672ba4b9-2f30-41b4-b638-bb05cde15cde" sourceRef="startEvent" targetRef="exclusiveGateway1"></sequenceFlow>
<userTask id="ut1" name="Workbox Musterprodukte"></userTask>
<sequenceFlow id="sequenceFlow-20c9fdf5-52f4-4c8c-9d30-9522b8cac16b" name="Check: mobile Category set" sourceRef="exclusiveGateway1" targetRef="ut1"></sequenceFlow>
<exclusiveGateway id="exclusiveGateway2"></exclusiveGateway>
<sequenceFlow id="sequenceFlow-0651ad02-735a-4311-bf3c-55bb6146e764" sourceRef="ut1" targetRef="exclusiveGateway2"></sequenceFlow>
<sequenceFlow id="sequenceFlow-039e61e4-6404-4fc8-b074-606ec2e0032a" name="Check: mobile Category NOT set" sourceRef="exclusiveGateway1" targetRef="exclusiveGateway2"></sequenceFlow>
<userTask id="ut2" name="Step1"></userTask>
<sequenceFlow id="sequenceFlow-833b5285-e302-4ab3-a0fc-b1442ec4909f" sourceRef="exclusiveGateway2" targetRef="ut2"></sequenceFlow>
<parallelGateway id="pg1"></parallelGateway>
<userTask id="ut3" name="Step2A"></userTask>
<userTask id="ut4" name="Step2B"></userTask>
<sequenceFlow id="sequenceFlow-b5f991a9-4d2c-4537-8ab2-7d5a6449cdf1" sourceRef="ut2" targetRef="pg1"></sequenceFlow>
<sequenceFlow id="sequenceFlow-7c12d9ea-c96f-4715-a8a5-39654053225a" name="Check: Main Image available" sourceRef="pg1" targetRef="ut3"></sequenceFlow>
<sequenceFlow id="sequenceFlow-19439ed1-2af5-43c4-8abf-df013fe24cdc" name="toom_Freigabe_CM = y" sourceRef="pg1" targetRef="ut4"></sequenceFlow>
<parallelGateway id="pg2"></parallelGateway>
<sequenceFlow id="sequenceFlow-faf33a66-a6db-4636-8ddf-d46484dbaa1e" sourceRef="ut3" targetRef="pg2"></sequenceFlow>
<sequenceFlow id="sequenceFlow-6180eea1-14e6-47c8-9e68-d6c3aed0b322" sourceRef="ut4" targetRef="pg2"></sequenceFlow>
<userTask id="ut5" name="Step3"></userTask>
<sequenceFlow id="sequenceFlow-efb2cef7-0b4a-410b-b076-19f0cf0a97ce" sourceRef="pg2" targetRef="ut5"></sequenceFlow>
<endEvent id="end" name="Step4"></endEvent>
<sequenceFlow id="sequenceFlow-7129e658-6004-4004-907b-f1ea6d5602a3" sourceRef="ut5" targetRef="end"></sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_process">
<bpmndi:BPMNPlane bpmnElement="process" id="BPMNPlane_process">
<bpmndi:BPMNShape bpmnElement="ut2" id="BPMNShape_ut2">
<omgdc:Bounds height="60.0" width="100.0" x="410.0" y="73.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="ut1" id="BPMNShape_ut1">
<omgdc:Bounds height="60.0" width="100.0" x="170.0" y="130.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="exclusiveGateway2" id="BPMNShape_exclusiveGateway2">
<omgdc:Bounds height="40.0" width="40.0" x="320.0" y="78.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="exclusiveGateway1" id="BPMNShape_exclusiveGateway1">
<omgdc:Bounds height="40.0" width="40.0" x="80.0" y="76.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="ut4" id="BPMNShape_ut4">
<omgdc:Bounds height="60.0" width="100.0" x="650.0" y="160.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="ut3" id="BPMNShape_ut3">
<omgdc:Bounds height="60.0" width="100.0" x="650.0" y="0.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="startEvent" id="BPMNShape_startEvent">
<omgdc:Bounds height="30.0" width="30.0" x="0.0" y="81.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="ut5" id="BPMNShape_ut5">
<omgdc:Bounds height="60.0" width="100.0" x="890.0" y="80.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="pg2" id="BPMNShape_pg2">
<omgdc:Bounds height="40.0" width="40.0" x="800.0" y="90.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="end" id="BPMNShape_end">
<omgdc:Bounds height="30.0" width="30.0" x="1040.0" y="95.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="pg1" id="BPMNShape_pg1">
<omgdc:Bounds height="40.0" width="40.0" x="560.0" y="88.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow-7129e658-6004-4004-907b-f1ea6d5602a3" id="BPMNEdge_sequenceFlow-7129e658-6004-4004-907b-f1ea6d5602a3">
<omgdi:waypoint x="990.0" y="110.0"></omgdi:waypoint>
<omgdi:waypoint x="1040.0" y="110.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow-efb2cef7-0b4a-410b-b076-19f0cf0a97ce" id="BPMNEdge_sequenceFlow-efb2cef7-0b4a-410b-b076-19f0cf0a97ce">
<omgdi:waypoint x="840.0" y="110.0"></omgdi:waypoint>
<omgdi:waypoint x="890.0" y="110.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow-672ba4b9-2f30-41b4-b638-bb05cde15cde" id="BPMNEdge_sequenceFlow-672ba4b9-2f30-41b4-b638-bb05cde15cde">
<omgdi:waypoint x="30.0" y="96.0"></omgdi:waypoint>
<omgdi:waypoint x="80.0" y="96.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow-039e61e4-6404-4fc8-b074-606ec2e0032a" id="BPMNEdge_sequenceFlow-039e61e4-6404-4fc8-b074-606ec2e0032a">
<omgdi:waypoint x="120.0" y="88.5"></omgdi:waypoint>
<omgdi:waypoint x="132.0" y="88.5"></omgdi:waypoint>
<omgdi:waypoint x="132.0" y="98.0"></omgdi:waypoint>
<omgdi:waypoint x="320.0" y="98.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow-833b5285-e302-4ab3-a0fc-b1442ec4909f" id="BPMNEdge_sequenceFlow-833b5285-e302-4ab3-a0fc-b1442ec4909f">
<omgdi:waypoint x="360.0" y="98.0"></omgdi:waypoint>
<omgdi:waypoint x="372.0" y="98.0"></omgdi:waypoint>
<omgdi:waypoint x="372.0" y="103.0"></omgdi:waypoint>
<omgdi:waypoint x="410.0" y="103.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow-6180eea1-14e6-47c8-9e68-d6c3aed0b322" id="BPMNEdge_sequenceFlow-6180eea1-14e6-47c8-9e68-d6c3aed0b322">
<omgdi:waypoint x="750.0" y="190.0"></omgdi:waypoint>
<omgdi:waypoint x="762.0" y="190.0"></omgdi:waypoint>
<omgdi:waypoint x="762.0" y="110.0"></omgdi:waypoint>
<omgdi:waypoint x="800.0" y="110.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow-0651ad02-735a-4311-bf3c-55bb6146e764" id="BPMNEdge_sequenceFlow-0651ad02-735a-4311-bf3c-55bb6146e764">
<omgdi:waypoint x="270.0" y="160.0"></omgdi:waypoint>
<omgdi:waypoint x="282.0" y="160.0"></omgdi:waypoint>
<omgdi:waypoint x="282.0" y="98.0"></omgdi:waypoint>
<omgdi:waypoint x="320.0" y="98.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow-b5f991a9-4d2c-4537-8ab2-7d5a6449cdf1" id="BPMNEdge_sequenceFlow-b5f991a9-4d2c-4537-8ab2-7d5a6449cdf1">
<omgdi:waypoint x="510.0" y="103.0"></omgdi:waypoint>
<omgdi:waypoint x="522.0" y="103.0"></omgdi:waypoint>
<omgdi:waypoint x="522.0" y="108.0"></omgdi:waypoint>
<omgdi:waypoint x="560.0" y="108.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow-faf33a66-a6db-4636-8ddf-d46484dbaa1e" id="BPMNEdge_sequenceFlow-faf33a66-a6db-4636-8ddf-d46484dbaa1e">
<omgdi:waypoint x="750.0" y="30.0"></omgdi:waypoint>
<omgdi:waypoint x="762.0" y="30.0"></omgdi:waypoint>
<omgdi:waypoint x="762.0" y="110.0"></omgdi:waypoint>
<omgdi:waypoint x="800.0" y="110.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow-7c12d9ea-c96f-4715-a8a5-39654053225a" id="BPMNEdge_sequenceFlow-7c12d9ea-c96f-4715-a8a5-39654053225a">
<omgdi:waypoint x="600.0" y="100.5"></omgdi:waypoint>
<omgdi:waypoint x="612.0" y="100.5"></omgdi:waypoint>
<omgdi:waypoint x="612.0" y="30.000000000000007"></omgdi:waypoint>
<omgdi:waypoint x="650.0" y="30.000000000000007"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow-20c9fdf5-52f4-4c8c-9d30-9522b8cac16b" id="BPMNEdge_sequenceFlow-20c9fdf5-52f4-4c8c-9d30-9522b8cac16b">
<omgdi:waypoint x="120.0" y="103.5"></omgdi:waypoint>
<omgdi:waypoint x="132.0" y="103.5"></omgdi:waypoint>
<omgdi:waypoint x="132.0" y="160.0"></omgdi:waypoint>
<omgdi:waypoint x="170.0" y="160.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow-19439ed1-2af5-43c4-8abf-df013fe24cdc" id="BPMNEdge_sequenceFlow-19439ed1-2af5-43c4-8abf-df013fe24cdc">
<omgdi:waypoint x="600.0" y="115.5"></omgdi:waypoint>
<omgdi:waypoint x="612.0" y="115.5"></omgdi:waypoint>
<omgdi:waypoint x="612.0" y="190.0"></omgdi:waypoint>
<omgdi:waypoint x="650.0" y="190.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>

为什么不在活动或序列流中使用文档字段。 在 XML 中,它如下所示:

<sequenceFlow id="flow4" sourceRef="usertask1" targetRef="exclusivegateway1">
<documentation>This is some element documentation.</documentation>
</sequenceFlow>

然后在 BPMN 编辑器中,它将显示为文档。 你正在进行的非常有趣的项目。

格雷格

最新更新