2015-04-27 14:50:09 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var is = require('./ModelUtil').is,
|
|
|
|
getBusinessObject = require('./ModelUtil').getBusinessObject;
|
|
|
|
|
2016-11-09 10:45:12 +00:00
|
|
|
var forEach = require('lodash/collection/forEach');
|
|
|
|
|
2015-04-27 14:50:09 +00:00
|
|
|
module.exports.isExpanded = function(element) {
|
|
|
|
|
|
|
|
if (is(element, 'bpmn:CallActivity')) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is(element, 'bpmn:SubProcess')) {
|
2016-01-27 14:11:27 +00:00
|
|
|
return !!getBusinessObject(element).di.isExpanded;
|
2015-04-27 14:50:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (is(element, 'bpmn:Participant')) {
|
|
|
|
return !!getBusinessObject(element).processRef;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
};
|
2015-08-04 15:52:43 +00:00
|
|
|
|
2015-08-11 09:58:30 +00:00
|
|
|
module.exports.isInterrupting = function(element) {
|
|
|
|
return element && getBusinessObject(element).isInterrupting !== false;
|
|
|
|
};
|
|
|
|
|
2015-08-04 15:52:43 +00:00
|
|
|
module.exports.isEventSubProcess = function(element) {
|
|
|
|
return element && !!getBusinessObject(element).triggeredByEvent;
|
|
|
|
};
|
2016-11-09 10:45:12 +00:00
|
|
|
|
|
|
|
function hasEventDefinition(element, eventType) {
|
|
|
|
var bo = getBusinessObject(element),
|
|
|
|
hasEventDefinition = false;
|
|
|
|
|
|
|
|
if (bo.eventDefinitions) {
|
|
|
|
forEach(bo.eventDefinitions, function(event) {
|
|
|
|
if (is(event, eventType)) {
|
|
|
|
hasEventDefinition = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return hasEventDefinition;
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports.hasEventDefinition = hasEventDefinition;
|
|
|
|
|
|
|
|
module.exports.hasErrorEventDefinition = function(element) {
|
|
|
|
return hasEventDefinition(element, 'bpmn:ErrorEventDefinition');
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports.hasEscalationEventDefinition = function(element) {
|
|
|
|
return hasEventDefinition(element, 'bpmn:EscalationEventDefinition');
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports.hasCompensateEventDefinition = function(element) {
|
|
|
|
return hasEventDefinition(element, 'bpmn:CompensateEventDefinition');
|
|
|
|
};
|