如何使用Activiti

时间:2017-07-18 10:35:48

标签: java xml workflow activiti bpmn

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

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

创建工作流后,它将保存为XML文件,并检查转换后的工作流程的外观,并将其上传到bpmn.io(此时包括如果XML文件在bpmn.io上传时未显示的Message对象):

<?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 个答案:

答案 0 :(得分:1)

为什么不在活动或序列流中使用文档字段。 在XML中它看起来像这样:

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

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

格雷格