| 264 | return cancelled |
| 265 | |
| 266 | def update_collaboration(self, event): |
| 267 | |
| 268 | def get_or_create_subprocess(task_spec, wf_spec): |
| 269 | |
| 270 | for sp in self.subprocesses.values(): |
| 271 | if sp.get_next_task(state=TaskState.WAITING, spec_name=task_spec.name) is not None: |
| 272 | return sp |
| 273 | |
| 274 | # This creates a new task associated with a process when an event that kicks of a process is received |
| 275 | # I need to know what class is being used to create new processes in this case, and this seems slightly |
| 276 | # less bad than adding yet another argument. Still sucks though. |
| 277 | # TODO: Make collaborations a class rather than trying to shoehorn them into a process. |
| 278 | for spec in self.spec.task_specs.values(): |
| 279 | if isinstance(spec, CallActivity): |
| 280 | spec_class = spec.__class__ |
| 281 | break |
| 282 | else: |
| 283 | # Default to the mixin class, which will probably fail in many cases. |
| 284 | spec_class = CallActivity |
| 285 | |
| 286 | new = spec_class(self.spec, f'{wf_spec.name}_{len(self.subprocesses)}', wf_spec.name) |
| 287 | self.spec.start.connect(new) |
| 288 | task = Task(self, new, parent=self.task_tree) |
| 289 | # This (indirectly) calls create_subprocess |
| 290 | task.task_spec._update(task) |
| 291 | return self.subprocesses[task.id] |
| 292 | |
| 293 | # Start a subprocess for known specs with start events that catch this |
| 294 | for spec in self.subprocess_specs.values(): |
| 295 | for task_spec in spec.task_specs.values(): |
| 296 | if isinstance(task_spec, StartEvent) and task_spec.event_definition == event.event_definition: |
| 297 | subprocess = get_or_create_subprocess(task_spec, spec) |
| 298 | subprocess.correlations.update(event.correlations) |