2022-10-12 10:19:53 -04:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
# Copyright (C) 2012 Matthew Hampton
|
|
|
|
#
|
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this library; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
# 02110-1301 USA
|
|
|
|
from ...exceptions import WorkflowException
|
|
|
|
|
|
|
|
from .BpmnSpecMixin import BpmnSpecMixin
|
2022-11-04 09:33:42 -04:00
|
|
|
from ...specs.base import TaskSpec
|
2022-10-12 10:19:53 -04:00
|
|
|
from ...specs.ExclusiveChoice import ExclusiveChoice
|
|
|
|
|
|
|
|
|
|
|
|
class ExclusiveGateway(ExclusiveChoice, BpmnSpecMixin):
|
|
|
|
|
|
|
|
"""
|
|
|
|
Task Spec for a bpmn:exclusiveGateway node.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def test(self):
|
|
|
|
"""
|
|
|
|
Checks whether all required attributes are set. Throws an exception
|
|
|
|
if an error was detected.
|
|
|
|
"""
|
|
|
|
# This has been overridden to allow a single default flow out (without a
|
|
|
|
# condition) - useful for the converging type
|
|
|
|
TaskSpec.test(self)
|
|
|
|
# if len(self.cond_task_specs) < 1:
|
|
|
|
# raise WorkflowException(self, 'At least one output required.')
|
|
|
|
for condition, name in self.cond_task_specs:
|
|
|
|
if name is None:
|
2023-01-19 10:47:07 -05:00
|
|
|
raise WorkflowException('Condition with no task spec.', task_spec=self)
|
2022-10-12 10:19:53 -04:00
|
|
|
task_spec = self._wf_spec.get_task_spec_from_name(name)
|
|
|
|
if task_spec is None:
|
|
|
|
msg = 'Condition leads to non-existent task ' + repr(name)
|
2023-01-19 10:47:07 -05:00
|
|
|
raise WorkflowException(msg, task_spec=self)
|
2022-10-12 10:19:53 -04:00
|
|
|
if condition is None:
|
|
|
|
continue
|
|
|
|
|
|
|
|
@property
|
|
|
|
def spec_type(self):
|
|
|
|
return 'Exclusive Gateway'
|