mirror of
https://github.com/status-im/spiff-arena.git
synced 2025-01-29 19:25:50 +00:00
35ef5cbe54
1f51db962 Merge pull request #283 from sartography/feature/better_errors 69fb4967e Patching up some bugs and logical disconnects as I test out the errors. cf5be0096 * Making a few more things consistent in the error messages -- so there isn't filename for validation errors, and file_name for WorkflowExceptions. Same for line_number vs sourceline. * Assure than an error_type is consistently set on exceptions. * ValidationExceptions should not bild up a detailed error message that replicates information available within it. 440ee16c8 Responding to some excellent suggestions from Elizabeth: 655e415e1 Merge pull request #282 from subhakarks/fix-workfowspec-dump 1f6d3cf4e Explain that the error happened in a pre-script or post script. 8119abd14 Added a top level SpiffWorklowException that all exceptions inherit from. Aside from a message string you can append information to these exceptions with "add_note", which is a new method that all exceptions have starting in python 3.11 Switched arguments to the WorkflowException, WorkflowTaskException - which now always takes a string message as the first argument, and named arguments thereafter to be consistent with all other error messages in Python. Consistently raise ValidationExceptions whenever we encounter an error anywhere during parsing of xml. The BPMN/WorkflowTaskExecException is removed, in favor of just calling a WorkflowTaskException. There is nothing BPMN Specific in the logic, so no need for this. Consolidated error message logic so that things like "Did you mean" just get added by default if possible. So we don't have to separately deal with that logic each time. Better Error messages for DMN (include row number as a part of the error information) 13463b5c5 fix for workflowspec dump be26100bc Merge pull request #280 from sartography/feature/remove-unused-bpmn-attributes-and-methods 23a5c1d70 remove 'entering_* methods 4e5875ec8 remove sequence flow 5eed83ab1 Merge pull request #278 from sartography/feature/remove-old-serializer 614f1c68a remove compact serializer and references e7e410d4a remove old serializer and references git-subtree-dir: SpiffWorkflow git-subtree-split: 1f51db962ccaed5810f5d0f7d76a932f056430ab
95 lines
3.0 KiB
Python
95 lines
3.0 KiB
Python
# -*- 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 ...operators import Operator
|
|
from ...specs.base import TaskSpec
|
|
|
|
|
|
class _BpmnCondition(Operator):
|
|
|
|
def __init__(self, *args):
|
|
if len(args) > 1:
|
|
raise TypeError("Too many arguments")
|
|
super(_BpmnCondition, self).__init__(*args)
|
|
|
|
def _matches(self, task):
|
|
return task.workflow.script_engine.evaluate(task, self.args[0])
|
|
|
|
|
|
|
|
class BpmnSpecMixin(TaskSpec):
|
|
"""
|
|
All BPMN spec classes should mix this superclass in. It adds a number of
|
|
methods that are BPMN specific to the TaskSpec.
|
|
"""
|
|
|
|
def __init__(self, wf_spec, name, lane=None, position=None, **kwargs):
|
|
"""
|
|
Constructor.
|
|
|
|
:param lane: Indicates the name of the lane that this task belongs to
|
|
(optional).
|
|
"""
|
|
super(BpmnSpecMixin, self).__init__(wf_spec, name, **kwargs)
|
|
self.lane = lane
|
|
self.position = position or {'x': 0, 'y': 0}
|
|
self.loopTask = False
|
|
self.documentation = None
|
|
self.data_input_associations = []
|
|
self.data_output_associations = []
|
|
|
|
@property
|
|
def spec_type(self):
|
|
return 'BPMN Task'
|
|
|
|
def is_loop_task(self):
|
|
"""
|
|
Returns true if this task is a BPMN looping task
|
|
"""
|
|
return self.loopTask
|
|
|
|
def connect_outgoing_if(self, condition, taskspec):
|
|
"""
|
|
Connect this task spec to the indicated child, if the condition
|
|
evaluates to true. This should only be called if the task has a
|
|
connect_if method (e.g. ExclusiveGateway).
|
|
"""
|
|
self.connect_if(_BpmnCondition(condition), taskspec)
|
|
|
|
def _on_ready_hook(self, my_task):
|
|
super()._on_ready_hook(my_task)
|
|
for obj in self.data_input_associations:
|
|
obj.get(my_task)
|
|
|
|
def _on_complete_hook(self, my_task):
|
|
|
|
for obj in self.data_output_associations:
|
|
obj.set(my_task)
|
|
|
|
for obj in self.data_input_associations:
|
|
# Remove the any copied input variables that might not have already been removed
|
|
my_task.data.pop(obj.name, None)
|
|
|
|
super(BpmnSpecMixin, self)._on_complete_hook(my_task)
|
|
if isinstance(my_task.parent.task_spec, BpmnSpecMixin):
|
|
my_task.parent.task_spec._child_complete_hook(my_task)
|
|
|
|
def _child_complete_hook(self, child_task):
|
|
pass
|