diff --git a/lib/import/BpmnTreeWalker.js b/lib/import/BpmnTreeWalker.js index 8c4d9a56..9951e8cf 100644 --- a/lib/import/BpmnTreeWalker.js +++ b/lib/import/BpmnTreeWalker.js @@ -118,8 +118,7 @@ function BpmnTreeWalker(handler) { if (is(rootElement, 'bpmn:Process')) { handleProcess(rootElement); - } else - if (is(rootElement, 'bpmn:Collaboration')) { + } else if (is(rootElement, 'bpmn:Collaboration')) { handleCollaboration(rootElement); // force drawing of everything not yet drawn that is part of the target DI @@ -129,17 +128,37 @@ function BpmnTreeWalker(handler) { } } + function handleProcess(process, context) { + handleFlowElementsContainer(process, context); + handleIoSpecification(process.ioSpecification, context); + + handleArtifacts(process.artifacts, context); + + // log process handled + handledProcesses.push(process); + } + function handleUnhandledProcesses(rootElements) { // walk through all processes that have not yet been drawn and draw them // (in case they contain lanes with DI information) var processes = _.filter(rootElements, function(e) { + //Need this fix to get run test-case "01" return e.$type === 'bpmn:Process' && e.laneSets && handledProcesses.indexOf(e) === -1; }); - processes.forEach(contextual(handleProcess)); } + function handleMessageFlow(messageFlow, context) { + visitIfDi(messageFlow, context); + } + + function handleMessageFlows(messageFlows, context) { + if (messageFlows) { + _.forEach(messageFlows, contextual(handleMessageFlow, context)); + } + } + function handleDataAssociation(association, context) { visitIfDi(association, context); } @@ -203,13 +222,20 @@ function BpmnTreeWalker(handler) { visitIfDi(dataObject, context); } + function handleBoundaryElement(dataObject, context) { + visitIfDi(dataObject, context); + } + function handleLane(lane, context) { var newContext = visitIfDi(lane, context); if (lane.childLaneSet) { handleLaneSet(lane.childLaneSet, newContext || context); } else { - handleFlowElements(lane.flowNodeRef, newContext || context); + var filterList = _.filter(lane.flowNodeRef, function(e) { + return e.$type !== 'bpmn:BoundaryEvent'; + }); + handleFlowElements(filterList, newContext || context); } } @@ -233,43 +259,45 @@ function BpmnTreeWalker(handler) { function handleNonFlowNodes(flowElements, context) { var sequenceFlows = []; + var boundaryEvents = []; _.forEach(flowElements, function(e) { if (is(e, 'bpmn:SequenceFlow')) { sequenceFlows.push(e); - } else - if (is(e, 'bpmn:DataObject')) { + } else if (is(e, 'bpmn:DataObject')) { // SKIP (assume correct referencing via DataObjectReference) - } else - if (is(e, 'bpmn:DataStoreReference')) { + } else if (is(e, 'bpmn:DataStoreReference')) { handleDataElement(e, context); - } else - if (is(e, 'bpmn:DataObjectReference')) { + } else if (is(e, 'bpmn:DataObjectReference')) { handleDataElement(e, context); + } else if (is(e, 'bpmn:BoundaryEvent')) { + boundaryEvents.push(e); } }); + // handle boundary events + _.forEach(boundaryEvents, contextual(handleBoundaryElement, context)); + // handle SequenceFlows _.forEach(sequenceFlows, contextual(handleSequenceFlow, context)); } function handleFlowElements(flowElements, context) { var sequenceFlows = []; + var boundaryEvents = []; _.forEach(flowElements, function(e) { if (is(e, 'bpmn:SequenceFlow')) { sequenceFlows.push(e); - } else - if (is(e, 'bpmn:FlowNode')) { + } else if (is(e, 'bpmn:BoundaryEvent')) { + boundaryEvents.push(e); + } else if (is(e, 'bpmn:FlowNode')) { handleFlowNode(e, context); - } else - if (is(e, 'bpmn:DataObject')) { + } else if (is(e, 'bpmn:DataObject')) { // SKIP (assume correct referencing via DataObjectReference) - } else - if (is(e, 'bpmn:DataStoreReference')) { + } else if (is(e, 'bpmn:DataStoreReference')) { handleDataElement(e, context); - } else - if (is(e, 'bpmn:DataObjectReference')) { + } else if (is(e, 'bpmn:DataObjectReference')) { handleDataElement(e, context); } else { logError( @@ -278,6 +306,9 @@ function BpmnTreeWalker(handler) { } }); + // handle boundary events + _.forEach(boundaryEvents, contextual(handleBoundaryElement, context)); + // handle SequenceFlows _.forEach(sequenceFlows, contextual(handleSequenceFlow, context)); } @@ -291,26 +322,6 @@ function BpmnTreeWalker(handler) { } } - function handleProcess(process, context) { - handleFlowElementsContainer(process, context); - handleIoSpecification(process.ioSpecification, context); - - handleArtifacts(process.artifacts, context); - - // log process handled - handledProcesses.push(process); - } - - function handleMessageFlow(messageFlow, context) { - visitIfDi(messageFlow, context); - } - - function handleMessageFlows(messageFlows, context) { - if (messageFlows) { - _.forEach(messageFlows, contextual(handleMessageFlow, context)); - } - } - function handleCollaboration(collaboration) { _.forEach(collaboration.participants, contextual(handleParticipant)); diff --git a/test/fixtures/bpmn/draw/boundary-event-with-refnode.bpmn b/test/fixtures/bpmn/draw/boundary-event-with-refnode.bpmn new file mode 100644 index 00000000..4571ef58 --- /dev/null +++ b/test/fixtures/bpmn/draw/boundary-event-with-refnode.bpmn @@ -0,0 +1,81 @@ + + + + + + + + + + + _d58753a7-d38b-49cd-914d-14e4cdaa4449 + End_Event + Boundary_Event + + + + + + sid-4F795442-BADE-4AD2-AC9A-C51F90503931 + + + + sid-4F795442-BADE-4AD2-AC9A-C51F90503931 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/fixtures/bpmn/draw/boundary-event-without-refnode.bpmn b/test/fixtures/bpmn/draw/boundary-event-without-refnode.bpmn new file mode 100644 index 00000000..89b3fb1a --- /dev/null +++ b/test/fixtures/bpmn/draw/boundary-event-without-refnode.bpmn @@ -0,0 +1,81 @@ + + + + + + + + + + + _d58753a7-d38b-49cd-914d-14e4cdaa4449 + End_Event + + + + + + + sid-4F795442-BADE-4AD2-AC9A-C51F90503931 + + + + sid-4F795442-BADE-4AD2-AC9A-C51F90503931 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/fixtures/bpmn/draw/boundary-event-z-index.bpmn b/test/fixtures/bpmn/draw/boundary-event-z-index.bpmn new file mode 100644 index 00000000..ad295905 --- /dev/null +++ b/test/fixtures/bpmn/draw/boundary-event-z-index.bpmn @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/fixtures/bpmn/features/label-editing/labels.bpmn b/test/fixtures/bpmn/features/label-editing/labels.bpmn index 97814d5c..353148ec 100644 --- a/test/fixtures/bpmn/features/label-editing/labels.bpmn +++ b/test/fixtures/bpmn/features/label-editing/labels.bpmn @@ -22,7 +22,6 @@ call-activity user-task - boundary-event diff --git a/test/spec/browser/draw/BpmnRendererSpec.js b/test/spec/browser/draw/BpmnRendererSpec.js index 071d4def..1b6e59fb 100644 --- a/test/spec/browser/draw/BpmnRendererSpec.js +++ b/test/spec/browser/draw/BpmnRendererSpec.js @@ -132,4 +132,19 @@ describe('draw - bpmn renderer', function() { bootstrapBpmnJS(xml)(done); }); + it('should render boundary events with correct z-index', function(done) { + var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/boundary-event-z-index.bpmn', 'utf8'); + bootstrapBpmnJS(xml)(done); + }); + + it('should render boundary events without flowNodeRef', function(done) { + var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/boundary-event-without-refnode.bpmn', 'utf8'); + bootstrapBpmnJS(xml)(done); + }); + + it('should render boundary event only once if referenced incorrectly via flowNodeRef (robustness)', function(done) { + var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/boundary-event-with-refnode.bpmn', 'utf8'); + bootstrapBpmnJS(xml)(done); + }); + }); \ No newline at end of file