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