SpiffWorkflow 3.0.0rc0__tar.gz → 3.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. {SpiffWorkflow-3.0.0rc0/SpiffWorkflow.egg-info → spiffworkflow-3.1.0}/PKG-INFO +1 -1
  2. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/__init__.py +21 -0
  3. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/exceptions.py +112 -0
  4. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/parser/BpmnParser.py +383 -0
  5. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/parser/ProcessParser.py +156 -0
  6. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/parser/TaskParser.py +271 -0
  7. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/parser/ValidationException.py +52 -0
  8. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/parser/__init__.py +22 -0
  9. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/parser/event_parsers.py +328 -0
  10. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/parser/node_parser.py +163 -0
  11. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/parser/schema/BPMN20.xsd +33 -0
  12. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/parser/schema/BPMNDI.xsd +100 -0
  13. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/parser/schema/DC.xsd +29 -0
  14. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/parser/schema/DI.xsd +100 -0
  15. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/parser/schema/Semantic.xsd +1559 -0
  16. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/parser/spec_description.py +53 -0
  17. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/parser/task_parsers.py +126 -0
  18. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/parser/util.py +68 -0
  19. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/script_engine/__init__.py +21 -0
  20. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/script_engine/python_engine.py +102 -0
  21. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/script_engine/python_environment.py +82 -0
  22. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/serializer/__init__.py +22 -0
  23. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/serializer/config.py +158 -0
  24. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/serializer/default/__init__.py +39 -0
  25. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/serializer/default/event_definition.py +63 -0
  26. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/serializer/default/process_spec.py +85 -0
  27. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/serializer/default/task_spec.py +225 -0
  28. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/serializer/default/workflow.py +162 -0
  29. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/serializer/exceptions.py +23 -0
  30. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/serializer/helpers/__init__.py +22 -0
  31. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/serializer/helpers/bpmn_converter.py +56 -0
  32. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/serializer/helpers/dictionary.py +134 -0
  33. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/serializer/helpers/registry.py +65 -0
  34. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/serializer/helpers/spec.py +227 -0
  35. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/serializer/migration/__init__.py +0 -0
  36. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/serializer/migration/version_1_1.py +53 -0
  37. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/serializer/migration/version_1_2.py +259 -0
  38. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/serializer/migration/version_1_3.py +171 -0
  39. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/serializer/migration/version_1_4.py +13 -0
  40. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/serializer/migration/version_migration.py +125 -0
  41. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/serializer/workflow.py +178 -0
  42. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/__init__.py +22 -0
  43. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/bpmn_process_spec.py +47 -0
  44. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/bpmn_task_spec.py +115 -0
  45. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/control.py +140 -0
  46. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/data_spec.py +107 -0
  47. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/defaults.py +113 -0
  48. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/event_definitions/__init__.py +25 -0
  49. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/event_definitions/base.py +47 -0
  50. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/event_definitions/conditional.py +14 -0
  51. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/event_definitions/item_aware_event.py +70 -0
  52. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/event_definitions/message.py +84 -0
  53. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/event_definitions/multiple.py +50 -0
  54. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/event_definitions/simple.py +39 -0
  55. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/event_definitions/timer.py +215 -0
  56. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/mixins/__init__.py +49 -0
  57. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/mixins/bpmn_spec_mixin.py +28 -0
  58. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/mixins/events/__init__.py +18 -0
  59. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/mixins/events/end_event.py +55 -0
  60. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/mixins/events/event_types.py +90 -0
  61. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/mixins/events/intermediate_event.py +62 -0
  62. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/mixins/events/start_event.py +32 -0
  63. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/mixins/exclusive_gateway.py +32 -0
  64. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/mixins/inclusive_gateway.py +131 -0
  65. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/mixins/manual_task.py +28 -0
  66. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/mixins/multiinstance_task.py +353 -0
  67. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/mixins/none_task.py +28 -0
  68. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/mixins/parallel_gateway.py +68 -0
  69. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/mixins/script_task.py +46 -0
  70. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/mixins/service_task.py +30 -0
  71. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/mixins/subworkflow_task.py +124 -0
  72. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/mixins/unstructured_join.py +62 -0
  73. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/specs/mixins/user_task.py +27 -0
  74. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/util/__init__.py +20 -0
  75. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/util/diff.py +245 -0
  76. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/util/event.py +13 -0
  77. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/util/subworkflow.py +65 -0
  78. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/util/task.py +90 -0
  79. spiffworkflow-3.1.0/SpiffWorkflow/bpmn/workflow.py +296 -0
  80. spiffworkflow-3.1.0/SpiffWorkflow/camunda/__init__.py +18 -0
  81. spiffworkflow-3.1.0/SpiffWorkflow/camunda/parser/CamundaParser.py +78 -0
  82. spiffworkflow-3.1.0/SpiffWorkflow/camunda/parser/__init__.py +20 -0
  83. spiffworkflow-3.1.0/SpiffWorkflow/camunda/parser/event_parsers.py +72 -0
  84. spiffworkflow-3.1.0/SpiffWorkflow/camunda/parser/task_spec.py +184 -0
  85. spiffworkflow-3.1.0/SpiffWorkflow/camunda/serializer/__init__.py +20 -0
  86. spiffworkflow-3.1.0/SpiffWorkflow/camunda/serializer/config.py +53 -0
  87. spiffworkflow-3.1.0/SpiffWorkflow/camunda/serializer/event_definition.py +36 -0
  88. spiffworkflow-3.1.0/SpiffWorkflow/camunda/serializer/task_spec.py +50 -0
  89. spiffworkflow-3.1.0/SpiffWorkflow/camunda/specs/__init__.py +22 -0
  90. spiffworkflow-3.1.0/SpiffWorkflow/camunda/specs/business_rule_task.py +5 -0
  91. spiffworkflow-3.1.0/SpiffWorkflow/camunda/specs/event_definitions.py +59 -0
  92. spiffworkflow-3.1.0/SpiffWorkflow/camunda/specs/multiinstance_task.py +68 -0
  93. spiffworkflow-3.1.0/SpiffWorkflow/camunda/specs/user_task.py +125 -0
  94. spiffworkflow-3.1.0/SpiffWorkflow/dmn/__init__.py +18 -0
  95. spiffworkflow-3.1.0/SpiffWorkflow/dmn/engine/DMNEngine.py +151 -0
  96. spiffworkflow-3.1.0/SpiffWorkflow/dmn/engine/__init__.py +18 -0
  97. spiffworkflow-3.1.0/SpiffWorkflow/dmn/parser/BpmnDmnParser.py +124 -0
  98. spiffworkflow-3.1.0/SpiffWorkflow/dmn/parser/DMNParser.py +205 -0
  99. spiffworkflow-3.1.0/SpiffWorkflow/dmn/parser/__init__.py +20 -0
  100. spiffworkflow-3.1.0/SpiffWorkflow/dmn/parser/schema/DC.xsd +159 -0
  101. spiffworkflow-3.1.0/SpiffWorkflow/dmn/parser/schema/DMN.xsd +438 -0
  102. spiffworkflow-3.1.0/SpiffWorkflow/dmn/parser/schema/DMN12.xsd +504 -0
  103. spiffworkflow-3.1.0/SpiffWorkflow/dmn/parser/schema/DMN13.xsd +524 -0
  104. spiffworkflow-3.1.0/SpiffWorkflow/dmn/parser/schema/DMNDI12.xsd +115 -0
  105. spiffworkflow-3.1.0/SpiffWorkflow/dmn/parser/schema/DMNDI13.xsd +108 -0
  106. spiffworkflow-3.1.0/SpiffWorkflow/dmn/serializer/__init__.py +20 -0
  107. spiffworkflow-3.1.0/SpiffWorkflow/dmn/serializer/task_spec.py +114 -0
  108. spiffworkflow-3.1.0/SpiffWorkflow/dmn/specs/__init__.py +19 -0
  109. spiffworkflow-3.1.0/SpiffWorkflow/dmn/specs/business_rule_task_mixin.py +45 -0
  110. spiffworkflow-3.1.0/SpiffWorkflow/dmn/specs/model.py +128 -0
  111. {SpiffWorkflow-3.0.0rc0 → spiffworkflow-3.1.0}/SpiffWorkflow/operators.py +3 -3
  112. spiffworkflow-3.1.0/SpiffWorkflow/serializer/__init__.py +16 -0
  113. spiffworkflow-3.1.0/SpiffWorkflow/serializer/base.py +94 -0
  114. spiffworkflow-3.1.0/SpiffWorkflow/serializer/dict.py +546 -0
  115. spiffworkflow-3.1.0/SpiffWorkflow/serializer/dotv.py +81 -0
  116. spiffworkflow-3.1.0/SpiffWorkflow/serializer/exceptions.py +27 -0
  117. spiffworkflow-3.1.0/SpiffWorkflow/serializer/json.py +70 -0
  118. spiffworkflow-3.1.0/SpiffWorkflow/serializer/prettyxml.py +318 -0
  119. spiffworkflow-3.1.0/SpiffWorkflow/serializer/xml.py +733 -0
  120. spiffworkflow-3.1.0/SpiffWorkflow/specs/AcquireMutex.py +65 -0
  121. spiffworkflow-3.1.0/SpiffWorkflow/specs/Cancel.py +68 -0
  122. spiffworkflow-3.1.0/SpiffWorkflow/specs/CancelTask.py +44 -0
  123. spiffworkflow-3.1.0/SpiffWorkflow/specs/Choose.py +74 -0
  124. spiffworkflow-3.1.0/SpiffWorkflow/specs/ExclusiveChoice.py +86 -0
  125. spiffworkflow-3.1.0/SpiffWorkflow/specs/Execute.py +86 -0
  126. spiffworkflow-3.1.0/SpiffWorkflow/specs/Gate.py +67 -0
  127. spiffworkflow-3.1.0/SpiffWorkflow/specs/Join.py +244 -0
  128. spiffworkflow-3.1.0/SpiffWorkflow/specs/Merge.py +41 -0
  129. spiffworkflow-3.1.0/SpiffWorkflow/specs/MultiChoice.py +129 -0
  130. spiffworkflow-3.1.0/SpiffWorkflow/specs/MultiInstance.py +101 -0
  131. spiffworkflow-3.1.0/SpiffWorkflow/specs/ReleaseMutex.py +60 -0
  132. spiffworkflow-3.1.0/SpiffWorkflow/specs/Simple.py +38 -0
  133. spiffworkflow-3.1.0/SpiffWorkflow/specs/StartTask.py +64 -0
  134. spiffworkflow-3.1.0/SpiffWorkflow/specs/SubWorkflow.py +143 -0
  135. spiffworkflow-3.1.0/SpiffWorkflow/specs/ThreadMerge.py +134 -0
  136. spiffworkflow-3.1.0/SpiffWorkflow/specs/ThreadSplit.py +136 -0
  137. spiffworkflow-3.1.0/SpiffWorkflow/specs/ThreadStart.py +57 -0
  138. spiffworkflow-3.1.0/SpiffWorkflow/specs/Transform.py +73 -0
  139. spiffworkflow-3.1.0/SpiffWorkflow/specs/Trigger.py +98 -0
  140. spiffworkflow-3.1.0/SpiffWorkflow/specs/WorkflowSpec.py +170 -0
  141. spiffworkflow-3.1.0/SpiffWorkflow/specs/__init__.py +38 -0
  142. spiffworkflow-3.1.0/SpiffWorkflow/specs/base.py +457 -0
  143. spiffworkflow-3.1.0/SpiffWorkflow/spiff/__init__.py +18 -0
  144. spiffworkflow-3.1.0/SpiffWorkflow/spiff/parser/__init__.py +20 -0
  145. spiffworkflow-3.1.0/SpiffWorkflow/spiff/parser/event_parsers.py +179 -0
  146. spiffworkflow-3.1.0/SpiffWorkflow/spiff/parser/process.py +98 -0
  147. spiffworkflow-3.1.0/SpiffWorkflow/spiff/parser/schema/spiffworkflow.xsd +66 -0
  148. spiffworkflow-3.1.0/SpiffWorkflow/spiff/parser/task_spec.py +205 -0
  149. spiffworkflow-3.1.0/SpiffWorkflow/spiff/serializer/__init__.py +20 -0
  150. spiffworkflow-3.1.0/SpiffWorkflow/spiff/serializer/config.py +118 -0
  151. spiffworkflow-3.1.0/SpiffWorkflow/spiff/serializer/data_spec.py +7 -0
  152. spiffworkflow-3.1.0/SpiffWorkflow/spiff/serializer/event_definition.py +53 -0
  153. spiffworkflow-3.1.0/SpiffWorkflow/spiff/serializer/task_spec.py +119 -0
  154. spiffworkflow-3.1.0/SpiffWorkflow/spiff/specs/__init__.py +20 -0
  155. spiffworkflow-3.1.0/SpiffWorkflow/spiff/specs/data_object.py +6 -0
  156. spiffworkflow-3.1.0/SpiffWorkflow/spiff/specs/defaults.py +80 -0
  157. spiffworkflow-3.1.0/SpiffWorkflow/spiff/specs/event_definitions.py +95 -0
  158. spiffworkflow-3.1.0/SpiffWorkflow/spiff/specs/mixins/__init__.py +0 -0
  159. spiffworkflow-3.1.0/SpiffWorkflow/spiff/specs/mixins/service_task.py +53 -0
  160. spiffworkflow-3.1.0/SpiffWorkflow/spiff/specs/spiff_task.py +58 -0
  161. {SpiffWorkflow-3.0.0rc0 → spiffworkflow-3.1.0}/SpiffWorkflow/task.py +24 -20
  162. spiffworkflow-3.1.0/SpiffWorkflow/util/__init__.py +16 -0
  163. spiffworkflow-3.1.0/SpiffWorkflow/util/compat.py +39 -0
  164. spiffworkflow-3.1.0/SpiffWorkflow/util/deep_merge.py +65 -0
  165. spiffworkflow-3.1.0/SpiffWorkflow/util/event.py +245 -0
  166. spiffworkflow-3.1.0/SpiffWorkflow/util/levenshtein.py +38 -0
  167. spiffworkflow-3.1.0/SpiffWorkflow/util/task.py +267 -0
  168. spiffworkflow-3.1.0/SpiffWorkflow/util/weakmethod.py +134 -0
  169. spiffworkflow-3.1.0/SpiffWorkflow/version.py +1 -0
  170. {SpiffWorkflow-3.0.0rc0 → spiffworkflow-3.1.0}/SpiffWorkflow/workflow.py +32 -23
  171. {SpiffWorkflow-3.0.0rc0 → spiffworkflow-3.1.0/SpiffWorkflow.egg-info}/PKG-INFO +1 -1
  172. spiffworkflow-3.1.0/SpiffWorkflow.egg-info/SOURCES.txt +180 -0
  173. {SpiffWorkflow-3.0.0rc0 → spiffworkflow-3.1.0}/pyproject.toml +3 -2
  174. SpiffWorkflow-3.0.0rc0/SpiffWorkflow/version.py +0 -1
  175. SpiffWorkflow-3.0.0rc0/SpiffWorkflow.egg-info/SOURCES.txt +0 -15
  176. {SpiffWorkflow-3.0.0rc0 → spiffworkflow-3.1.0}/AUTHORS +0 -0
  177. {SpiffWorkflow-3.0.0rc0 → spiffworkflow-3.1.0}/COPYING +0 -0
  178. {SpiffWorkflow-3.0.0rc0 → spiffworkflow-3.1.0}/README.md +0 -0
  179. {SpiffWorkflow-3.0.0rc0 → spiffworkflow-3.1.0}/SpiffWorkflow/__init__.py +0 -0
  180. {SpiffWorkflow-3.0.0rc0 → spiffworkflow-3.1.0}/SpiffWorkflow/exceptions.py +0 -0
  181. {SpiffWorkflow-3.0.0rc0 → spiffworkflow-3.1.0}/SpiffWorkflow.egg-info/dependency_links.txt +0 -0
  182. {SpiffWorkflow-3.0.0rc0 → spiffworkflow-3.1.0}/SpiffWorkflow.egg-info/requires.txt +0 -0
  183. {SpiffWorkflow-3.0.0rc0 → spiffworkflow-3.1.0}/SpiffWorkflow.egg-info/top_level.txt +0 -0
  184. {SpiffWorkflow-3.0.0rc0 → spiffworkflow-3.1.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: SpiffWorkflow
3
- Version: 3.0.0rc0
3
+ Version: 3.1.0
4
4
  Summary: A workflow framework and BPMN/DMN Processor
5
5
  Author-email: Sartography <dan@sartography.com>
6
6
  License: lGPLv3
@@ -0,0 +1,21 @@
1
+ # Copyright (C) 2012 Matthew Hampton, 2023 Sartography
2
+ #
3
+ # This file is part of SpiffWorkflow.
4
+ #
5
+ # SpiffWorkflow is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 3.0 of the License, or (at your option) any later version.
9
+ #
10
+ # SpiffWorkflow is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
+ # 02110-1301 USA
19
+
20
+ from .workflow import BpmnWorkflow
21
+ from .util import BpmnEvent
@@ -0,0 +1,112 @@
1
+ # Copyright (C) 2023 Sartography
2
+ #
3
+ # This file is part of SpiffWorkflow.
4
+ #
5
+ # SpiffWorkflow is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 3.0 of the License, or (at your option) any later version.
9
+ #
10
+ # SpiffWorkflow is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
+ # 02110-1301 USA
19
+ import re
20
+
21
+ from SpiffWorkflow.util import levenshtein
22
+ from SpiffWorkflow.exceptions import WorkflowException
23
+
24
+
25
+ class WorkflowTaskException(WorkflowException):
26
+ """WorkflowException that provides task_trace information."""
27
+
28
+ def __init__(self, error_msg, task=None, exception=None, line_number=None, offset=None, error_line=None):
29
+ """
30
+ Exception initialization.
31
+
32
+ :param task: the task that threw the exception
33
+ :type task: Task
34
+ :param error_msg: a human readable error message
35
+ :type error_msg: str
36
+ :param exception: an exception to wrap, if any
37
+ :type exception: Exception
38
+ """
39
+ self.task = task
40
+ self.line_number = line_number
41
+ self.offset = offset
42
+ self.error_line = error_line
43
+ if exception:
44
+ self.error_type = exception.__class__.__name__
45
+ else:
46
+ self.error_type = "unknown"
47
+ super().__init__(error_msg, task_spec=task.task_spec)
48
+
49
+ if isinstance(exception, SyntaxError) and not line_number:
50
+ # Line number and offset can be recovered directly from syntax errors,
51
+ # otherwise they must be passed in.
52
+ self.line_number = exception.lineno
53
+ self.offset = exception.offset
54
+ elif isinstance(exception, NameError):
55
+ self.add_note(self.did_you_mean_from_name_error(exception, list(task.data.keys())))
56
+
57
+ # If encountered in a sub-workflow, this traces back up the stack,
58
+ # so we can tell how we got to this particular task, no matter how
59
+ # deeply nested in sub-workflows it is. Takes the form of:
60
+ # task-description (file-name)
61
+ self.task_trace = self.get_task_trace(task)
62
+
63
+ @staticmethod
64
+ def get_task_trace(task):
65
+ task_trace = [f"{task.task_spec.bpmn_name} ({task.workflow.spec.file})"]
66
+ top = task.workflow.top_workflow
67
+ parent = None if task.workflow is top else task.workflow.parent_workflow
68
+
69
+ # cap the iterations to ensure we do not infinitely loop and tie up all CPU's
70
+ max_iterations = 1000
71
+ iteration = 0
72
+ caller = task
73
+ while parent is not None:
74
+ if iteration > max_iterations:
75
+ raise WorkflowException(
76
+ f"Could not find full task trace after {max_iterations} iterations.",
77
+ task_spec=task.task_spec,
78
+ )
79
+ caller = parent.get_task_from_id(caller.workflow.parent_task_id)
80
+ task_trace.append(f"{caller.task_spec.bpmn_name} ({parent.spec.file})")
81
+ parent = None if caller.workflow is top else caller.workflow.parent_workflow
82
+ iteration += 1
83
+ return task_trace
84
+
85
+ @staticmethod
86
+ def did_you_mean_from_name_error(name_exception, options):
87
+ """Returns a string along the lines of 'did you mean 'dog'? Given
88
+ a name_error, and a set of possible things that could have been called,
89
+ or an empty string if no valid suggestions come up. """
90
+ def_match = re.match("name '(.+)' is not defined", str(name_exception))
91
+ if def_match:
92
+ bad_variable = re.match("name '(.+)' is not defined", str(name_exception)).group(1)
93
+ most_similar = levenshtein.most_similar(bad_variable, options, 3)
94
+ error_msg = ""
95
+ if len(most_similar) == 1:
96
+ error_msg += f' Did you mean \'{most_similar[0]}\'?'
97
+ if len(most_similar) > 1:
98
+ error_msg += f' Did you mean one of \'{most_similar}\'?'
99
+ return error_msg
100
+
101
+
102
+ class WorkflowDataException(WorkflowTaskException):
103
+
104
+ def __init__(self, message, task, data_input=None, data_output=None):
105
+ """
106
+ :param task: the task that generated the error
107
+ :param data_input: the spec of the input variable (if a data input)
108
+ :param data_output: the spec of the output variable (if a data output)
109
+ """
110
+ super().__init__(message, task)
111
+ self.data_input = data_input
112
+ self.data_output = data_output
@@ -0,0 +1,383 @@
1
+ # Copyright (C) 2012 Matthew Hampton
2
+ #
3
+ # This file is part of SpiffWorkflow.
4
+ #
5
+ # SpiffWorkflow is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 3.0 of the License, or (at your option) any later version.
9
+ #
10
+ # SpiffWorkflow is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
+ # 02110-1301 USA
19
+
20
+ import glob
21
+ import os
22
+
23
+ from lxml import etree
24
+ from lxml.etree import LxmlError
25
+
26
+ from SpiffWorkflow.bpmn.specs.bpmn_process_spec import BpmnProcessSpec
27
+ from SpiffWorkflow.bpmn.specs.defaults import (
28
+ UserTask,
29
+ ManualTask,
30
+ NoneTask,
31
+ ScriptTask,
32
+ ServiceTask,
33
+ CallActivity,
34
+ SubWorkflowTask,
35
+ TransactionSubprocess,
36
+ InclusiveGateway,
37
+ ExclusiveGateway,
38
+ ParallelGateway,
39
+ StartEvent,
40
+ EndEvent,
41
+ IntermediateCatchEvent,
42
+ IntermediateThrowEvent,
43
+ SendTask,
44
+ ReceiveTask,
45
+ BoundaryEvent,
46
+ EventBasedGateway
47
+ )
48
+ from SpiffWorkflow.bpmn.specs.event_definitions.simple import NoneEventDefinition
49
+ from SpiffWorkflow.bpmn.specs.event_definitions.timer import TimerEventDefinition
50
+ from SpiffWorkflow.bpmn.specs.mixins.subworkflow_task import SubWorkflowTask as SubWorkflowTaskMixin
51
+ from SpiffWorkflow.bpmn.specs.mixins.events.start_event import StartEvent as StartEventMixin
52
+
53
+ from .ValidationException import ValidationException
54
+ from .ProcessParser import ProcessParser
55
+ from .node_parser import DEFAULT_NSMAP
56
+ from .spec_description import SPEC_DESCRIPTIONS
57
+ from .util import full_tag, xpath_eval, first
58
+ from .TaskParser import TaskParser
59
+ from .task_parsers import (
60
+ GatewayParser,
61
+ ConditionalGatewayParser,
62
+ CallActivityParser,
63
+ ScriptTaskParser,
64
+ SubWorkflowParser,
65
+ )
66
+ from .event_parsers import (
67
+ EventBasedGatewayParser,
68
+ StartEventParser, EndEventParser,
69
+ BoundaryEventParser,
70
+ IntermediateCatchEventParser,
71
+ IntermediateThrowEventParser,
72
+ SendTaskParser,
73
+ ReceiveTaskParser
74
+ )
75
+
76
+
77
+ XSD_PATH = os.path.join(os.path.dirname(__file__), 'schema', 'BPMN20.xsd')
78
+
79
+ class BpmnValidator:
80
+
81
+ def __init__(self, xsd_path=XSD_PATH, imports=None):
82
+ with open(xsd_path) as xsd:
83
+ schema = etree.parse(xsd)
84
+ if imports is not None:
85
+ for ns, fn in imports.items():
86
+ elem = etree.Element(
87
+ '{http://www.w3.org/2001/XMLSchema}import',
88
+ namespace=ns,
89
+ schemaLocation=fn
90
+ )
91
+ schema.getroot().insert(0, elem)
92
+ self.validator = etree.XMLSchema(schema)
93
+
94
+ def validate(self, bpmn, filename=None):
95
+ self.preprocess(bpmn)
96
+ try:
97
+ self.validator.assertValid(bpmn)
98
+ except ValidationException as ve:
99
+ ve.file_name = filename
100
+ ve.line_number = self.validator.error_log.last_error.line
101
+ except LxmlError:
102
+ last_error = self.validator.error_log.last_error
103
+ raise ValidationException(last_error.message, file_name=filename,
104
+ line_number=last_error.line)
105
+
106
+ def preprocess(self, bpmn):
107
+ # BPMN js creates invalid XML for message correlation properties and it is apparently too difficult to change
108
+ # therefore, I'll just preprocess the XML and replace the tag in order to continue validating the XML
109
+ for expr in bpmn.xpath('.//bpmn:correlationPropertyRetrievalExpression/bpmn:formalExpression', namespaces=DEFAULT_NSMAP):
110
+ expr.tag = '{' + DEFAULT_NSMAP['bpmn'] + '}messagePath'
111
+
112
+ class BpmnParser(object):
113
+ """
114
+ The BpmnParser class is a pluggable base class that manages the parsing of
115
+ a set of BPMN files. It is intended that this class will be overriden by an
116
+ application that implements a BPMN engine.
117
+
118
+ Extension points: OVERRIDE_PARSER_CLASSES provides a map from full BPMN tag
119
+ name to a TaskParser and Task class. PROCESS_PARSER_CLASS provides a
120
+ subclass of ProcessParser. DATA_STORE_CLASSES provides a mapping of names to
121
+ subclasses of BpmnDataStoreSpecification that provide a data store
122
+ implementation.
123
+ """
124
+
125
+ PARSER_CLASSES = {
126
+ full_tag('startEvent'): (StartEventParser, StartEvent),
127
+ full_tag('endEvent'): (EndEventParser, EndEvent),
128
+ full_tag('userTask'): (TaskParser, UserTask),
129
+ full_tag('task'): (TaskParser, NoneTask),
130
+ full_tag('subProcess'): (SubWorkflowParser, SubWorkflowTask),
131
+ full_tag('manualTask'): (TaskParser, ManualTask),
132
+ full_tag('exclusiveGateway'): (ConditionalGatewayParser, ExclusiveGateway),
133
+ full_tag('parallelGateway'): (GatewayParser, ParallelGateway),
134
+ full_tag('inclusiveGateway'): (ConditionalGatewayParser, InclusiveGateway),
135
+ full_tag('callActivity'): (CallActivityParser, CallActivity),
136
+ full_tag('transaction'): (SubWorkflowParser, TransactionSubprocess),
137
+ full_tag('scriptTask'): (ScriptTaskParser, ScriptTask),
138
+ full_tag('serviceTask'): (TaskParser, ServiceTask),
139
+ full_tag('intermediateCatchEvent'): (IntermediateCatchEventParser, IntermediateCatchEvent),
140
+ full_tag('intermediateThrowEvent'): (IntermediateThrowEventParser, IntermediateThrowEvent),
141
+ full_tag('boundaryEvent'): (BoundaryEventParser, BoundaryEvent),
142
+ full_tag('receiveTask'): (ReceiveTaskParser, ReceiveTask),
143
+ full_tag('sendTask'): (SendTaskParser, SendTask),
144
+ full_tag('eventBasedGateway'): (EventBasedGatewayParser, EventBasedGateway),
145
+ }
146
+
147
+ OVERRIDE_PARSER_CLASSES = {}
148
+
149
+ PROCESS_PARSER_CLASS = ProcessParser
150
+
151
+ DATA_STORE_CLASSES = {}
152
+
153
+ def __init__(self, namespaces=None, validator=None, spec_descriptions=SPEC_DESCRIPTIONS):
154
+ """
155
+ Constructor.
156
+ """
157
+ self.namespaces = namespaces or DEFAULT_NSMAP
158
+ self.validator = validator
159
+ self.spec_descriptions = spec_descriptions
160
+ self.process_parsers = {}
161
+ self.collaborations = {}
162
+ self.process_dependencies = set()
163
+ self.messages = {}
164
+ self.correlations = {}
165
+ self.data_stores = {}
166
+
167
+ def _get_parser_class(self, tag):
168
+ if tag in self.OVERRIDE_PARSER_CLASSES:
169
+ return self.OVERRIDE_PARSER_CLASSES[tag]
170
+ elif tag in self.PARSER_CLASSES:
171
+ return self.PARSER_CLASSES[tag]
172
+ return None, None
173
+
174
+ def get_process_parser(self, process_id):
175
+ """
176
+ Returns the ProcessParser for the given process ID or name. It matches
177
+ by name first.
178
+ """
179
+ if process_id in self.process_parsers:
180
+ return self.process_parsers[process_id]
181
+
182
+ def get_process_ids(self):
183
+ """Returns a list of process IDs"""
184
+ return list(proc_id for proc_id, parser in self.process_parsers.items() if parser.process_executable)
185
+
186
+ def add_bpmn_file(self, filename):
187
+ """
188
+ Add the given BPMN filename to the parser's set.
189
+ """
190
+ self.add_bpmn_files([filename])
191
+
192
+ def add_bpmn_files_by_glob(self, g):
193
+ """
194
+ Add all filenames matching the provided pattern (e.g. *.bpmn) to the
195
+ parser's set.
196
+ """
197
+ self.add_bpmn_files(glob.glob(g))
198
+
199
+ def add_bpmn_files(self, filenames):
200
+ """
201
+ Add all filenames in the given list to the parser's set.
202
+ """
203
+ for filename in filenames:
204
+ with open(filename, 'r') as f:
205
+ self.add_bpmn_io(f, filename)
206
+
207
+ def add_bpmn_io(self, file_like_object, filename=None):
208
+ """
209
+ Add the given BPMN file like object to the parser's set.
210
+ """
211
+ self.add_bpmn_xml(etree.parse(file_like_object), filename)
212
+
213
+ def add_bpmn_str(self, bpmn_str, filename=None):
214
+ """
215
+ Add the given BPMN string to the parser's set.
216
+ """
217
+ self.add_bpmn_xml(etree.fromstring(bpmn_str), filename)
218
+
219
+ def add_bpmn_xml(self, bpmn, filename=None):
220
+ """
221
+ Add the given lxml representation of the BPMN file to the parser's set.
222
+
223
+ :param svg: Optionally, provide the text data for the SVG of the BPMN
224
+ file
225
+ :param filename: Optionally, provide the source filename.
226
+ """
227
+ if self.validator:
228
+ self.validator.validate(bpmn, filename)
229
+
230
+ # we need to parse the data stores before _add_process since it creates
231
+ # the parser instances, which need to know about the data stores to
232
+ # resolve data references.
233
+ self._add_data_stores(bpmn)
234
+
235
+ self._add_processes(bpmn, filename)
236
+ self._add_collaborations(bpmn)
237
+ self._add_messages(bpmn)
238
+ self._add_correlations(bpmn)
239
+
240
+ def _add_processes(self, bpmn, filename=None):
241
+ for process in bpmn.xpath('.//bpmn:process', namespaces=self.namespaces):
242
+ self._find_dependencies(process)
243
+ self.create_parser(process, filename)
244
+
245
+ def _add_collaborations(self, bpmn):
246
+ collaboration = first(bpmn.xpath('.//bpmn:collaboration', namespaces=self.namespaces))
247
+ if collaboration is not None:
248
+ collaboration_xpath = xpath_eval(collaboration)
249
+ name = collaboration.get('id')
250
+ self.collaborations[name] = [ participant.get('processRef') for participant in collaboration_xpath('.//bpmn:participant') ]
251
+
252
+ def _add_messages(self, bpmn):
253
+ for message in bpmn.xpath('.//bpmn:message', namespaces=self.namespaces):
254
+ if message.attrib.get("id") is None:
255
+ raise ValidationException(
256
+ "Message identifier is missing from bpmn xml"
257
+ )
258
+ self.messages[message.attrib.get("id")] = message.attrib.get("name")
259
+
260
+ def _add_correlations(self, bpmn):
261
+ for correlation in bpmn.xpath('.//bpmn:correlationProperty', namespaces=self.namespaces):
262
+ correlation_identifier = correlation.attrib.get("id")
263
+ if correlation_identifier is None:
264
+ raise ValidationException("Correlation identifier is missing from bpmn xml")
265
+ correlation_property_retrieval_expressions = correlation.xpath(
266
+ ".//bpmn:correlationPropertyRetrievalExpression", namespaces = self.namespaces)
267
+ if not correlation_property_retrieval_expressions:
268
+ raise ValidationException(
269
+ f"Correlation is missing correlation property retrieval expressions: {correlation_identifier}"
270
+ )
271
+ retrieval_expressions = []
272
+ for cpre in correlation_property_retrieval_expressions:
273
+ message_model_identifier = cpre.attrib.get("messageRef")
274
+ if message_model_identifier is None:
275
+ raise ValidationException(
276
+ f"Message identifier is missing from correlation property: {correlation_identifier}"
277
+ )
278
+ children = cpre.getchildren()
279
+ expression = children[0].text if len(children) > 0 else None
280
+ retrieval_expressions.append({"messageRef": message_model_identifier,
281
+ "expression": expression})
282
+ self.correlations[correlation_identifier] = {
283
+ "name": correlation.attrib.get("name"),
284
+ "retrieval_expressions": retrieval_expressions
285
+ }
286
+
287
+ def _add_data_stores(self, bpmn):
288
+ for data_store in bpmn.xpath('.//bpmn:dataStore', namespaces=self.namespaces):
289
+ data_store_id = data_store.attrib.get("id")
290
+ if data_store_id is None:
291
+ raise ValidationException(
292
+ "Data Store identifier is missing from bpmn xml"
293
+ )
294
+ data_store_name = data_store.attrib.get("name")
295
+ if data_store_name is None:
296
+ raise ValidationException(
297
+ "Data Store name is missing from bpmn xml"
298
+ )
299
+ if data_store_name not in self.DATA_STORE_CLASSES:
300
+ raise ValidationException(
301
+ f"Data Store with name {data_store_name} has no implementation"
302
+ )
303
+ data_store_spec = self.DATA_STORE_CLASSES[data_store_name](
304
+ data_store_id,
305
+ data_store_name,
306
+ data_store.attrib.get('capacity'),
307
+ data_store.attrib.get('isUnlimited'))
308
+ self.data_stores[data_store_id] = data_store_spec
309
+
310
+ def _find_dependencies(self, process):
311
+ """Locate all calls to external BPMN, and store their ids in our list of dependencies"""
312
+ for call_activity in process.xpath('.//bpmn:callActivity', namespaces=self.namespaces):
313
+ self.process_dependencies.add(call_activity.get('calledElement'))
314
+
315
+ def create_parser(self, node, filename=None, lane=None):
316
+ parser = self.PROCESS_PARSER_CLASS(self, node, self.namespaces, self.data_stores, filename=filename, lane=lane)
317
+ if parser.bpmn_id in self.process_parsers:
318
+ raise ValidationException(f'Duplicate process ID: {parser.bpmn_id}', node=node, file_name=filename)
319
+ self.process_parsers[parser.bpmn_id] = parser
320
+
321
+ def get_process_dependencies(self):
322
+ return self.process_dependencies
323
+
324
+ def get_spec(self, process_id, required=True):
325
+ """
326
+ Parses the required subset of the BPMN files, in order to provide an
327
+ instance of BpmnProcessSpec (i.e. WorkflowSpec)
328
+ for the given process ID or name. The Name is matched first.
329
+ """
330
+ parser = self.get_process_parser(process_id)
331
+ if required and parser is None:
332
+ raise ValidationException(
333
+ f"The process '{process_id}' was not found. "
334
+ f"Did you mean one of the following: "
335
+ f"{', '.join(self.get_process_ids())}?")
336
+ elif parser is not None:
337
+ return parser.get_spec()
338
+
339
+ def get_subprocess_specs(self, name, specs=None, require_call_activity_specs=True):
340
+ used = specs or {}
341
+ wf_spec = self.get_spec(name)
342
+ for task_spec in wf_spec.task_specs.values():
343
+ if isinstance(task_spec, SubWorkflowTaskMixin) and task_spec.spec not in used:
344
+ subprocess_spec = self.get_spec(task_spec.spec, required=require_call_activity_specs)
345
+ used[task_spec.spec] = subprocess_spec
346
+ if subprocess_spec is not None:
347
+ self.get_subprocess_specs(task_spec.spec, used)
348
+ return used
349
+
350
+ def find_all_specs(self):
351
+ # This is a little convoluted, but we might add more processes as we generate
352
+ # the dictionary if something refers to another subprocess that we haven't seen.
353
+ processes = dict((id, self.get_spec(id)) for id in self.get_process_ids())
354
+ while sorted(processes.keys()) != sorted(self.get_process_ids()):
355
+ for process_id in self.get_process_ids():
356
+ processes[process_id] = self.get_spec(process_id)
357
+ return processes
358
+
359
+ def get_collaboration(self, name):
360
+ self.find_all_specs()
361
+ spec = BpmnProcessSpec(name)
362
+ subprocesses = {}
363
+ participant_type = self._get_parser_class(full_tag('callActivity'))[1]
364
+ start_type = self._get_parser_class(full_tag('startEvent'))[1]
365
+ end_type = self._get_parser_class(full_tag('endEvent'))[1]
366
+ start = start_type(spec, 'Start Collaboration', NoneEventDefinition())
367
+ spec.start.connect(start)
368
+ end = end_type(spec, 'End Collaboration', NoneEventDefinition())
369
+ end.connect(spec.end)
370
+ for process in self.collaborations[name]:
371
+ process_parser = self.get_process_parser(process)
372
+ if process_parser and process_parser.process_executable:
373
+ sp_spec = self.get_spec(process)
374
+ subprocesses[process] = sp_spec
375
+ subprocesses.update(self.get_subprocess_specs(process))
376
+ if len([s for s in sp_spec.task_specs.values() if
377
+ isinstance(s, StartEventMixin) and
378
+ isinstance(s.event_definition, (NoneEventDefinition, TimerEventDefinition))
379
+ ]):
380
+ participant = participant_type(spec, process, process)
381
+ start.connect(participant)
382
+ participant.connect(end)
383
+ return spec, subprocesses
@@ -0,0 +1,156 @@
1
+ # Copyright (C) 2012 Matthew Hampton
2
+ #
3
+ # This file is part of SpiffWorkflow.
4
+ #
5
+ # SpiffWorkflow is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 3.0 of the License, or (at your option) any later version.
9
+ #
10
+ # SpiffWorkflow is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
+ # 02110-1301 USA
19
+
20
+ from .ValidationException import ValidationException
21
+ from ..specs.bpmn_process_spec import BpmnProcessSpec
22
+ from ..specs.data_spec import DataObject
23
+ from ..specs.control import StartEventJoin, StartEventSplit
24
+ from .node_parser import NodeParser
25
+ from .util import first
26
+
27
+
28
+ class ProcessParser(NodeParser):
29
+ """
30
+ Parses a single BPMN process, including all of the tasks within that
31
+ process.
32
+ """
33
+
34
+ def __init__(self, p, node, nsmap, data_stores, filename=None, lane=None):
35
+ """
36
+ Constructor.
37
+
38
+ :param p: the owning BpmnParser instance
39
+ :param node: the XML node for the process
40
+ :param data_stores: map of ids to data store implementations
41
+ :param filename: the source BPMN filename (optional)
42
+ :param lane: the lane of a subprocess (optional)
43
+ """
44
+ super().__init__(node, nsmap, filename=filename, lane=lane)
45
+ self.parser = p
46
+ self.lane = lane
47
+ self.spec = None
48
+ self.process_executable = node.get('isExecutable', 'true') == 'true'
49
+ self.data_stores = data_stores
50
+ self.parent = None
51
+
52
+ def get_name(self):
53
+ """
54
+ Returns the process name (or ID, if no name is included in the file)
55
+ """
56
+ return self.node.get('name', default=self.bpmn_id)
57
+
58
+ def has_lanes(self) -> bool:
59
+ """Returns true if this process has one or more named lanes """
60
+ elements = self.xpath("//bpmn:lane")
61
+ for el in elements:
62
+ if el.get("name"):
63
+ return True
64
+ return False
65
+
66
+ def start_messages(self):
67
+ """ This returns a list of message names that would cause this
68
+ process to start. """
69
+ message_names = []
70
+ messages = self.xpath("//bpmn:message")
71
+ message_event_definitions = self.xpath(
72
+ "//bpmn:startEvent/bpmn:messageEventDefinition")
73
+ for message_event_definition in message_event_definitions:
74
+ message_model_identifier = message_event_definition.attrib.get(
75
+ "messageRef"
76
+ )
77
+ if message_model_identifier is None:
78
+ raise ValidationException(
79
+ "Could not find messageRef from message event definition: {message_event_definition}"
80
+ )
81
+ # Convert the id into a Message Name
82
+ message_name = next((m for m in messages if m.attrib.get('id') == message_model_identifier), None)
83
+ message_names.append(message_name.attrib.get('name'))
84
+
85
+ return message_names
86
+
87
+ def called_element_ids(self):
88
+ """
89
+ Returns a list of ids referenced by `bpmn:callActivity` nodes.
90
+ """
91
+ return self.xpath(".//bpmn:callActivity/@calledElement")
92
+
93
+ def parse_node(self, node):
94
+ """
95
+ Parses the specified child task node, and returns the task spec. This
96
+ can be called by a TaskParser instance, that is owned by this
97
+ ProcessParser.
98
+ """
99
+ if node.get('id') in self.spec.task_specs:
100
+ return self.spec.task_specs[node.get('id')]
101
+
102
+ (node_parser, spec_class) = self.parser._get_parser_class(node.tag)
103
+ if not node_parser or not spec_class:
104
+ raise ValidationException("There is no support implemented for this task type.",
105
+ node=node, file_name=self.filename)
106
+ np = node_parser(self, spec_class, node, self.nsmap, lane=self.lane)
107
+ task_spec = np.parse_node()
108
+ return task_spec
109
+
110
+ def _parse(self):
111
+ # here we only look in the top level, We will have another
112
+ # bpmn:startEvent if we have a subworkflow task
113
+ start_node_list = self.xpath('./bpmn:startEvent')
114
+ if not start_node_list and self.process_executable:
115
+ raise ValidationException("No start event found", node=self.node, file_name=self.filename)
116
+ if not self.process_executable:
117
+ raise ValidationException(f"Process {self.bpmn_id} is not executable.", node=self.node, file_name=self.filename)
118
+ self.spec = BpmnProcessSpec(name=self.bpmn_id, description=self.get_name(), filename=self.filename)
119
+
120
+ # Get the data objects
121
+ for obj in self.xpath('./bpmn:dataObject'):
122
+ data_object = self.parse_data_object(obj)
123
+ self.spec.data_objects[data_object.bpmn_id] = data_object
124
+
125
+ # Check for an IO Specification.
126
+ io_spec = first(self.xpath('./bpmn:ioSpecification'))
127
+ if io_spec is not None:
128
+ self.spec.io_specification = self.parse_io_spec()
129
+
130
+ # set the data stores on the process spec so they can survive
131
+ # serialization
132
+ self.spec.data_stores = self.data_stores
133
+ for node in start_node_list:
134
+ self.parse_node(node)
135
+
136
+ if len(start_node_list) > 1:
137
+ split_task = StartEventSplit(self.spec, 'StartEventSplit')
138
+ join_task = StartEventJoin(self.spec, 'StartEventJoin', split_task='StartEventSplit', threshold=1, cancel=True)
139
+ for spec in self.spec.start.outputs:
140
+ spec.inputs = [split_task]
141
+ spec.connect(join_task)
142
+ split_task.outputs = self.spec.start.outputs
143
+ self.spec.start.outputs = [split_task]
144
+ split_task.inputs = [self.spec.start]
145
+
146
+ def parse_data_object(self, obj):
147
+ return self.create_data_spec(obj, DataObject)
148
+
149
+ def get_spec(self):
150
+ """
151
+ Parse this process (if it has not already been parsed), and return the
152
+ workflow spec.
153
+ """
154
+ if self.spec is None:
155
+ self._parse()
156
+ return self.spec