From 53144c712a695c182b5ac786383d2a8a21e3fc53 Mon Sep 17 00:00:00 2001
From: Kazuhiko Shiozaki <kazuhiko@nexedi.com>
Date: Wed, 10 Feb 2010 05:09:33 +0000
Subject: [PATCH] update divergence solving dialog.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32387 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../Delivery_getSolverDecisionList.xml        |  29 +++-
 .../Delivery_updateSolveDivergenceDialog.xml  |  13 +-
 .../listbox_delivery_solver.xml               |   8 +-
 .../listbox_solver_configuration.xml          |   4 +-
 .../SolverDecision_getDeliverySolverList.xml  | 132 ++++++++++++++++++
 5 files changed, 173 insertions(+), 13 deletions(-)
 create mode 100644 bt5/erp5_simulation/SkinTemplateItem/portal_skins/erp5_simulation/SolverDecision_getDeliverySolverList.xml

diff --git a/bt5/erp5_simulation/SkinTemplateItem/portal_skins/erp5_simulation/Delivery_getSolverDecisionList.xml b/bt5/erp5_simulation/SkinTemplateItem/portal_skins/erp5_simulation/Delivery_getSolverDecisionList.xml
index 9b3ed6f5cb..f74319d857 100644
--- a/bt5/erp5_simulation/SkinTemplateItem/portal_skins/erp5_simulation/Delivery_getSolverDecisionList.xml
+++ b/bt5/erp5_simulation/SkinTemplateItem/portal_skins/erp5_simulation/Delivery_getSolverDecisionList.xml
@@ -53,10 +53,24 @@
         </item>
         <item>
             <key> <string>_body</string> </key>
-            <value> <string># XXX currently we create a temporary Solver Process and build temporary Solver Decision in it.\n
-# But for better performance, Solver Process and Solver Decision should be created by causality\n
-# workflow when a delivery becomes divergent.\n
-solver_process = context.getPortalObject().portal_solvers.newSolverProcess(context, temp_object=True)\n
+            <value> <string># XXX currently we create a Solver Process and build Solver Decision in it if missing.\n
+# But for better performance, Solver Process and Solver Decision should be created beforehand\n
+# by causality workflow when a delivery becomes divergent.\n
+solver_process = None\n
+solver_list = context.getSolverValueList()\n
+for i in solver_list:\n
+  # XXX if \'solving\' decision exists, what should we do?\n
+  if i.getSolverState() != \'solved\':\n
+    solver_process = i\n
+    break\n
+context.log(solver_process)\n
+if solver_process is None:\n
+  context.log(solver_process)\n
+  solver_process = context.getPortalObject().portal_solvers.newSolverProcess(context)\n
+  context.log(solver_process)\n
+  solver_list.append(solver_process.getRelativeUrl())\n
+  context.setSolverList(solver_list)\n
+# XXX should omit \'solved\' decision?\n
 return solver_process.objectValues(portal_type=\'Solver Decision\')\n
 </string> </value>
         </item>
@@ -95,10 +109,13 @@ return solver_process.objectValues(portal_type=\'Solver Decision\')\n
                         <value>
                           <tuple>
                             <string>kw</string>
+                            <string>None</string>
+                            <string>solver_process</string>
                             <string>_getattr_</string>
                             <string>context</string>
-                            <string>True</string>
-                            <string>solver_process</string>
+                            <string>solver_list</string>
+                            <string>_getiter_</string>
+                            <string>i</string>
                           </tuple>
                         </value>
                     </item>
diff --git a/bt5/erp5_simulation/SkinTemplateItem/portal_skins/erp5_simulation/Delivery_updateSolveDivergenceDialog.xml b/bt5/erp5_simulation/SkinTemplateItem/portal_skins/erp5_simulation/Delivery_updateSolveDivergenceDialog.xml
index cefa2b0535..e78d41f464 100644
--- a/bt5/erp5_simulation/SkinTemplateItem/portal_skins/erp5_simulation/Delivery_updateSolveDivergenceDialog.xml
+++ b/bt5/erp5_simulation/SkinTemplateItem/portal_skins/erp5_simulation/Delivery_updateSolveDivergenceDialog.xml
@@ -58,12 +58,17 @@ listbox = request.get(\'listbox\')\n
 line_list = context.Delivery_getSolverDecisionList(listbox=listbox)\n
 for listbox_key in listbox:\n
   listbox_dict = listbox[listbox_key]\n
-  line = [x for x in line_list if x.getId() == listbox_key][0]\n
+  line = [x for x in line_list if x.getPath() == listbox_key][0]\n
   uid = line.getUid()\n
-  for property in (\'solver\', \'solver_parameter\', \'target_solver\', \'comment\',):\n
-    value = listbox_dict.get(property, \'\')\n
+  for property in (\'solver\', \'solver_configuration\', \'delivery_solver\', \'comment\',):\n
+    value = listbox_dict.get(property, None)\n
     key = \'field_listbox_%s_%s\' % (property, uid)\n
     request.form[key] = request.other[key] = value\n
+    if property == \'solver_configuration\':\n
+      if value is not None:\n
+        line.updateConfiguration(**value.as_dict())\n
+    else:\n
+      line.setProperty(property, value)\n
 \n
 return context.Delivery_viewSolveDivergenceDialog(listbox=listbox)\n
 </string> </value>
@@ -118,9 +123,11 @@ return context.Delivery_viewSolveDivergenceDialog(listbox=listbox)\n
                             <string>line</string>
                             <string>uid</string>
                             <string>property</string>
+                            <string>None</string>
                             <string>value</string>
                             <string>key</string>
                             <string>_write_</string>
+                            <string>_apply_</string>
                           </tuple>
                         </value>
                     </item>
diff --git a/bt5/erp5_simulation/SkinTemplateItem/portal_skins/erp5_simulation/Delivery_viewSolveDivergenceDialog/listbox_delivery_solver.xml b/bt5/erp5_simulation/SkinTemplateItem/portal_skins/erp5_simulation/Delivery_viewSolveDivergenceDialog/listbox_delivery_solver.xml
index f9f0a4353c..f3a4880333 100644
--- a/bt5/erp5_simulation/SkinTemplateItem/portal_skins/erp5_simulation/Delivery_viewSolveDivergenceDialog/listbox_delivery_solver.xml
+++ b/bt5/erp5_simulation/SkinTemplateItem/portal_skins/erp5_simulation/Delivery_viewSolveDivergenceDialog/listbox_delivery_solver.xml
@@ -277,7 +277,11 @@
       <dictionary>
         <item>
             <key> <string>_text</string> </key>
-            <value> <string>python:request.get(\'listbox\', {}).get(cell.getId(), {}).get(\'solver\', \'\')</string> </value>
+            <value> <string encoding="cdata"><![CDATA[
+
+python:request.get(\'listbox\', {}).get(cell.getPath(), {}).get(\'solver\', \'\') and len(cell.SolverDecision_getDeliverySolverList()) > 1
+
+]]></string> </value>
         </item>
       </dictionary>
     </pickle>
@@ -293,7 +297,7 @@
       <dictionary>
         <item>
             <key> <string>_text</string> </key>
-            <value> <string>python:here.Delivery_getDeliverySolverList(cell.getId())</string> </value>
+            <value> <string>python:cell.SolverDecision_getDeliverySolverList()</string> </value>
         </item>
       </dictionary>
     </pickle>
diff --git a/bt5/erp5_simulation/SkinTemplateItem/portal_skins/erp5_simulation/Delivery_viewSolveDivergenceDialog/listbox_solver_configuration.xml b/bt5/erp5_simulation/SkinTemplateItem/portal_skins/erp5_simulation/Delivery_viewSolveDivergenceDialog/listbox_solver_configuration.xml
index bafc92a0a4..29a5c4e104 100644
--- a/bt5/erp5_simulation/SkinTemplateItem/portal_skins/erp5_simulation/Delivery_viewSolveDivergenceDialog/listbox_solver_configuration.xml
+++ b/bt5/erp5_simulation/SkinTemplateItem/portal_skins/erp5_simulation/Delivery_viewSolveDivergenceDialog/listbox_solver_configuration.xml
@@ -187,7 +187,7 @@
       <dictionary>
         <item>
             <key> <string>_text</string> </key>
-            <value> <string>python:request.get(\'listbox\', {}).get(cell.getId(), {}).get(\'solver\', \'\')</string> </value>
+            <value> <string>cell/getSolver</string> </value>
         </item>
       </dictionary>
     </pickle>
@@ -203,7 +203,7 @@
       <dictionary>
         <item>
             <key> <string>_text</string> </key>
-            <value> <string>python:here.Delivery_getSolverConfigurationFormId(cell.getId())</string> </value>
+            <value> <string>python:cell.getSolverValue().getConfigurationFormId()</string> </value>
         </item>
       </dictionary>
     </pickle>
diff --git a/bt5/erp5_simulation/SkinTemplateItem/portal_skins/erp5_simulation/SolverDecision_getDeliverySolverList.xml b/bt5/erp5_simulation/SkinTemplateItem/portal_skins/erp5_simulation/SolverDecision_getDeliverySolverList.xml
new file mode 100644
index 0000000000..cecdef3319
--- /dev/null
+++ b/bt5/erp5_simulation/SkinTemplateItem/portal_skins/erp5_simulation/SolverDecision_getDeliverySolverList.xml
@@ -0,0 +1,132 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
+        <tuple/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>Script_magic</string> </key>
+            <value> <int>3</int> </value>
+        </item>
+        <item>
+            <key> <string>_bind_names</string> </key>
+            <value>
+              <object>
+                <klass>
+                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
+                </klass>
+                <tuple/>
+                <state>
+                  <dictionary>
+                    <item>
+                        <key> <string>_asgns</string> </key>
+                        <value>
+                          <dictionary>
+                            <item>
+                                <key> <string>name_container</string> </key>
+                                <value> <string>container</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_context</string> </key>
+                                <value> <string>context</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_m_self</string> </key>
+                                <value> <string>script</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_subpath</string> </key>
+                                <value> <string>traverse_subpath</string> </value>
+                            </item>
+                          </dictionary>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>_body</string> </key>
+            <value> <string>try:\n
+  return [(\'\', \'\')] + [x for x in context.getPortalObject().portal_solvers.getDeliverySolverTranslatedItemList() \\\n
+      if x[1] in context.getSolverValue().getDeliverySolverList()]\n
+except AttributeError:\n
+  return [(\'\', \'\')]\n
+</string> </value>
+        </item>
+        <item>
+            <key> <string>_code</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_params</string> </key>
+            <value> <string></string> </value>
+        </item>
+        <item>
+            <key> <string>errors</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>func_code</string> </key>
+            <value>
+              <object>
+                <klass>
+                  <global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
+                </klass>
+                <tuple/>
+                <state>
+                  <dictionary>
+                    <item>
+                        <key> <string>co_argcount</string> </key>
+                        <value> <int>0</int> </value>
+                    </item>
+                    <item>
+                        <key> <string>co_varnames</string> </key>
+                        <value>
+                          <tuple>
+                            <string>append</string>
+                            <string>$append0</string>
+                            <string>_getiter_</string>
+                            <string>_getattr_</string>
+                            <string>context</string>
+                            <string>x</string>
+                            <string>_getitem_</string>
+                            <string>AttributeError</string>
+                          </tuple>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>func_defaults</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>SolverDecision_getDeliverySolverList</string> </value>
+        </item>
+        <item>
+            <key> <string>warnings</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
-- 
2.30.9