Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
InitialRenderVisitor.prototype.visit = function(element, parentShape) {
// avoid multiple rendering of elements
if (element.gfx) {
throw new Error('already rendered ' + elementToString(element));
}
return this._add(element, parentShape);
};
// love to model such as cross participant / sub process
// associations
parentShape = null;
}
// insert sequence flows behind other flow nodes (cf. #727)
let parentIndex;
if (is(semantic, 'bpmn:SequenceFlow')) {
parentIndex = 0;
}
this._canvas.addConnection(element, parentShape, parentIndex);
} else {
throw new Error(this._translate('unknown di {di} for element {semantic}', {
di: elementToString(di),
semantic: elementToString(semantic)
}));
}
// (optional) external LABEL
if (isLabelExternal(semantic) && semantic.name) {
this._addLabel(semantic, element);
}
} else {
if (isMessageFlow) {
/*
* Messages are attached to a participant band. They are separate shapes
* but move with the band. They do not have an underlying DI element.
* If no message is attached to the message flow, we first have to create one.
*/
const choreo = this._canvas.getRootElement().businessObject;
const definitions = choreo.$parent;
// associations
parentShape = null;
}
// insert sequence flows behind other flow nodes (cf. #727)
let parentIndex;
if (is(semantic, 'bpmn:SequenceFlow')) {
parentIndex = 0;
}
this._canvas.addConnection(element, parentShape, parentIndex);
} else {
throw new Error(this._translate('unknown di {di} for element {semantic}', {
di: elementToString(di),
semantic: elementToString(semantic)
}));
}
// (optional) external LABEL
if (isLabelExternal(semantic) && semantic.name) {
this._addLabel(semantic, element);
}
} else {
if (isMessageFlow) {
/*
* Messages are attached to a participant band. They are separate shapes
* but move with the band. They do not have an underlying DI element.
* If no message is attached to the message flow, we first have to create one.
*/
const choreo = this._canvas.getRootElement().businessObject;
const definitions = choreo.$parent;
let message = semantic.messageRef;
function notYetDrawn(translate, semantic, refSemantic, property) {
return new Error(translate('element {element} referenced by {referenced}#{property} not yet drawn', {
element: elementToString(refSemantic),
referenced: elementToString(semantic),
property: property
}));
}
flowElements.forEach(flowElement => {
if (is(flowElement, 'bpmn:SequenceFlow')) {
self._deferred.push(function() {
self.handleSequenceFlow(flowElement, parentShape);
});
} else if (is(flowElement, 'bpmn:BoundaryEvent')) {
self._deferred.unshift(function() {
self.handleBoundaryEvent(flowElement, parentShape);
});
} else if (is(flowElement, 'bpmn:FlowNode')) {
self.handleFlowNode(flowElement, parentShape);
} else {
throw new Error(
'unrecognized flowElement ' +
elementToString(flowElement) + ' in context ' +
(parentShape ? elementToString(parentShape.businessObject) : 'null')
);
}
});
}
function notYetDrawn(translate, semantic, refSemantic, property) {
return new Error(translate('element {element} referenced by {referenced}#{property} not yet drawn', {
element: elementToString(refSemantic),
referenced: elementToString(semantic),
property: property
}));
}
flowElements.forEach(flowElement => {
if (is(flowElement, 'bpmn:SequenceFlow')) {
self._deferred.push(function() {
self.handleSequenceFlow(flowElement, parentShape);
});
} else if (is(flowElement, 'bpmn:BoundaryEvent')) {
self._deferred.unshift(function() {
self.handleBoundaryEvent(flowElement, parentShape);
});
} else if (is(flowElement, 'bpmn:FlowNode')) {
self.handleFlowNode(flowElement, parentShape);
} else {
throw new Error(
'unrecognized flowElement ' +
elementToString(flowElement) + ' in context ' +
(parentShape ? elementToString(parentShape.businessObject) : 'null')
);
}
});
}