From c688e0cd729b47379befbc22e80d013d9f8dd6dd Mon Sep 17 00:00:00 2001
From: Jean-Paul Smets <jp@nexedi.com>
Date: Sat, 13 Oct 2007 16:28:28 +0000
Subject: [PATCH] Upgrade workflow logic to support email ingestion yet keep
 the posisbility to delete draft content.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16984 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../interactions/Event_upload.xml}            |  97 ++++++------
 .../scripts/receiveEvent.xml                  | 147 ++++++++++++++++++
 .../event_workflow/states/draft.xml           |   8 +-
 3 files changed, 199 insertions(+), 53 deletions(-)
 rename bt5/erp5_crm/WorkflowTemplateItem/portal_workflow/{event_workflow/transitions/receive_automatic.xml => event_interaction_workflow/interactions/Event_upload.xml} (50%)
 create mode 100644 bt5/erp5_crm/WorkflowTemplateItem/portal_workflow/event_interaction_workflow/scripts/receiveEvent.xml

diff --git a/bt5/erp5_crm/WorkflowTemplateItem/portal_workflow/event_workflow/transitions/receive_automatic.xml b/bt5/erp5_crm/WorkflowTemplateItem/portal_workflow/event_interaction_workflow/interactions/Event_upload.xml
similarity index 50%
rename from bt5/erp5_crm/WorkflowTemplateItem/portal_workflow/event_workflow/transitions/receive_automatic.xml
rename to bt5/erp5_crm/WorkflowTemplateItem/portal_workflow/event_interaction_workflow/interactions/Event_upload.xml
index 146d470920..fd48fa2d73 100644
--- a/bt5/erp5_crm/WorkflowTemplateItem/portal_workflow/event_workflow/transitions/receive_automatic.xml
+++ b/bt5/erp5_crm/WorkflowTemplateItem/portal_workflow/event_interaction_workflow/interactions/Event_upload.xml
@@ -3,11 +3,8 @@
   <record id="1" aka="AAAAAAAAAAE=">
     <pickle>
       <tuple>
-        <tuple>
-          <string>Products.DCWorkflow.Transitions</string>
-          <string>TransitionDefinition</string>
-        </tuple>
-        <none/>
+        <global name="InteractionDefinition" module="Products.ERP5.Interaction"/>
+        <tuple/>
       </tuple>
     </pickle>
     <pickle>
@@ -18,6 +15,12 @@
               <none/>
             </value>
         </item>
+        <item>
+            <key> <string>_owner</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
         <item>
             <key> <string>actbox_category</string> </key>
             <value> <string>workflow</string> </value>
@@ -30,73 +33,73 @@
             <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> <string></string> </value>
+            <value>
+              <list>
+                <string>receiveEvent</string>
+              </list>
+            </value>
         </item>
         <item>
             <key> <string>description</string> </key>
-            <value> <string>The receive automatic transition sets the event state to new whenever this events contains an email file.</string> </value>
+            <value> <string>Each time a file is uploaded into an event, it should be considered as a new message.</string> </value>
         </item>
         <item>
             <key> <string>guard</string> </key>
             <value>
-              <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
+              <none/>
             </value>
         </item>
         <item>
             <key> <string>id</string> </key>
-            <value> <string>receive_automatic</string> </value>
-        </item>
-        <item>
-            <key> <string>new_state_id</string> </key>
-            <value> <string>new</string> </value>
+            <value> <string>Event_upload</string> </value>
         </item>
         <item>
-            <key> <string>script_name</string> </key>
-            <value> <string></string> </value>
+            <key> <string>method_id</string> </key>
+            <value>
+              <list>
+                <string>_setFile</string>
+              </list>
+            </value>
         </item>
         <item>
-            <key> <string>title</string> </key>
-            <value> <string></string> </value>
+            <key> <string>once_per_transaction</string> </key>
+            <value> <int>0</int> </value>
         </item>
         <item>
-            <key> <string>trigger_type</string> </key>
-            <value> <int>0</int> </value>
+            <key> <string>portal_type_filter</string> </key>
+            <value>
+              <list>
+                <string>Fax Message</string>
+                <string>Letter</string>
+                <string>Mail Message</string>
+                <string>Note</string>
+                <string>Phone Call</string>
+                <string>Visit</string>
+                <string>Web Message</string>
+              </list>
+            </value>
         </item>
-      </dictionary>
-    </pickle>
-  </record>
-  <record id="2" aka="AAAAAAAAAAI=">
-    <pickle>
-      <tuple>
-        <global name="Guard" module="Products.DCWorkflow.Guard"/>
-        <tuple/>
-      </tuple>
-    </pickle>
-    <pickle>
-      <dictionary>
         <item>
-            <key> <string>expr</string> </key>
+            <key> <string>script_name</string> </key>
             <value>
-              <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
+              <tuple/>
             </value>
         </item>
-      </dictionary>
-    </pickle>
-  </record>
-  <record id="3" aka="AAAAAAAAAAM=">
-    <pickle>
-      <tuple>
-        <global name="Expression" module="Products.CMFCore.Expression"/>
-        <tuple/>
-      </tuple>
-    </pickle>
-    <pickle>
-      <dictionary>
         <item>
-            <key> <string>text</string> </key>
-            <value> <string>here/hasData</string> </value>
+            <key> <string>title</string> </key>
+            <value> <string>Upload Event Message</string> </value>
+        </item>
+        <item>
+            <key> <string>trigger_type</string> </key>
+            <value> <int>2</int> </value>
         </item>
       </dictionary>
     </pickle>
diff --git a/bt5/erp5_crm/WorkflowTemplateItem/portal_workflow/event_interaction_workflow/scripts/receiveEvent.xml b/bt5/erp5_crm/WorkflowTemplateItem/portal_workflow/event_interaction_workflow/scripts/receiveEvent.xml
new file mode 100644
index 0000000000..d349652fda
--- /dev/null
+++ b/bt5/erp5_crm/WorkflowTemplateItem/portal_workflow/event_interaction_workflow/scripts/receiveEvent.xml
@@ -0,0 +1,147 @@
+<?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>Python_magic</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>Script_magic</string> </key>
+            <value> <int>3</int> </value>
+        </item>
+        <item>
+            <key> <string>__ac_local_roles__</string> </key>
+            <value>
+              <none/>
+            </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>state_change[\'object\'].receive()\n
+</string> </value>
+        </item>
+        <item>
+            <key> <string>_code</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_filepath</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_owner</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>_getattr_</string>
+                            <string>_getitem_</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>receiveEvent</string> </value>
+        </item>
+        <item>
+            <key> <string>warnings</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_crm/WorkflowTemplateItem/portal_workflow/event_workflow/states/draft.xml b/bt5/erp5_crm/WorkflowTemplateItem/portal_workflow/event_workflow/states/draft.xml
index 439503632d..c55db96422 100644
--- a/bt5/erp5_crm/WorkflowTemplateItem/portal_workflow/event_workflow/states/draft.xml
+++ b/bt5/erp5_crm/WorkflowTemplateItem/portal_workflow/event_workflow/states/draft.xml
@@ -3,11 +3,8 @@
   <record id="1" aka="AAAAAAAAAAE=">
     <pickle>
       <tuple>
-        <tuple>
-          <string>Products.DCWorkflow.States</string>
-          <string>StateDefinition</string>
-        </tuple>
-        <none/>
+        <global name="StateDefinition" module="Products.DCWorkflow.States"/>
+        <tuple/>
       </tuple>
     </pickle>
     <pickle>
@@ -48,7 +45,6 @@
                 <string>plan_action</string>
                 <string>receive</string>
                 <string>receive_action</string>
-                <string>receive_automatic</string>
                 <string>start</string>
                 <string>start_action</string>
               </tuple>
-- 
2.30.9