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

edit business link documents from the graph data

parent 63ab390c
...@@ -56,22 +56,28 @@ graph = business_process.getProperty(\'jsplumb_graph\')\n ...@@ -56,22 +56,28 @@ graph = business_process.getProperty(\'jsplumb_graph\')\n
\n \n
\n \n
if graph:\n if graph:\n
portal = business_process.getPortalObject()\n
trade_state_dict = dict(start=None, end=None)\n trade_state_dict = dict(start=None, end=None)\n
for trade_state in business_process.getPortalObject().portal_categories.trade_state.getCategoryChildValueList():\n for trade_state in portal.portal_categories.trade_state.getCategoryChildValueList():\n
# XXX I hope no duplicates\n # XXX I hope no duplicates\n
trade_state_dict[trade_state.getReference() or trade_state.getId()] = trade_state\n trade_state_dict[trade_state.getReference() or trade_state.getId()] = trade_state\n
\n \n
graph = json.loads(graph)[\'graph\']\n graph = json.loads(graph)[\'graph\']\n
\n
for edge_data in graph[\'edge\'].values():\n for edge_data in graph[\'edge\'].values():\n
# Create the business link if it does not exist yet.\n # Create the business link if it does not exist yet.\n
if not edge_data.get(\'business_link_url\'):\n if not edge_data.get(\'business_link_url\'):\n
business_process.newContent(\n business_link = business_process.newContent(\n
portal_type=\'Business Link\',\n portal_type=\'Business Link\',\n
predecessor_value=trade_state_dict[edge_data[\'source\']],\n predecessor_value=trade_state_dict[edge_data[\'source\']],\n
successor_value=trade_state_dict[edge_data[\'destination\']],\n successor_value=trade_state_dict[edge_data[\'destination\']],\n
)\n
else:\n
# XXX Zope does not like to traverse unicode ...\n
business_link = portal.restrictedTraverse(str(edge_data[\'business_link_url\']))\n
business_link.edit(\n
title=edge_data.get(\'name\'),\n title=edge_data.get(\'name\'),\n
trade_phase=edge_data.get(\'trade_phase\'),\n # XXX Zope does not like to traverse unicode ...\n
trade_phase=str(edge_data.get(\'trade_phase\', \'\')),\n
)\n )\n
</string> </value> </string> </value>
</item> </item>
......
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