DiUtil.js 1.3 KB

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