A library to execute BPMN Workflows and DMN Decision Tables.
This package uses SpiffWorkflow to execute the DBPM workflow. I wrote my own DMN engine to execute DMN Decision Tables. I used the Camunda Modeleler to create all my files.
The bpmn_dmn package contains 3 main modules:
-
bpmn to execute BPMN Workflow Charts by using an xml file on the disc
-
dmn to execute DMN Decision Tables by using an xml file on the disc
-
bpmn_dmn to execute BPMN Workflow Charts that includes DMN Decision Tables as business tasks
Use the BPMNXMLWorkflowRunner class to execute xml files (based on SpiffWorkflow)
Constructor: path, workflowProcessID=None, debug=False, **kwargs
from bpmn_dmn.bpmn import BPMNXMLWorkflowRunner
class Lorder:
def __init__(self, status, printedfl):
self.status = status
self.printedfl = printedfl
runner = BPMNXMLWorkflowRunner('exclusive_gateway_two_if_else.bpmn', debug=True)
runner.start(lorder=Lorder(2, True))
res = runner.getEndEventName()
print(res)
In my unit tests I currently only used Exclusive Gateways. But there is MUCH more. Please see the SpiffWorkflow BPMN UnitTests.
All of them should work in my library too, since I simply wrote a base Class that wraps the xml packager and some more small features.
Use the BPMNDMNXMLWorkflowRunner class to execute xml files
Constructor: path, workflowProcessID=None, debugLog='INFO', debug=False, **kwargs
from bpmn_dmn.bpmn_dmn import BPMNDMNXMLWorkflowRunner
runner = BPMNDMNXMLWorkflowRunner('ExclusiveGatewayIfElseAndDecision.bpmn', debugLog='DEBUG', debug=True)
runner.start(x=3)
res = runner.getEndEventName()
print(res)
from bpmn_dmn.bpmn import BPMNXMLWorkflowRunner
from SpiffWorkflow.bpmn.BpmnScriptEngine import BpmnScriptEngine
class LXScriptEngine(BpmnScriptEngine):
@staticmethod
def lxs(fctName, lorder):
print('lxs', fctName, lorder)
if fctName == 'checkPatientOrder':
return lorder.patientOrder
else:
raise NotImplementedError(fctName)
def _eval(self, task, expression, **kwargs):
locals().update(kwargs)
locals().update({'lxs': LXScriptEngine.lxs})
return eval(expression)
class LXS_BPMNXMLWorkflowRunner(BPMNXMLWorkflowRunner):
def __init__(self, *args, **kwargs):
super(LXS_BPMNXMLWorkflowRunner, self).__init__(*args, **kwargs, script_engine=LXScriptEngine())
class Lorder:
def __init__(self, status, printedfl):
self.status = status
self.printedfl = printedfl
runner = LXS_BPMNXMLWorkflowRunner('exclusive_gateway_two_if_else.bpmn', debugLog='DEBUG', debug=True)
runner.start(lorder=Lorder(2, True))
res = runner.getEndEventName()
print(res)
Use the DMNDecisionRunner class to execute xml files
Constructor: path, debug='INFO'
from bpmn_dmn.dmn import DMNDecisionRunner
runner = DMNDecisionRunner('string_integer_decision.dmn', debug='DEBUG')
res = self.runner.decide('m', 30)
print(res)
From github
pip install git+https://github.com/labsolutionlu/bpmn_dmn.git
or
pip install git+https://github.com/labsolutionlu/[email protected]
From pypi
pip install bpmn-dmn
- Denny Weinberg - Initial work - DennyWeinberg
This project is licensed under the MIT License - see the LICENSE.md file for details
- Log improvements
- Test other unit tests from SpiffWorkflow Source
- Implement all differnt modes that are available for DMN tables