Commit f9510780 authored by Jérome Perrin's avatar Jérome Perrin

edit business link documents from the graph data

parent ebb30221
......@@ -56,23 +56,29 @@ graph = business_process.getProperty(\'jsplumb_graph\')\n
\n
\n
if graph:\n
portal = business_process.getPortalObject()\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
trade_state_dict[trade_state.getReference() or trade_state.getId()] = trade_state\n
\n
graph = json.loads(graph)[\'graph\']\n
\n
for edge_data in graph[\'edge\'].values():\n
# Create the business link if it does not exist yet.\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
predecessor_value=trade_state_dict[edge_data[\'source\']],\n
successor_value=trade_state_dict[edge_data[\'destination\']],\n
title=edge_data.get(\'name\'),\n
trade_phase=edge_data.get(\'trade_phase\'),\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
# XXX Zope does not like to traverse unicode ...\n
trade_phase=str(edge_data.get(\'trade_phase\', \'\')),\n
)\n
</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