2017-07-18 109 views
0

我正在嘗試使用Java和Activiti可視化現有工作流程。如何使用Activiti將註釋添加到工作流程

我在後臺使用自己的工作流引擎,但它真的不清楚,因爲它只是以表格形式呈現工作流數據。這就是爲什麼我想將表格中的數據轉換爲標準BPMN 2.0表單的原因。因此使用包org.activiti.bpmn.model。不同的任務由UserTask類創建,SequenceFlows按預期生成,並且佈局由Activiti的自動bpmn佈局功能設計。我現在的問題是不同的前提條件和用戶任務的影響。在某些情況下,有太多的文本只是將它們添加爲序列流的名稱。我的想法只是添加一個節點到用戶任務,我可以添加一個包含這些東西的字符串,但我沒有找到解決此問題的適合對象。我已經嘗試了Message對象與MessageFlow對象的結合,但它並沒有像我希望的那樣工作。

創建工作流程後,它被保存爲XML文件,並檢查轉換後的工作流程是如何在bpmn.io上載的(此時包括如果XML文件以bpmn上傳時未顯示的Message對象。 io):

<?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> 

回答

1

爲什麼不在活動或順序流中使用文檔字段。 在XML,它看起來像這樣:

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

然後在BPMN編輯器將顯示爲文檔。 你真的很有趣的項目。

格雷格

+0

我曾嘗試這種方式和XML的處理部分包括描述但我已經設置爲文檔中的文本未在圖中示出。 我認爲最好使用的對象是TextAnnotation。但是我有同樣的問題。我通過addAtrifact()將TextAnnotation附加到流程實例。但是提供佈局信息的XML的底部不包含關於該對象的任何信息,因此它也不會顯示在圖中。 – Sasa

+0

因此,現在我知道我需要一個將UserTask與TextAnnotation鏈接起來的關聯,但是當執行BpmnAutoLayout時我會得到一個NPE。失敗的方法是generateAssociationDiagramInterchangeElements()。在執行getState(Edge)時,該方法以某種方式接收空值。 – Sasa