UNPKG

1.37 kBJavaScriptView Raw
1import {
2 is,
3 getBusinessObject
4} from './ModelUtil';
5
6import {
7 forEach
8} from 'min-dash';
9
10
11export function isExpanded(element) {
12
13 if (is(element, 'bpmn:CallActivity')) {
14 return false;
15 }
16
17 if (is(element, 'bpmn:SubProcess')) {
18 return !!getBusinessObject(element).di.isExpanded;
19 }
20
21 if (is(element, 'bpmn:Participant')) {
22 return !!getBusinessObject(element).processRef;
23 }
24
25 return true;
26}
27
28export function isInterrupting(element) {
29 return element && getBusinessObject(element).isInterrupting !== false;
30}
31
32export function isEventSubProcess(element) {
33 return element && !!getBusinessObject(element).triggeredByEvent;
34}
35
36export function hasEventDefinition(element, eventType) {
37 var bo = getBusinessObject(element),
38 hasEventDefinition = false;
39
40 if (bo.eventDefinitions) {
41 forEach(bo.eventDefinitions, function(event) {
42 if (is(event, eventType)) {
43 hasEventDefinition = true;
44 }
45 });
46 }
47
48 return hasEventDefinition;
49}
50
51export function hasErrorEventDefinition(element) {
52 return hasEventDefinition(element, 'bpmn:ErrorEventDefinition');
53}
54
55export function hasEscalationEventDefinition(element) {
56 return hasEventDefinition(element, 'bpmn:EscalationEventDefinition');
57}
58
59export function hasCompensateEventDefinition(element) {
60 return hasEventDefinition(element, 'bpmn:CompensateEventDefinition');
61}