function getLabelAttr(semantic) { if (semantic.$instanceOf('bpmn:FlowElement') || semantic.$instanceOf('bpmn:Participant') || semantic.$instanceOf('bpmn:Lane') || semantic.$instanceOf('bpmn:SequenceFlow') || semantic.$instanceOf('bpmn:MessageFlow')) { return 'name'; } if (semantic.$instanceOf('bpmn:TextAnnotation')) { return 'text'; } } module.exports.getLabel = function(semantic) { var attr = getLabelAttr(semantic); if (attr) { return semantic[attr] || ''; } }; module.exports.setLabel = function(semantic, label) { var attr = getLabelAttr(semantic); if (attr) { semantic[attr] = label; } };