Commit ff6846c9 authored by wenjie.zheng's avatar wenjie.zheng

WorkflowTool.py: fix variable guard conversion, and guards of the other objects.

parent a4e8225d
......@@ -290,6 +290,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
workflow._delObject('state_draft')
dc_workflow_transition_value_list = dc_workflow.transitions
dc_workflow_transition_id_list = dc_workflow_transition_value_list.objectIds()
# create transition (portal_type = Transition)
for tid in dc_workflow_transition_value_list:
tdef = dc_workflow_transition_value_list.get(tid)
transition = workflow.newContent(portal_type='Transition', temp_object=temp)
......@@ -325,6 +326,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
transition.setBeforeScriptId(tdef.script_name)
# configure guard
if tdef.guard:
transition.guard = tdef.guard
transition.setRoleList(tdef.guard.roles)
transition.setPermissionList(tdef.guard.permissions)
transition.setGroupList(tdef.guard.groups)
......@@ -355,7 +357,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
pr_cell = state.newContent(id='cell_%s_%s'%(i,j), portal_type='PermissionRoles')
if permission in permission_roles and role in permission_roles[permission]:
pr_cell.is_selected = 1
# Set Workflow default state using category setter
# default state using category setter
state_path = getattr(workflow, 'state_'+dc_workflow.initial_state).getPath()
state_path = 'source/' + '/'.join(state_path.split('/')[2:])
workflow.setCategoryList([state_path])
......@@ -374,7 +376,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
continue
state_path = 'destination/' + '/'.join(state.getPath().split('/')[2:])
tdef.setCategoryList([state_path])
# create worklists (portal_type = Worklist)
# worklists (portal_type = Worklist)
for qid in dc_workflow.worklists:
qdef = dc_workflow.worklists.get(qid)
worklist = workflow.newContent(portal_type='Worklist', temp_object=temp)
......@@ -415,6 +417,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
worklist.setActboxName(qdef.actbox_name)
# configure guard
if qdef.guard:
worklist.guard = qdef.guard
worklist.setRoleList(qdef.guard.roles)
worklist.setPermissionList(qdef.guard.permissions)
worklist.setGroupList(qdef.guard.groups)
......@@ -422,16 +425,17 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
worklist.setExpression(qdef.guard.expr.text)
elif workflow_type_id == 'InteractionWorkflowDefinition':
dc_workflow_interaction_value_list = dc_workflow.interactions
# create interactions (portal_type = Interaction)
for tid in dc_workflow_interaction_value_list:
interaction = workflow.newContent(portal_type='Interaction', temp_object=temp)
tdef = dc_workflow_interaction_value_list.get(tid)
if tdef.title == '' or tdef.title is None:
tdef.title = UpperCase(tdef.id)
tdef.setTitle(UpperCase(tdef.id))
interaction.setTitle(tdef.title)
interaction.setReference(tdef.id)
script_list = []
for script_name in tdef.activate_script_name:
# add a prefix if there is a script method conflict
# Add a prefix iif there is a conflict (script and accessor).
if hasattr(workflow, script_name):
script_name = 'ScriptPrefix_' + script_name
script_list.append(script_name)
......@@ -456,10 +460,12 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
interaction.setBeforeScriptNameList(tuple(script_list))
# configure guard
if tdef.guard:
interaction.guard = tdef.guard
interaction.setRoleList(tdef.guard.roles)
interaction.setPermissionList(tdef.guard.permissions)
interaction.setGroupList(tdef.guard.groups)
if tdef.guard.expr is not None:
# Here add expression text, convert to expression in getMatchVar.
interaction.setExpression(tdef.guard.expr.text)
interaction.setPortalTypeFilter(tdef.portal_type_filter)
interaction.setPortalTypeGroupFilter(tdef.portal_type_group_filter)
......@@ -503,12 +509,19 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
if vid == 'action':
variable.setDefaultExpr('transition/getReference|nothing')
else: variable.setDefaultExpr(vdef.default_expr.text)
variable.info_guard = vdef.info_guard
if vdef.info_guard:
variable.info_guard = vdef.info_guard
variable.setRoleList(vdef.info_guard.roles)
variable.setPermissionList(vdef.info_guard.permissions)
variable.setGroupList(vdef.info_guard.groups)
if vdef.info_guard.expr is not None:
# Here add expression text, convert to expression in getMatchVar.
variable.setExpression(tdef.info_guard.expr.text)
variable.setForCatalog(vdef.for_catalog)
variable.setForStatus(vdef.for_status)
variable.setInitialValue(vdef.default_value)
variable.setDescription(vdef.description)
# configure transition variable
# Configure transition variable:
if getattr(dc_workflow, 'transitions', None) is not None:
dc_workflow_transition_value_list = dc_workflow.transitions
for tid in dc_workflow_transition_value_list:
......@@ -525,6 +538,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
tr_var_path = '/'.join(tr_var_path.split('/')[2:])
new_category.append(tr_var_path)
tr_var.setCausalityList(new_category)
# Configure interaction variable:
if getattr(dc_workflow, 'interactions', None) is not None:
dc_workflow_interaction_value_list = dc_workflow.interactions
for tid in dc_workflow_interaction_value_list:
......
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