Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sebastien Robin
erp5
Commits
e0ca9a3d
Commit
e0ca9a3d
authored
Aug 24, 2016
by
iv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Workflow: set categories on interactions while converting them
to ERP5 Workflow and use them
parent
82b70919
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
94 deletions
+69
-94
product/ERP5Workflow/Document/Interaction.py
product/ERP5Workflow/Document/Interaction.py
+0
-1
product/ERP5Workflow/Document/InteractionWorkflow.py
product/ERP5Workflow/Document/InteractionWorkflow.py
+15
-23
product/ERP5Workflow/Tool/WorkflowTool.py
product/ERP5Workflow/Tool/WorkflowTool.py
+54
-70
No files found.
product/ERP5Workflow/Document/Interaction.py
View file @
e0ca9a3d
...
@@ -64,7 +64,6 @@ class Interaction(IdAsReferenceMixin('interaction_', "prefix"), XMLObject,
...
@@ -64,7 +64,6 @@ class Interaction(IdAsReferenceMixin('interaction_', "prefix"), XMLObject,
trigger_once_per_transaction
=
False
trigger_once_per_transaction
=
False
temporary_document_disallowed
=
False
temporary_document_disallowed
=
False
var_exprs
=
None
# A mapping.
var_exprs
=
None
# A mapping.
guard
=
None
default_reference
=
''
default_reference
=
''
# Declarative security
# Declarative security
...
...
product/ERP5Workflow/Document/InteractionWorkflow.py
View file @
e0ca9a3d
...
@@ -240,10 +240,8 @@ class InteractionWorkflow(IdAsReferenceMixin("", "prefix"), Workflow):
...
@@ -240,10 +240,8 @@ class InteractionWorkflow(IdAsReferenceMixin("", "prefix"), Workflow):
sci
=
StateChangeInfo
(
sci
=
StateChangeInfo
(
ob
,
self
,
former_status
,
tdef
,
None
,
None
,
kwargs
=
kw
)
ob
,
self
,
former_status
,
tdef
,
None
,
None
,
kwargs
=
kw
)
before_script_list
=
tdef
.
getBeforeScriptNameList
()
before_script_list
=
tdef
.
getBeforeScriptValueList
()
if
before_script_list
!=
[]
and
before_script_list
is
not
None
:
for
script
in
before_script_list
:
for
script_name
in
before_script_list
:
script
=
self
.
_getOb
(
script_name
,
None
)
if
script
:
script
(
sci
)
if
script
:
script
(
sci
)
return
filtered_transition_list
return
filtered_transition_list
...
@@ -306,28 +304,22 @@ class InteractionWorkflow(IdAsReferenceMixin("", "prefix"), Workflow):
...
@@ -306,28 +304,22 @@ class InteractionWorkflow(IdAsReferenceMixin("", "prefix"), Workflow):
ob
,
self
,
former_status
,
tdef
,
None
,
None
,
kwargs
=
kw
)
ob
,
self
,
former_status
,
tdef
,
None
,
None
,
kwargs
=
kw
)
# Execute the "after" script.
# Execute the "after" script.
after_script_list
=
tdef
.
getAfterScriptNameList
()
after_script_list
=
tdef
.
getAfterScriptValueList
()
if
after_script_list
!=
[]
and
after_script_list
is
not
None
:
for
script
in
after_script_list
:
for
script_name
in
after_script_list
:
# try to get the script without calling it.
script
=
self
.
_getOb
(
script_name
,
None
)
# Pass lots of info to the script in a single parameter.
if
script
:
script
(
sci
)
# May throw an exception
if
script
:
script
(
sci
)
# May throw an exception
# Queue the "Before Commit" scripts
# Queue the "Before Commit" scripts
sm
=
getSecurityManager
()
sm
=
getSecurityManager
()
before_commit_script_list
=
tdef
.
getBeforeCommitScriptNameList
()
before_commit_script_list
=
tdef
.
getBeforeCommitScriptValueList
()
if
before_commit_script_list
!=
[]
and
before_commit_script_list
is
not
None
:
for
script
in
before_commit_script_list
:
for
script_name
in
before_commit_script_list
:
transaction
.
get
().
addBeforeCommitHook
(
self
.
_before_commit
,
transaction
.
get
().
addBeforeCommitHook
(
self
.
_before_commit
,
(
sci
,
script
_name
,
sm
))
(
sci
,
script
.
id
,
sm
))
# Execute "activity" scripts
# Execute "activity" scripts
activity_script_list
=
tdef
.
getActivateScriptNameList
()
activity_script_list
=
tdef
.
getActivateScriptValueList
()
if
activity_script_list
!=
[]
and
activity_script_list
is
not
None
:
for
script_name
in
activity_script_list
:
for
script_name
in
activity_script_list
:
self
.
activate
(
activity
=
'SQLQueue'
)
\
self
.
activate
(
activity
=
'SQLQueue'
)
\
.
activeScript
(
script_name
,
ob
.
getRelativeUrl
(),
.
activeScript
(
script
.
id
,
ob
.
getRelativeUrl
(),
status
,
tdef
.
getId
())
status
,
tdef
.
getId
())
def
_before_commit
(
self
,
sci
,
script_name
,
security_manager
):
def
_before_commit
(
self
,
sci
,
script_name
,
security_manager
):
...
...
product/ERP5Workflow/Tool/WorkflowTool.py
View file @
e0ca9a3d
...
@@ -87,22 +87,6 @@ Most of the code in this file has been taken from patches/WorkflowTool.py.
...
@@ -87,22 +87,6 @@ Most of the code in this file has been taken from patches/WorkflowTool.py.
_marker
=
[]
# Create a new marker object.
_marker
=
[]
# Create a new marker object.
def
getERP5ScriptPath
(
erp5_workflow
,
dc_workflow
,
dc_script_name
,
category_name
):
# XXX(WORKFLOW): remove hardcoded paths
if
dc_script_name
is
not
None
:
script_path_base
=
category_name
.
strip
(
'/'
)
+
'/'
+
'portal_workflow/'
+
\
erp5_workflow
.
getId
()
+
'/'
# check script is a Transition or a Script:
if
dc_script_name
in
dc_workflow
.
transitions
:
return
(
script_path_base
+
'transition_'
+
dc_script_name
)
elif
dc_script_name
in
dc_workflow
.
scripts
.
objectIds
():
# add a prefix if there is a conflict
if
hasattr
(
erp5_workflow
,
dc_script_name
):
return
(
script_path_base
+
'ScriptPrefix_'
+
dc_script_name
)
else
:
return
(
script_path_base
+
dc_script_name
)
return
None
class
WorkflowTool
(
BaseTool
,
OriginalWorkflowTool
):
class
WorkflowTool
(
BaseTool
,
OriginalWorkflowTool
):
"""
"""
A new container for DC workflow and workflow;
A new container for DC workflow and workflow;
...
@@ -273,6 +257,17 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
...
@@ -273,6 +257,17 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
temp_workflow_id_list
.
append
(
temp_workflow
.
getTitle
())
temp_workflow_id_list
.
append
(
temp_workflow
.
getTitle
())
return
temp_workflow_list
return
temp_workflow_list
def
initialize_script_categories
(
self
,
workflow
,
initial_script_name_list
,
method
):
script_path_list
=
[]
if
isinstance
(
initial_script_name_list
,
str
):
initial_script_name_list
=
[
initial_script_name_list
]
for
script_name
in
initial_script_name_list
:
if
script_name
:
script
=
getattr
(
workflow
,
'ScriptPrefix_'
+
script_name
,
None
)
or
getattr
(
workflow
,
script_name
,
None
)
or
getattr
(
workflow
,
'transition_'
+
script_name
,
None
)
script_path
=
script
.
getRelativeUrl
()
script_path_list
.
append
(
script_path
)
method
(
tuple
(
script_path_list
))
def
dc_workflow_asERP5Object
(
self
,
dc_workflow
,
is_temporary
=
False
):
def
dc_workflow_asERP5Object
(
self
,
dc_workflow
,
is_temporary
=
False
):
""" convert DC Workflow to New Workflow """
""" convert DC Workflow to New Workflow """
...
@@ -302,6 +297,23 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
...
@@ -302,6 +297,23 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
if
not
is_temporary
:
if
not
is_temporary
:
# create state and transitions (Workflow)
# create state and transitions (Workflow)
# or interactions (Interaction Workflow)
# or interactions (Interaction Workflow)
# create scripts (portal_type = Workflow Script)
dc_workflow_script_list
=
dc_workflow
.
scripts
for
script_id
in
dc_workflow_script_list
:
script
=
dc_workflow_script_list
.
get
(
script_id
)
# add a prefix if there is a script & method conflict
if
hasattr
(
workflow
,
script_id
):
workflow_script
=
workflow
.
newContent
(
id
=
'ScriptPrefix_'
+
script_id
,
portal_type
=
'Workflow Script'
,
temp_object
=
is_temporary
)
else
:
workflow_script
=
workflow
.
newContent
(
id
=
script_id
,
portal_type
=
'Workflow Script'
,
temp_object
=
is_temporary
)
workflow_script
.
setTitle
(
script
.
title
)
workflow_script
.
default_reference
=
script_id
workflow_script
.
setParameterSignature
(
script
.
_params
)
#workflow_script.setCallableType(script.callable_type)# not defined in python script?
workflow_script
.
setBody
(
script
.
_body
)
workflow_script
.
setProxyRole
(
script
.
_proxy_roles
)
if
workflow_type_id
==
'DCWorkflowDefinition'
:
if
workflow_type_id
==
'DCWorkflowDefinition'
:
# remove default state and variables
# remove default state and variables
for
def_var
in
workflow
.
objectValues
(
portal_type
=
'Workflow Variable'
):
for
def_var
in
workflow
.
objectValues
(
portal_type
=
'Workflow Variable'
):
...
@@ -309,6 +321,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
...
@@ -309,6 +321,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
workflow
.
_delObject
(
'state_draft'
)
workflow
.
_delObject
(
'state_draft'
)
dc_workflow_transition_value_list
=
dc_workflow
.
transitions
dc_workflow_transition_value_list
=
dc_workflow
.
transitions
dc_workflow_transition_id_list
=
dc_workflow_transition_value_list
.
objectIds
()
dc_workflow_transition_id_list
=
dc_workflow_transition_value_list
.
objectIds
()
# create transition (portal_type = Transition)
# create transition (portal_type = Transition)
for
tid
in
dc_workflow_transition_value_list
:
for
tid
in
dc_workflow_transition_value_list
:
tdef
=
dc_workflow_transition_value_list
.
get
(
tid
)
tdef
=
dc_workflow_transition_value_list
.
get
(
tid
)
...
@@ -324,20 +337,6 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
...
@@ -324,20 +337,6 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
transition
.
setAction
(
tdef
.
actbox_url
)
transition
.
setAction
(
tdef
.
actbox_url
)
transition
.
setDescription
(
tdef
.
description
)
transition
.
setDescription
(
tdef
.
description
)
before_script_path
=
getERP5ScriptPath
(
workflow
,
dc_workflow
,
tdef
.
script_name
,
'before_script'
)
after_script_path
=
getERP5ScriptPath
(
workflow
,
dc_workflow
,
tdef
.
after_script_name
,
'after_script'
)
if
before_script_path
or
after_script_path
:
script_list
=
transition
.
getCategoryList
()
if
before_script_path
:
script_list
.
append
(
before_script_path
)
if
after_script_path
:
script_list
.
append
(
after_script_path
)
transition
.
setCategoryList
(
script_list
)
# configure guard
# configure guard
if
tdef
.
guard
:
if
tdef
.
guard
:
transition
.
guard
=
tdef
.
guard
transition
.
guard
=
tdef
.
guard
...
@@ -346,6 +345,18 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
...
@@ -346,6 +345,18 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
transition
.
setGuardGroupList
(
tdef
.
guard
.
groups
)
transition
.
setGuardGroupList
(
tdef
.
guard
.
groups
)
if
tdef
.
guard
.
expr
is
not
None
:
if
tdef
.
guard
.
expr
is
not
None
:
transition
.
setGuardExpression
(
tdef
.
guard
.
expr
.
text
)
transition
.
setGuardExpression
(
tdef
.
guard
.
expr
.
text
)
for
transition
in
workflow
.
objectValues
(
portal_type
=
'Transition'
):
# configure after/before scripts
# we have to loop again over transitions because some
# before/after/... scripts are transitions and obviously, all of
# them were not defined on the new workflow in the previous loop
self
.
initialize_script_categories
(
workflow
,
tdef
.
script_name
,
transition
.
setBeforeScriptValueList
)
self
.
initialize_script_categories
(
workflow
,
tdef
.
after_script_name
,
transition
.
setAfterScriptValueList
)
# create states (portal_type = State)
# create states (portal_type = State)
for
sid
in
dc_workflow
.
states
:
for
sid
in
dc_workflow
.
states
:
sdef
=
dc_workflow
.
states
.
get
(
sid
)
sdef
=
dc_workflow
.
states
.
get
(
sid
)
...
@@ -446,31 +457,19 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
...
@@ -446,31 +457,19 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
if
tdef
.
title
:
if
tdef
.
title
:
interaction
.
setTitle
(
tdef
.
title
)
interaction
.
setTitle
(
tdef
.
title
)
interaction
.
setReference
(
tdef
.
id
)
interaction
.
setReference
(
tdef
.
id
)
script_list
=
[]
for
script_name
in
tdef
.
activate_script_name
:
# configure after/before/before commit/activate scripts
# Add a prefix iif there is a conflict (script and accessor).
# no need to loop again over interactions as made for transitions
if
hasattr
(
workflow
,
script_name
):
# because interactions xxx_script are not interactions
script_name
=
'ScriptPrefix_'
+
script_name
self
.
initialize_script_categories
(
workflow
,
tdef
.
script_name
,
script_list
.
append
(
script_name
)
interaction
.
setBeforeScriptValueList
)
interaction
.
setActivateScriptNameList
(
tuple
(
script_list
))
self
.
initialize_script_categories
(
workflow
,
tdef
.
after_script_name
,
script_list
=
[]
interaction
.
setAfterScriptValueList
)
for
script_name
in
tdef
.
after_script_name
:
self
.
initialize_script_categories
(
workflow
,
tdef
.
activate_script_name
,
if
hasattr
(
workflow
,
script_name
):
interaction
.
setActivateScriptValueList
)
script_name
=
'ScriptPrefix_'
+
script_name
self
.
initialize_script_categories
(
workflow
,
tdef
.
before_commit_script_name
,
script_list
.
append
(
script_name
)
interaction
.
setBeforeCommitScriptValueList
)
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
# configure guard
if
tdef
.
guard
:
if
tdef
.
guard
:
interaction
.
guard
=
tdef
.
guard
interaction
.
guard
=
tdef
.
guard
...
@@ -494,21 +493,6 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
...
@@ -494,21 +493,6 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
interaction
.
setTriggerType
(
tdef
.
trigger_type
)
interaction
.
setTriggerType
(
tdef
.
trigger_type
)
interaction
.
setDescription
(
tdef
.
description
)
interaction
.
setDescription
(
tdef
.
description
)
# create scripts (portal_type = Workflow Script)
dc_workflow_script_list
=
dc_workflow
.
scripts
for
script_id
in
dc_workflow_script_list
:
script
=
dc_workflow_script_list
.
get
(
script_id
)
# add a prefix if there is a script & method conflict
if
hasattr
(
workflow
,
script_id
):
workflow_script
=
workflow
.
newContent
(
id
=
'ScriptPrefix_'
+
script_id
,
portal_type
=
'Workflow Script'
,
temp_object
=
is_temporary
)
else
:
workflow_script
=
workflow
.
newContent
(
id
=
script_id
,
portal_type
=
'Workflow Script'
,
temp_object
=
is_temporary
)
workflow_script
.
setTitle
(
script
.
title
)
workflow_script
.
default_reference
=
script_id
workflow_script
.
setParameterSignature
(
script
.
_params
)
#workflow_script.setCallableType(script.callable_type)# not defined in python script?
workflow_script
.
setBody
(
script
.
_body
)
workflow_script
.
setProxyRole
(
script
.
_proxy_roles
)
# create variables (portal_type = Variable)
# create variables (portal_type = Variable)
for
variable_id
,
variable_definition
in
dc_workflow
.
variables
.
items
():
for
variable_id
,
variable_definition
in
dc_workflow
.
variables
.
items
():
variable
=
workflow
.
newContent
(
portal_type
=
'Workflow Variable'
,
temp_object
=
is_temporary
)
variable
=
workflow
.
newContent
(
portal_type
=
'Workflow Variable'
,
temp_object
=
is_temporary
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment