Commit 4e3d3b4d authored by wenjie.zheng's avatar wenjie.zheng

WorkflowTool.py: during the conversion, if there is a script_id and method...

WorkflowTool.py: during the conversion, if there is a script_id and method name conflict, add a prefix to script_id.
parent f4e88dba
......@@ -301,13 +301,21 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
if tdef.after_script_name in dc_workflow.transitions.objectIds():
transition.setAfterScriptId('transition_'+tdef.after_script_name)
elif tdef.after_script_name in dc_workflow.scripts.objectIds():
transition.setAfterScriptId(tdef.after_script_name)
# add a prefix if there is a script & method conflict
if hasattr(workflow, tdef.after_script_name):
transition.setAfterScriptId('ScriptPrefix_'+tdef.after_script_name)
else:
transition.setAfterScriptId(tdef.after_script_name)
if tdef.script_name is not None:
# check before script is a Transion or a Script:
if tdef.script_name in dc_workflow.transitions.objectIds():
transition.setBeforeScriptId('transition_'+tdef.script_name)
elif tdef.script_name in dc_workflow.scripts.objectIds():
transition.setBeforeScriptId(tdef.script_name)
if hasattr(workflow, tdef.script_name):
# add a prefix if there is a script & method conflict
transition.setBeforeScriptId('ScriptPrefix_'+tdef.script_name)
else:
transition.setBeforeScriptId(tdef.script_name)
# configure guard
if tdef.guard:
transition.setRoleList(tdef.guard.roles)
......@@ -406,18 +414,27 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
interaction.setReference(tdef.id)
script_list = []
for script_name in tdef.activate_script_name:
# add a prefix if there is a script method conflict
if hasattr(workflow, script_name):
script_name = 'ScriptPrefix_' + script_name
script_list.append(script_name)
interaction.setActivateScriptNameList(tuple(script_list))
script_list = []
for script_name in tdef.after_script_name:
if hasattr(workflow, script_name):
script_name = 'ScriptPrefix_' + script_name
script_list.append(script_name)
interaction.setAfterScriptNameList(tuple(script_list))
script_list = []
for script_name in tdef.before_commit_script_name:
if hasattr(workflow, script_name):
script_name = 'ScriptPrefix_' + script_name
script_list.append(script_name)
interaction.setBeforeCommitScriptNameList(tuple(script_list))
script_list = []
for script_name in tdef.script_name:
if hasattr(workflow, script_name):
script_name = 'ScriptPrefix_' + script_name
script_list.append(script_name)
interaction.setBeforeScriptNameList(tuple(script_list))
# configure guard
......@@ -444,10 +461,9 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
# create scripts (portal_type = Workflow Script)
for script_id in dc_workflow.scripts:
script = dc_workflow.scripts.get(script_id)
# add a prefix if there is a script & method conflict
if hasattr(workflow, script_id):
workflow_script = workflow.newContent(portal_type='Workflow Script', temp_object=temp)
workflow.script_id = workflow_script
workflow.script_id.id = script_id
workflow_script = workflow.newContent(id='ScriptPrefix_'+script_id, portal_type='Workflow Script', temp_object=temp)
else:
workflow_script = workflow.newContent(id=script_id ,portal_type='Workflow Script', temp_object=temp)
workflow_script.setTitle(script.title)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment