2015-04-27 14:50:09 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Is an element of the given BPMN type?
|
|
|
|
*
|
|
|
|
* @param {djs.model.Base|ModdleElement} element
|
|
|
|
* @param {String} type
|
|
|
|
*
|
|
|
|
* @return {Boolean}
|
|
|
|
*/
|
|
|
|
function is(element, type) {
|
|
|
|
var bo = getBusinessObject(element);
|
|
|
|
|
2015-08-10 13:13:34 +00:00
|
|
|
return bo && (typeof bo.$instanceOf === 'function') && bo.$instanceOf(type);
|
2015-04-27 14:50:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports.is = is;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the business object for a given element.
|
|
|
|
*
|
|
|
|
* @param {djs.model.Base|ModdleElement} element
|
|
|
|
*
|
|
|
|
* @return {ModdleElement}
|
|
|
|
*/
|
|
|
|
function getBusinessObject(element) {
|
|
|
|
return (element && element.businessObject) || element;
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports.getBusinessObject = getBusinessObject;
|