Commit 4ddc5d73 authored by Jérome Perrin's avatar Jérome Perrin

display nodes for all trade states and also for start and end implicit states

parent 8e9c955a
......@@ -50,38 +50,55 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>import json\n
<value> <string>from Products.ERP5Type.Message import translateString\n
import json\n
portal = context.getPortalObject()\n
\n
import json\n
#context.manage_delProperties([\'jsplumb_graph\'])\n
# if a graph has been saved, we use this info for node coordinates.\n
position_graph = context.getProperty(\'jsplumb_graph\')\n
\n
if position_graph:\n
context.log(position_graph)\n
position_graph = json.loads(position_graph)[\'graph\']\n
\n
visited_business_process_set = set() # prevent infinite recurisions\n
\n
def getBusinessProcessGraph(business_process):\n
graph = dict(node=dict(), edge=dict())\n
graph = dict(node=dict(start=dict(_class=\'erp5.business_process.start\',\n
name=str(translateString(\'Start\'))),\n
end=dict(_class=\'erp5.business_process.end\',\n
name=str(translateString(\'End\'))),),\n
edge=dict())\n
\n
\n
for trade_state in portal.portal_categories.trade_state.getCategoryChildValueList(): # XXX all\n
state_id = trade_state.getReference() or trade_state.getId()\n
graph[\'node\'][state_id] = dict(\n
_class=\'erp5.business_process.trade_state\',\n
name=trade_state.getTranslatedTitle())\n
\n
for state_id in graph[\'node\'].keys():\n
if position_graph and state_id in position_graph[\'node\']:\n
graph[\'node\'][state_id][\'coordinate\'] = position_graph[\'node\'][state_id][\'coordinate\']\n
\n
if business_process in visited_business_process_set:\n
return graph\n
visited_business_process_set.add(business_process)\n
for link in business_process.contentValues(portal_type=\'Business Link\'):\n
for trade_state in (link.getPredecessorValue(), link.getSuccessorValue()):\n
if trade_state is not None:\n
state_id = trade_state.getReference() or trade_state.getId()\n
graph[\'node\'][state_id] = dict(\n
_class=\'erp5.business_process.trade_state\',\n
name=trade_state.getTranslatedTitle())\n
if state_id in position_graph[\'node\']:\n
graph[\'node\'][state_id][\'coordinate\'] = position_graph[\'node\'][state_id][\'coordinate\'] \n
if link.getPredecessor() and link.getSuccessor(): # XXX no start ??\n
graph[\'edge\'][link.getRelativeUrl()] = dict(\n
\n
predecessor = \'start\'\n
if link.getPredecessor():\n
predecessor = link.getPredecessorReference() or link.getPredecessorId()\n
successor = \'end\'\n
if link.getSuccessor():\n
successor = link.getSuccessorReference() or link.getSuccessorId()\n
\n
graph[\'edge\'][link.getRelativeUrl()] = dict(\n
_class=\'erp5.business_process.business_link\',\n
source=link.getPredecessorReference() or link.getPredecessorId(),\n
destination=link.getSuccessorReference() or link.getSuccessorId(),\n
name=link.getTranslatedTitle())\n
source=predecessor,\n
destination=successor,\n
name=link.getTranslatedTitle(),\n
business_process_relative_url=context.getRelativeUrl(),\n
trade_phase=link.getTradePhase())\n
\n
for specialise in [context] + business_process.getSpecialiseValueList(portal_type=\'Business Process\'):\n
specialise_graph = getBusinessProcessGraph(specialise)\n
......
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