fix(import): handle multiple DI elements per semantic

Closes #158
This commit is contained in:
Nico Rehwaldt 2014-11-26 20:54:52 +01:00
parent e2aaf342f7
commit f363356fcb
3 changed files with 47 additions and 2 deletions

View File

@ -76,8 +76,12 @@ function BpmnTreeWalker(handler) {
var bpmnElement = di.bpmnElement;
if (bpmnElement) {
diRefs.bind(bpmnElement, 'di');
bpmnElement.di = di;
if (bpmnElement.di) {
logError('multiple DI elements defined for ' + elementToString(bpmnElement), { element: bpmnElement });
} else {
diRefs.bind(bpmnElement, 'di');
bpmnElement.di = di;
}
} else {
logError('no bpmnElement referenced in ' + elementToString(di), { element: di });
}

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:bpmn="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"
xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"
id="gateway-testcase"
targetNamespace="http://bpmn.io/schema/bpmn">
<bpmn:process id="Process_1">
<bpmn:inclusiveGateway id="InclusiveGateway_1"/>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
<bpmndi:BPMNShape id="_BPMNShape_InclusiveGateway_2" bpmnElement="InclusiveGateway_1">
<dc:Bounds height="50.0" width="50.0" x="114.0" y="99.0"/>
</bpmndi:BPMNShape>
<!-- second DI element for InclusiveGateway_1 -->
<bpmndi:BPMNShape id="_BPMNShape_InclusiveGateway_2" bpmnElement="InclusiveGateway_1">
<dc:Bounds height="50.0" width="50.0" x="114.0" y="129.0"/>
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

View File

@ -277,6 +277,23 @@ describe('import - importer', function() {
});
});
it('should import multiple dis', function(done) {
// given
var xml = fs.readFileSync('test/fixtures/bpmn/error/multiple-dis.bpmn', 'utf8');
// when
runImport(diagram, xml, function(err, warnings) {
expect(warnings.length).toBe(1);
expect(warnings[0].message).toBe('multiple DI elements defined for <bpmn:InclusiveGateway id="InclusiveGateway_1" />');
done(err);
});
});
it('should extend missing attribute with default value', function(done) {
// given