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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Laurent S
erp5
Commits
0fcbca5e
Commit
0fcbca5e
authored
Jun 05, 2015
by
wenjie.zheng
Committed by
Sebastien Robin
Jul 16, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WorkflowTool.py: add workfow conversion related functions.
parent
dd9a31cd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
145 additions
and
111 deletions
+145
-111
product/ERP5/Tool/WorkflowTool.py
product/ERP5/Tool/WorkflowTool.py
+145
-111
No files found.
product/ERP5/Tool/WorkflowTool.py
View file @
0fcbca5e
...
...
@@ -27,6 +27,7 @@
#
##############################################################################
import
cPickle
import
os
import
shutil
import
sys
...
...
@@ -34,7 +35,6 @@ import subprocess
import
time
import
transaction
import
struct
import
cPickle
import
urllib2
import
re
...
...
@@ -215,23 +215,6 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
raise
WorkflowException
(
msg
)
return
res
def
getWorkflowTempObjectList
(
self
):
""" Return a list of converted temporary workflows. Only necessary in
Workflow Tool to get temporarilly converted DCWorkflow.
"""
temp_workflow_list
=
[]
temp_workflow_id_list
=
[]
for
dc_workflow_id
in
self
.
getPortalObject
().
portal_workflow
:
dc_workflow
=
self
.
getPortalObject
().
portal_workflow
.
get
(
dc_workflow_id
)
workflow_type
=
dc_workflow
.
__class__
.
__name__
if
workflow_type
==
'Workflow'
or
workflow_type
==
'Interaction Workflow'
:
continue
temp_obj
=
1
temp_workflow
=
self
.
dc_workflow_asERP5Object
(
self
,
dc_workflow
,
temp_obj
)
temp_workflow_list
.
append
(
temp_workflow
)
temp_workflow_id_list
.
append
(
temp_workflow
.
getTitle
())
return
temp_workflow_list
def
getWorkflowValueListFor
(
self
,
portal_type_id
):
""" Return a list of workflows bound to selected portal_type.
"""
...
...
@@ -264,24 +247,68 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
return
wfh
[
-
1
]
return
None
def
decodeWorkflowUid
(
self
,
uid
):
return
cPickle
.
loads
(
b64decode
(
uid
))
def
encodeWorkflowUid
(
self
,
id
):
return
b64encode
(
cPickle
.
dumps
(
id
))
def
getObjectFromPath
(
self
,
path
):
return
self
.
unrestrictedTraverse
(
path
)
def
getWorkflowTempObjectList
(
self
,
temp_obj
=
1
):
""" Return a list of converted temporary workflows. Only necessary in
Workflow Tool to get temporarilly converted DCWorkflow.
"""
temp_workflow_list
=
[]
temp_workflow_id_list
=
[]
for
dc_workflow
in
self
.
getPortalObject
().
portal_workflow
.
objectValues
():
LOG
(
"Getting workflow '%s'"
%
dc_workflow
.
id
,
WARNING
,
" in WorkflowTool.py 257"
)
workflow_type
=
dc_workflow
.
__class__
.
__name__
if
workflow_type
==
'Workflow'
or
workflow_type
==
'Interaction Workflow'
:
LOG
(
"Ingore workflow '%s'"
%
dc_workflow
.
id
,
WARNING
,
" in WorkflowTool.py 260"
)
continue
temp_workflow
=
self
.
dc_workflow_asERP5Object
(
self
,
dc_workflow
,
temp_obj
)
temp_workflow_list
.
append
(
temp_workflow
)
temp_workflow_id_list
.
append
(
temp_workflow
.
getTitle
())
return
temp_workflow_list
def
dc_workflow_asERP5Object
(
self
,
container
,
dc_workflow
,
temp
):
# create a temporary ERP5 Workflow
workflow_type_id
=
dc_workflow
.
__class__
.
__name__
if
workflow_type_id
==
'DCWorkflowDefinition'
:
LOG
(
"2.a Workflow '%s' is a DCWorkflow'"
%
dc_workflow
.
id
,
WARNING
,
' in WorkflowTool.py'
)
workflow
=
container
.
newContent
(
portal_type
=
'Workflow'
,
temp_object
=
temp
)
if
temp
==
0
:
new_id
=
'workflow_'
+
dc_workflow
.
id
else
:
new_id
=
dc_workflow
.
id
uid
=
self
.
encodeWorkflowUid
(
new_id
)
workflow
=
container
.
newContent
(
id
=
new_id
,
portal_type
=
'Workflow'
,
temp_object
=
temp
)
LOG
(
" New workflow created '%s' '%s'"
%
(
workflow
.
getId
(),
workflow
.
getPortalType
()),
WARNING
,
"in WorkfowTool.py"
)
workflow
.
setStateVariable
(
dc_workflow
.
state_var
)
workflow
.
setWorkflowManagedPermission
(
dc_workflow
.
permissions
)
workflow
.
setSource
(
dc_workflow
.
initial_state
)
else
:
LOG
(
"2.b Workflow '%s' is a DC Interaction Workflow"
%
dc_workflow
.
getTitle
(),
WARNING
,
' in WorkflowTool.py'
)
workflow
=
container
.
newContent
(
portal_type
=
'Interaction Workflow'
,
temp_object
=
temp
)
if
temp
==
0
:
new_id
=
'interactionworkflow_'
+
dc_workflow
.
id
else
:
new_id
=
dc_workflow
.
id
uid
=
self
.
encodeWorkflowUid
(
new_id
)
workflow
=
container
.
newContent
(
id
=
new_id
,
portal_type
=
'Interaction Workflow'
,
temp_object
=
temp
)
LOG
(
" New workflow created '%s' '%s'"
%
(
workflow
.
getId
(),
workflow
.
getPortalType
()),
WARNING
,
"in WorkfowTool.py"
)
workflow
.
setManagerBypass
(
dc_workflow
.
manager_bypass
)
workflow
.
setReference
(
dc_workflow
.
id
)
if
temp
==
1
:
# give temp workflow an uid for form_dialog.
workflow
.
uid
=
uid
workflow
.
default_reference
=
dc_workflow
.
id
workflow
.
edit
(
title
=
dc_workflow
.
title
)
workflow
.
edit
(
description
=
dc_workflow
.
description
)
if
temp
==
0
:
# convert under request only
LOG
(
"Converting DCWorkflow"
,
WARNING
,
" in WorkflowTool.py"
)
# create transitions
if
workflow_type_id
==
'DCWorkflowDefinition'
:
for
tid
in
dc_workflow
.
transitions
:
...
...
@@ -308,6 +335,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
state
.
setReference
(
sdef
.
id
)
state
.
setStatePermissionRoles
(
sdef
.
permission_roles
)
state
.
setDestinationList
(
sdef
.
transitions
)
workflow
.
setSource
(
getattr
(
workflow
,
'state_'
+
dc_workflow
.
initial_state
).
getPath
())
# create worklists (portal_type = Worklist)
for
qid
in
dc_workflow
.
worklists
:
qdef
=
dc_workflow
.
worklists
.
get
(
qid
)
...
...
@@ -353,9 +381,9 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
workflow_script
=
workflow
.
newContent
(
portal_type
=
'Workflow Script'
,
temp_object
=
temp
)
LOG
(
"2.5 Convert workflow script '%s' of workflow '%s'"
%
(
workflow_script
.
id
,
workflow
.
getTitle
()),
WARNING
,
' in WorkflowTool.py'
)
workflow_script
.
edit
(
title
=
script
.
title
)
workflow_script
.
setId
(
script
.
id
)
workflow_script
.
id
=
script
.
id
workflow_script
.
setParameterSignature
(
script
.
_params
)
#workflow_script.setCallableType(script.callable_type)# not defined in DC
script?
#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)
...
...
@@ -535,6 +563,12 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
return
getattr
(
self
,
'Base_getWorklistIgnoredSecurityColumnSet'
,
lambda
:
())()
def
getTypeCBT
(
self
,
pt
):
return
self
.
_chains_by_type
.
get
(
pt
)
def
delTypeCBT
(
self
,
pt
,
wf_id
):
self
.
_chains_by_type
=
tuple
(
list
(
self
.
_chains_by_type
).
remove
(
wf_id
))
def
listActions
(
self
,
info
=
None
,
object
=
None
,
src__
=
False
):
"""
Returns a list of actions to be displayed to the user.
...
...
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