From 773772a766e1f89e85fe6a68ec8de735dd2a0771 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=81ukasz=20Nowak?= <luke@nexedi.com>
Date: Tue, 28 Jul 2009 15:43:00 +0000
Subject: [PATCH]  - implement example of detached, but interactive, building
 process using interaction workflow reacting on delivery state change

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28196 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../workflow_chain_type.xml                   |   4 +
 .../delivery_build_interaction_workflow.xml   |  49 +++++++
 .../interactions.xml                          |  31 ++++
 .../interactions/order_confirm.xml            |  95 +++++++++++++
 .../scripts.xml                               |  31 ++++
 .../scripts/Delivery_build.xml                | 134 ++++++++++++++++++
 .../variables.xml                             |  25 ++++
 .../worklists.xml                             |  25 ++++
 bt5/erp5_bpm/bt/revision                      |   2 +-
 .../template_portal_type_workflow_chain_list  |   3 +-
 bt5/erp5_bpm/bt/template_workflow_id_list     |   1 +
 11 files changed, 398 insertions(+), 2 deletions(-)
 create mode 100644 bt5/erp5_bpm/WorkflowTemplateItem/portal_workflow/delivery_build_interaction_workflow.xml
 create mode 100644 bt5/erp5_bpm/WorkflowTemplateItem/portal_workflow/delivery_build_interaction_workflow/interactions.xml
 create mode 100644 bt5/erp5_bpm/WorkflowTemplateItem/portal_workflow/delivery_build_interaction_workflow/interactions/order_confirm.xml
 create mode 100644 bt5/erp5_bpm/WorkflowTemplateItem/portal_workflow/delivery_build_interaction_workflow/scripts.xml
 create mode 100644 bt5/erp5_bpm/WorkflowTemplateItem/portal_workflow/delivery_build_interaction_workflow/scripts/Delivery_build.xml
 create mode 100644 bt5/erp5_bpm/WorkflowTemplateItem/portal_workflow/delivery_build_interaction_workflow/variables.xml
 create mode 100644 bt5/erp5_bpm/WorkflowTemplateItem/portal_workflow/delivery_build_interaction_workflow/worklists.xml

diff --git a/bt5/erp5_bpm/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml b/bt5/erp5_bpm/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml
index def03dafa4..a13c983c1f 100644
--- a/bt5/erp5_bpm/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml
+++ b/bt5/erp5_bpm/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml
@@ -15,4 +15,8 @@
   <type>BPM Order Rule</type>
   <workflow>rule_validation_workflow, edit_workflow</workflow>
  </chain>
+ <chain>
+  <type>Sale Order</type>
+  <workflow>delivery_build_interaction_workflow</workflow>
+ </chain>
 </workflow_chain>
\ No newline at end of file
diff --git a/bt5/erp5_bpm/WorkflowTemplateItem/portal_workflow/delivery_build_interaction_workflow.xml b/bt5/erp5_bpm/WorkflowTemplateItem/portal_workflow/delivery_build_interaction_workflow.xml
new file mode 100644
index 0000000000..5ca52c6e6b
--- /dev/null
+++ b/bt5/erp5_bpm/WorkflowTemplateItem/portal_workflow/delivery_build_interaction_workflow.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <global name="InteractionWorkflowDefinition" module="Products.ERP5.InteractionWorkflow"/>
+        <tuple/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_objects</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>creation_guard</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>description</string> </key>
+            <value> <string>Exmaple of BPM enabled building of deliveries after passing workflow transitions</string> </value>
+        </item>
+        <item>
+            <key> <string>groups</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>delivery_build_interaction_workflow</string> </value>
+        </item>
+        <item>
+            <key> <string>manager_bypass</string> </key>
+            <value> <int>0</int> </value>
+        </item>
+        <item>
+            <key> <string>title</string> </key>
+            <value> <string>Building deliveries after passing transition Interaction Workflow</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_bpm/WorkflowTemplateItem/portal_workflow/delivery_build_interaction_workflow/interactions.xml b/bt5/erp5_bpm/WorkflowTemplateItem/portal_workflow/delivery_build_interaction_workflow/interactions.xml
new file mode 100644
index 0000000000..6788072919
--- /dev/null
+++ b/bt5/erp5_bpm/WorkflowTemplateItem/portal_workflow/delivery_build_interaction_workflow/interactions.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <global name="Interaction" module="Products.ERP5.Interaction"/>
+        <tuple/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_mapping</string> </key>
+            <value>
+              <dictionary/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_objects</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>interactions</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_bpm/WorkflowTemplateItem/portal_workflow/delivery_build_interaction_workflow/interactions/order_confirm.xml b/bt5/erp5_bpm/WorkflowTemplateItem/portal_workflow/delivery_build_interaction_workflow/interactions/order_confirm.xml
new file mode 100644
index 0000000000..ab07044528
--- /dev/null
+++ b/bt5/erp5_bpm/WorkflowTemplateItem/portal_workflow/delivery_build_interaction_workflow/interactions/order_confirm.xml
@@ -0,0 +1,95 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <global name="InteractionDefinition" module="Products.ERP5.Interaction"/>
+        <tuple/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>actbox_category</string> </key>
+            <value> <string>workflow</string> </value>
+        </item>
+        <item>
+            <key> <string>actbox_name</string> </key>
+            <value> <string></string> </value>
+        </item>
+        <item>
+            <key> <string>actbox_url</string> </key>
+            <value> <string></string> </value>
+        </item>
+        <item>
+            <key> <string>activate_script_name</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>after_script_name</string> </key>
+            <value>
+              <list>
+                <string>Delivery_build</string>
+              </list>
+            </value>
+        </item>
+        <item>
+            <key> <string>before_commit_script_name</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>description</string> </key>
+            <value> <string></string> </value>
+        </item>
+        <item>
+            <key> <string>guard</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>order_confirm</string> </value>
+        </item>
+        <item>
+            <key> <string>method_id</string> </key>
+            <value>
+              <list>
+                <string>confirm</string>
+              </list>
+            </value>
+        </item>
+        <item>
+            <key> <string>once_per_transaction</string> </key>
+            <value> <int>0</int> </value>
+        </item>
+        <item>
+            <key> <string>portal_type_filter</string> </key>
+            <value>
+              <list>
+                <string>Sale Order</string>
+              </list>
+            </value>
+        </item>
+        <item>
+            <key> <string>script_name</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>title</string> </key>
+            <value> <string>Build Order after confirming</string> </value>
+        </item>
+        <item>
+            <key> <string>trigger_type</string> </key>
+            <value> <int>2</int> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_bpm/WorkflowTemplateItem/portal_workflow/delivery_build_interaction_workflow/scripts.xml b/bt5/erp5_bpm/WorkflowTemplateItem/portal_workflow/delivery_build_interaction_workflow/scripts.xml
new file mode 100644
index 0000000000..0622b3c34f
--- /dev/null
+++ b/bt5/erp5_bpm/WorkflowTemplateItem/portal_workflow/delivery_build_interaction_workflow/scripts.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <global name="Scripts" module="Products.DCWorkflow.Scripts"/>
+        <tuple/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_mapping</string> </key>
+            <value>
+              <dictionary/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_objects</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>scripts</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_bpm/WorkflowTemplateItem/portal_workflow/delivery_build_interaction_workflow/scripts/Delivery_build.xml b/bt5/erp5_bpm/WorkflowTemplateItem/portal_workflow/delivery_build_interaction_workflow/scripts/Delivery_build.xml
new file mode 100644
index 0000000000..80fd159bcc
--- /dev/null
+++ b/bt5/erp5_bpm/WorkflowTemplateItem/portal_workflow/delivery_build_interaction_workflow/scripts/Delivery_build.xml
@@ -0,0 +1,134 @@
+<?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>delivery = state_change[\'object\']\n
+business_process = delivery.getRootSpecialiseValue(portal_type_list=[\'Business Process\'])\n
+if business_process is not None:\n
+  # XXX: after_method_id is only for example in this case\n
+  business_process.activate(activity=\'SQLQueue\', after_method_id = [ \'expand\',\n
+                              \'recursiveImmediateReindexObject\',\n
+                              \'updateAppliedRule\',\n
+                              \'immediateReindexObject\' ],\n
+  ).build(delivery.getRelativeUrl())\n
+</string> </value>
+        </item>
+        <item>
+            <key> <string>_code</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_params</string> </key>
+            <value> <string>state_change</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>1</int> </value>
+                    </item>
+                    <item>
+                        <key> <string>co_varnames</string> </key>
+                        <value>
+                          <tuple>
+                            <string>state_change</string>
+                            <string>_getitem_</string>
+                            <string>delivery</string>
+                            <string>_getattr_</string>
+                            <string>business_process</string>
+                            <string>None</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>Delivery_build</string> </value>
+        </item>
+        <item>
+            <key> <string>warnings</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_bpm/WorkflowTemplateItem/portal_workflow/delivery_build_interaction_workflow/variables.xml b/bt5/erp5_bpm/WorkflowTemplateItem/portal_workflow/delivery_build_interaction_workflow/variables.xml
new file mode 100644
index 0000000000..5547232278
--- /dev/null
+++ b/bt5/erp5_bpm/WorkflowTemplateItem/portal_workflow/delivery_build_interaction_workflow/variables.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <global name="Variables" module="Products.DCWorkflow.Variables"/>
+        <tuple/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_mapping</string> </key>
+            <value>
+              <dictionary/>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>variables</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_bpm/WorkflowTemplateItem/portal_workflow/delivery_build_interaction_workflow/worklists.xml b/bt5/erp5_bpm/WorkflowTemplateItem/portal_workflow/delivery_build_interaction_workflow/worklists.xml
new file mode 100644
index 0000000000..1f8b17b012
--- /dev/null
+++ b/bt5/erp5_bpm/WorkflowTemplateItem/portal_workflow/delivery_build_interaction_workflow/worklists.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <global name="Worklists" module="Products.DCWorkflow.Worklists"/>
+        <tuple/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_mapping</string> </key>
+            <value>
+              <dictionary/>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>worklists</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_bpm/bt/revision b/bt5/erp5_bpm/bt/revision
index d903d59723..20ad60520b 100644
--- a/bt5/erp5_bpm/bt/revision
+++ b/bt5/erp5_bpm/bt/revision
@@ -1 +1 @@
-229
\ No newline at end of file
+230
\ No newline at end of file
diff --git a/bt5/erp5_bpm/bt/template_portal_type_workflow_chain_list b/bt5/erp5_bpm/bt/template_portal_type_workflow_chain_list
index c6f12df832..5dee118cd7 100644
--- a/bt5/erp5_bpm/bt/template_portal_type_workflow_chain_list
+++ b/bt5/erp5_bpm/bt/template_portal_type_workflow_chain_list
@@ -6,4 +6,5 @@ BPM Invoice Transaction Rule | rule_validation_workflow
 BPM Invoicing Rule | edit_workflow
 BPM Invoicing Rule | rule_validation_workflow
 BPM Order Rule | edit_workflow
-BPM Order Rule | rule_validation_workflow
\ No newline at end of file
+BPM Order Rule | rule_validation_workflow
+Sale Order | delivery_build_interaction_workflow
\ No newline at end of file
diff --git a/bt5/erp5_bpm/bt/template_workflow_id_list b/bt5/erp5_bpm/bt/template_workflow_id_list
index 16406dafdb..235eb6edb3 100644
--- a/bt5/erp5_bpm/bt/template_workflow_id_list
+++ b/bt5/erp5_bpm/bt/template_workflow_id_list
@@ -1,3 +1,4 @@
+delivery_build_interaction_workflow
 delivery_causality_workflow
 order_workflow
 packing_list_workflow
-- 
2.30.9