-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from sartography/master
A year of BPMN / DMN Enhancements
- Loading branch information
Showing
311 changed files
with
23,454 additions
and
492 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,5 @@ nosetests.xml | |
.coverage | ||
tests/coverage.xml | ||
.c9revisions | ||
.idea | ||
/venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
Samuel Abels <http://github.com/knipknap/> | ||
Ziad Sawalha <http://github.com/ziadsawalha/> | ||
Matthew Hampton <http://github.com/matthewhampton/> | ||
Kelly McDonald | ||
Dan Funk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM python:2-wheezy | ||
FROM python:3.6 | ||
RUN apt-get -y update && apt-get upgrade -yu | ||
COPY . /tmp/SpiffWorkflow | ||
RUN cd /tmp/SpiffWorkflow && make wheel && pip install dist/SpiffWorkflow*.whl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import division, absolute_import | ||
from builtins import object | ||
# 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 SpiffWorkflow.exceptions import WorkflowTaskExecException | ||
|
||
from .FeelLikeScriptEngine import FeelLikeScriptEngine | ||
from ..operators import Operator | ||
|
||
|
||
class BpmnFeelScriptEngine(FeelLikeScriptEngine): | ||
""" | ||
Used during execution of a BPMN workflow to evaluate condition / value | ||
expressions. These are used by Gateways, and by Catching Events | ||
(non-message ones). | ||
Also used to execute scripts. | ||
If you are uncomfortable with the use of eval() and exec, then you should | ||
provide a specialised subclass that parses and executes the scripts / | ||
expressions in a mini-language of your own. | ||
""" | ||
|
||
def evaluate(self, task, expression): | ||
""" | ||
Evaluate the given expression, within the context of the given task and | ||
return the result. | ||
""" | ||
try: | ||
if isinstance(expression, Operator): | ||
# I am assuming that this takes care of some kind of XML | ||
# expression judging from the contents of operators.py | ||
return expression._matches(task) | ||
else: | ||
return super().evaluate(expression, **task.data) | ||
except Exception as e: | ||
raise WorkflowTaskExecException(task, | ||
"Error evaluating expression " | ||
"'%s', %s" % (expression, str(e))) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# -*- coding: utf-8 -*- | ||
from builtins import object | ||
import ast | ||
import re | ||
import operator | ||
import datetime | ||
from datetime import timedelta | ||
from decimal import Decimal | ||
from SpiffWorkflow.workflow import WorkflowException | ||
from .PythonScriptEngine import PythonScriptEngine, Box | ||
|
||
# Copyright (C) 2020 Kelly McDonald | ||
# | ||
# 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 | ||
|
||
class DMNPythonScriptEngine(PythonScriptEngine): | ||
""" | ||
This simply overrides the python script engine to do some specific things for | ||
DMN - I left the underlying PythonScriptEngine with everything in place so it | ||
will play nice with the existing FeelLikeScriptEngine | ||
""" | ||
def __init__(self): | ||
super().__init__() | ||
|
||
def eval_dmn_expression(self, inputExpr, matchExpr, **kwargs): | ||
""" | ||
Here we need to handle a few things such as if it is an equality or if | ||
the equality has already been taken care of. For now, we just assume it is equality. | ||
""" | ||
|
||
|
||
|
||
if matchExpr is None: | ||
return True | ||
|
||
nolhs = False | ||
if '?' in matchExpr: | ||
nolhs = True | ||
matchExpr = matchExpr.replace('?', 'dmninputexpr') | ||
|
||
rhs, needsEquals = self.validateExpression(matchExpr) | ||
|
||
extra = { | ||
'datetime': datetime, | ||
'timedelta': timedelta, | ||
'Decimal': Decimal, | ||
'Box': Box | ||
} | ||
|
||
lhs, lhsNeedsEquals = self.validateExpression(inputExpr) | ||
if not lhsNeedsEquals: | ||
raise WorkflowException("Input Expression '%s' is malformed"%inputExpr) | ||
if nolhs: | ||
dmninputexpr = self.evaluate(lhs, external_methods= extra, **kwargs) | ||
extra = {'dmninputexpr':dmninputexpr, | ||
'datetime':datetime, | ||
'timedelta':timedelta, | ||
'Decimal':Decimal, | ||
'Box':Box | ||
} | ||
return self.evaluate(rhs,external_methods=extra, **kwargs) | ||
if needsEquals: | ||
expression = lhs + ' == ' + rhs | ||
else: | ||
expression = lhs + rhs | ||
|
||
return self.evaluate(expression, external_methods=extra, **kwargs) | ||
|
Oops, something went wrong.