[open-ils-commits] [GIT] Evergreen ILS branch master updated. e50d4cef406bee50dbb5ea780a0f06807736e38f

Evergreen Git git at git.evergreen-ils.org
Tue Oct 16 09:39:30 EDT 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  e50d4cef406bee50dbb5ea780a0f06807736e38f (commit)
      from  a54edeb8a1546f7c1f36cd05c583fcff5220ad01 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit e50d4cef406bee50dbb5ea780a0f06807736e38f
Author: Bill Erickson <berick at esilibrary.com>
Date:   Thu Aug 23 17:29:42 2012 -0400

    Improvements to custom org tree UI
    
    This replaced the PermaCrud.js create() calls with inline transaction
    begin, creates, and commit.  We do this to solve a number of problems:
    
    * Create all new nodes within the same transaction so that a failure
    gracefully rolls back.
    
    * PermaCrud.js does not currently disconnect opensrf client sessions
    (though it has a disconnect() method).  We can manage that locally.
    
    Signed-off-by: Bill Erickson <berick at esilibrary.com>
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/Open-ILS/web/js/ui/default/conify/global/actor/org_unit_custom_tree.js b/Open-ILS/web/js/ui/default/conify/global/actor/org_unit_custom_tree.js
index 88d35dc..b4fd42a 100644
--- a/Open-ILS/web/js/ui/default/conify/global/actor/org_unit_custom_tree.js
+++ b/Open-ILS/web/js/ui/default/conify/global/actor/org_unit_custom_tree.js
@@ -162,12 +162,19 @@ function applyChanges() {
 }
 
 function applyChanges2() {
+
+    // pcrud.disconnect() exits before disconnecting the session.
+    // Clean up the session here.  TODO: fix pcrud
+    pcrud.session.disconnect();
+    pcrud.session.cleanup();
+
     ctNodes = [];
     var newCtNodes = [];
     var nodeList = [];
     var sorder = 0;
     var prevTn;
     var progress = 0;
+    var session = new OpenSRF.ClientSession('open-ils.pcrud');
 
     // flatten child nodes into a level-order (by parent) list
     var nodeList = [magicTree.rootNode];
@@ -178,6 +185,19 @@ function applyChanges2() {
     }
     flatten(magicTree.rootNode);
 
+    // called after all nodes are processed
+    function finishUp() {
+        // commit the transaction
+        session.request({
+            method : 'open-ils.pcrud.transaction.commit',
+            params : [ openils.User.authtoken ],
+            oncomplete : function (r) {
+                session.disconnect();
+                location.href = location.href;
+            }
+        }).send();
+    }
+
     // traverse the nodes, creating new aoucnt's as we go
     function traverseAndCreate(node) {
         var item = node.item;
@@ -199,25 +219,36 @@ function applyChanges2() {
             tn.sibling_order(++sorder);
         } else { sorder = 0; }
 
-        console.log("Creating new node for org unit " + tn.org_unit());
-
-        // create the new node, then process the children
-        pcrud.create(tn, {
-            oncomplete : function(r, objs) {
-                var newTn = objs[0];
+        // create the new node, then process the children (async)
+        session.request({
+            method : 'open-ils.pcrud.create.aouctn',
+            params : [ openils.User.authtoken, tn ],
+            oncomplete : function (r) {
+                var newTn = openils.Util.readResponse(r);
+                console.log("Created new node for org " + newTn.org_unit() + " => " + newTn.id());
                 ctNodes.push(newTn);
                 prevTn = newTn;
                 if (nodeList.length == 0) {
-                    progressDialog.hide();
-                    location.href = location.href;
+                    finishUp();
                 } else {
                     progressDialog.update({maximum : nodeList.length, progress : ++progress});
                     traverseAndCreate(nodeList.shift());
                 }
             }
-        });
+        }).send();
     }
-    traverseAndCreate(nodeList.shift());
+
+    // kick things off...
+    session.connect();
+
+    // start the transaction
+    session.request({
+        method : 'open-ils.pcrud.transaction.begin',
+        params : [ openils.User.authtoken ],
+        oncomplete : function (r) {
+            traverseAndCreate(nodeList.shift());
+        }
+    }).send();
 }
 
 function deleteSelected() {

-----------------------------------------------------------------------

Summary of changes:
 .../conify/global/actor/org_unit_custom_tree.js    |   51 ++++++++++++++++----
 1 files changed, 41 insertions(+), 10 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list