Skip to content

Commit

Permalink
fixed behaviour of --force and --clear paramters of load_diagrams com…
Browse files Browse the repository at this point in the history
…mand.

rref #5357
#GH-64
  • Loading branch information
evrenesat committed Aug 31, 2016
1 parent e5bbf3a commit 71797bc
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions zengine/management_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,15 @@ class LoadDiagrams(Command):
CMD_NAME = 'load_diagrams'
HELP = 'Loads workflow diagrams from diagrams folder to DB'
PARAMS = [
{'name': 'wf_path', 'default': None, 'help': 'Only update given BPMN diagram'},
{'name': 'clear', 'action': 'store_true', 'help': 'Clear all task related models'},
{'name': 'force', 'action': 'store_true', 'help': 'Load BPMN file even if there are active WFInstances exists.'},
{'name': 'wf_path', 'default': None,
'help': 'Only update given BPMN diagram'},

{'name': 'clear', 'action': 'store_true',
'help': 'Clear all TaskManager related models'},

{'name': 'force', 'action': 'store_true',
'help': "(Re)Load BPMN file even if it doesn't updated or"
" there are active WFInstances exists."},
]

def run(self):
Expand All @@ -265,7 +271,7 @@ def run(self):
wf, wf_is_new = BPMNWorkflow.objects.get_or_create(name=wf_name)
content = self._tmp_fix_diagram(content)
diagram, diagram_is_updated = DiagramXML.get_or_create_by_content(wf_name, content)
if wf_is_new or diagram_is_updated:
if wf_is_new or diagram_is_updated or self.manager.args.force:
count += 1
print("%s created or updated" % wf_name.upper())
try:
Expand All @@ -277,14 +283,16 @@ def run(self):


def _clear_models(self):
from zengine.models.workflow_manager import DiagramXML, BPMNWorkflow, WFInstance
from zengine.models.workflow_manager import DiagramXML, BPMNWorkflow, WFInstance, TaskInvitation
print("Workflow related models will be cleared")
c = len(DiagramXML.objects.delete())
print("%s DiagramXML object deleted" % c)
c = len(BPMNWorkflow.objects.delete())
print("%s BPMNWorkflow object deleted" % c)
c = len(WFInstance.objects.delete())
print("%s WFInstance object deleted" % c)
c = len(TaskInvitation.objects.delete())
print("%s TaskInvitation object deleted" % c)

def _tmp_fix_diagram(self, content):
# Temporary solution for easier transition from old to new xml format
Expand Down

0 comments on commit 71797bc

Please sign in to comment.