尽管模型不完整,但 Camunda BPMN 验证成功
Camunda BPMN validation successful although model is incomplete
我在bpmn.io设计了一个不完整的bpmn流程(见下文xml,你可以在bpmn.io上加载到modeler中)。
下一步我写了一个简单的验证函数according to this guide。功能也在下面。
问题
我的问题是,尽管模型似乎无效(没有 endEvent,只有一个 sequenceFlow 从 xor 网关发出),但没有抛出任何错误。 BPMN class 中的 validateModel 方法只是从其内部解析器调用相同的方法。我是不是错过了之前定义方案之类的东西,还是我完全误解了有效的 bpmn 是什么样子以及如何验证它?
验证方法
public String validateModel(String modelString) {
String message = "";
try {
InputStream stream = new ByteArrayInputStream(modelString.getBytes(Charset.forName("UTF-8")));
BpmnParser parser = new BpmnParser();
BpmnModelInstance modelinstance = parser.parseModelFromStream(stream);
parser.validateModel(modelinstance.getDocument());
Bpmn.validateModel(modelinstance); //does the same as above, just added for completeness
message = "Model is conform!";
} catch (Exception e) {
message = e.getMessage();
}
return message;
}
BPMN XML内容
<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="sample-diagram" targetNamespace="http://bpmn.io/schema/bpmn" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
<bpmn2:process id="Process_1" isExecutable="false">
<bpmn2:startEvent id="StartEvent_1">
<bpmn2:outgoing>SequenceFlow_061afhx</bpmn2:outgoing>
</bpmn2:startEvent>
<bpmn2:task id="Task_06azz4c">
<bpmn2:incoming>SequenceFlow_061afhx</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_0lw11e7</bpmn2:outgoing>
</bpmn2:task>
<bpmn2:sequenceFlow id="SequenceFlow_061afhx" sourceRef="StartEvent_1" targetRef="Task_06azz4c" />
<bpmn2:exclusiveGateway id="ExclusiveGateway_0eezp6n">
<bpmn2:incoming>SequenceFlow_0lw11e7</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_06uvwwf</bpmn2:outgoing>
</bpmn2:exclusiveGateway>
<bpmn2:sequenceFlow id="SequenceFlow_0lw11e7" sourceRef="Task_06azz4c" targetRef="ExclusiveGateway_0eezp6n" />
<bpmn2:task id="Task_1j0gerp">
<bpmn2:incoming>SequenceFlow_06uvwwf</bpmn2:incoming>
</bpmn2:task>
<bpmn2:sequenceFlow id="SequenceFlow_06uvwwf" sourceRef="ExclusiveGateway_0eezp6n" targetRef="Task_1j0gerp" />
</bpmn2:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="412" y="240" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_06azz4c_di" bpmnElement="Task_06azz4c">
<dc:Bounds x="647" y="218" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_061afhx_di" bpmnElement="SequenceFlow_061afhx">
<di:waypoint xsi:type="dc:Point" x="448" y="258" />
<di:waypoint xsi:type="dc:Point" x="503" y="258" />
<di:waypoint xsi:type="dc:Point" x="503" y="258" />
<di:waypoint xsi:type="dc:Point" x="647" y="258" />
<bpmndi:BPMNLabel>
<dc:Bounds x="457" y="253" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="ExclusiveGateway_0eezp6n_di" bpmnElement="ExclusiveGateway_0eezp6n" isMarkerVisible="true">
<dc:Bounds x="672" y="60" width="50" height="50" />
<bpmndi:BPMNLabel>
<dc:Bounds x="652" y="110" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_0lw11e7_di" bpmnElement="SequenceFlow_0lw11e7">
<di:waypoint xsi:type="dc:Point" x="697" y="218" />
<di:waypoint xsi:type="dc:Point" x="697" y="110" />
<bpmndi:BPMNLabel>
<dc:Bounds x="631" y="97" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Task_1j0gerp_di" bpmnElement="Task_1j0gerp">
<dc:Bounds x="899" y="45" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_06uvwwf_di" bpmnElement="SequenceFlow_06uvwwf">
<di:waypoint xsi:type="dc:Point" x="722" y="85" />
<di:waypoint xsi:type="dc:Point" x="899" y="85" />
<bpmndi:BPMNLabel>
<dc:Bounds x="765.5" y="75" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>
您的模型是有效的 BPMN 模型。验证根据 XSD 方案检查 XML 文件。这不会也无法检查您的模型是否设计良好或一致。
我在bpmn.io设计了一个不完整的bpmn流程(见下文xml,你可以在bpmn.io上加载到modeler中)。
下一步我写了一个简单的验证函数according to this guide。功能也在下面。
问题
我的问题是,尽管模型似乎无效(没有 endEvent,只有一个 sequenceFlow 从 xor 网关发出),但没有抛出任何错误。 BPMN class 中的 validateModel 方法只是从其内部解析器调用相同的方法。我是不是错过了之前定义方案之类的东西,还是我完全误解了有效的 bpmn 是什么样子以及如何验证它?
验证方法
public String validateModel(String modelString) {
String message = "";
try {
InputStream stream = new ByteArrayInputStream(modelString.getBytes(Charset.forName("UTF-8")));
BpmnParser parser = new BpmnParser();
BpmnModelInstance modelinstance = parser.parseModelFromStream(stream);
parser.validateModel(modelinstance.getDocument());
Bpmn.validateModel(modelinstance); //does the same as above, just added for completeness
message = "Model is conform!";
} catch (Exception e) {
message = e.getMessage();
}
return message;
}
BPMN XML内容
<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="sample-diagram" targetNamespace="http://bpmn.io/schema/bpmn" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
<bpmn2:process id="Process_1" isExecutable="false">
<bpmn2:startEvent id="StartEvent_1">
<bpmn2:outgoing>SequenceFlow_061afhx</bpmn2:outgoing>
</bpmn2:startEvent>
<bpmn2:task id="Task_06azz4c">
<bpmn2:incoming>SequenceFlow_061afhx</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_0lw11e7</bpmn2:outgoing>
</bpmn2:task>
<bpmn2:sequenceFlow id="SequenceFlow_061afhx" sourceRef="StartEvent_1" targetRef="Task_06azz4c" />
<bpmn2:exclusiveGateway id="ExclusiveGateway_0eezp6n">
<bpmn2:incoming>SequenceFlow_0lw11e7</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_06uvwwf</bpmn2:outgoing>
</bpmn2:exclusiveGateway>
<bpmn2:sequenceFlow id="SequenceFlow_0lw11e7" sourceRef="Task_06azz4c" targetRef="ExclusiveGateway_0eezp6n" />
<bpmn2:task id="Task_1j0gerp">
<bpmn2:incoming>SequenceFlow_06uvwwf</bpmn2:incoming>
</bpmn2:task>
<bpmn2:sequenceFlow id="SequenceFlow_06uvwwf" sourceRef="ExclusiveGateway_0eezp6n" targetRef="Task_1j0gerp" />
</bpmn2:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="412" y="240" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_06azz4c_di" bpmnElement="Task_06azz4c">
<dc:Bounds x="647" y="218" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_061afhx_di" bpmnElement="SequenceFlow_061afhx">
<di:waypoint xsi:type="dc:Point" x="448" y="258" />
<di:waypoint xsi:type="dc:Point" x="503" y="258" />
<di:waypoint xsi:type="dc:Point" x="503" y="258" />
<di:waypoint xsi:type="dc:Point" x="647" y="258" />
<bpmndi:BPMNLabel>
<dc:Bounds x="457" y="253" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="ExclusiveGateway_0eezp6n_di" bpmnElement="ExclusiveGateway_0eezp6n" isMarkerVisible="true">
<dc:Bounds x="672" y="60" width="50" height="50" />
<bpmndi:BPMNLabel>
<dc:Bounds x="652" y="110" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_0lw11e7_di" bpmnElement="SequenceFlow_0lw11e7">
<di:waypoint xsi:type="dc:Point" x="697" y="218" />
<di:waypoint xsi:type="dc:Point" x="697" y="110" />
<bpmndi:BPMNLabel>
<dc:Bounds x="631" y="97" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Task_1j0gerp_di" bpmnElement="Task_1j0gerp">
<dc:Bounds x="899" y="45" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_06uvwwf_di" bpmnElement="SequenceFlow_06uvwwf">
<di:waypoint xsi:type="dc:Point" x="722" y="85" />
<di:waypoint xsi:type="dc:Point" x="899" y="85" />
<bpmndi:BPMNLabel>
<dc:Bounds x="765.5" y="75" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>
您的模型是有效的 BPMN 模型。验证根据 XSD 方案检查 XML 文件。这不会也无法检查您的模型是否设计良好或一致。