Vandelay fix for merging without loading new
authorDan Wells <dbw2@calvin.edu>
Fri, 29 Jul 2011 22:09:19 +0000 (18:09 -0400)
committerMike Rylander <mrylander@gmail.com>
Wed, 3 Aug 2011 17:11:24 +0000 (13:11 -0400)
This fix is derivative of da3a453442050482a419deff91d3dc92fdbf132a
in master, but with new feature code removed for backport to 2.1
and 2.0.  It does the following:

- renames 'vlUploadQueueAutoImport' to 'vlUploadQueueImportNoMatch' to
  match identical change in master and to increase code clarity
- honors this flag when doing a merge.

Previously, if you checked one of the two auto-merge boxes, any records
which did not merge loaded as new records even if the 'Auto-Import
Non-Colliding Records' box was not checked.  You can now do one, the
other, or both together (auto-importing and merging) as needed.

Signed-off-by: Dan Wells <dbw2@calvin.edu>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Vandelay.pm
Open-ILS/web/js/ui/default/vandelay/vandelay.js
Open-ILS/web/templates/default/vandelay/inc/queue.tt2
Open-ILS/web/templates/default/vandelay/inc/upload.tt2

index 5c48282..d177022 100644 (file)
@@ -622,6 +622,7 @@ sub import_record_list_impl {
     my $merge_profile = $$args{merge_profile};
     my $bib_source = $$args{bib_source};
     my $report_all = $$args{report_all};
+    my $import_no_match = $$args{import_no_match};
 
     my $overlay_func = 'vandelay.overlay_bib_record';
     my $auto_overlay_func = 'vandelay.auto_overlay_bib_record';
@@ -771,7 +772,7 @@ sub import_record_list_impl {
                 }
             }
 
-            if(!$imported and !$error) {
+            if(!$imported and !$error and $import_no_match and scalar(@{$rec->matches}) == 0) { # match count test should not be necessary, but is a good fail-safe
             
                 # No overlay / merge occurred.  Do a traditional record import by creating a new record
             
index a54005f..1ae7400 100644 (file)
@@ -821,7 +821,7 @@ function vlHandleQueueItemsAction(action) {
             queueItemsImportDialog.hide();
 
             // hack to set the widgets the import funcs will be looking at.  Reset them below.
-            vlUploadQueueAutoImport.attr('value',  vlUploadQueueAutoImport2.attr('value'));
+            vlUploadQueueImportNoMatch.attr('value',  vlUploadQueueImportNoMatch2.attr('value'));
             vlUploadQueueAutoOverlayExact.attr('value',  vlUploadQueueAutoOverlayExact2.attr('value'));
             vlUploadQueueAutoOverlay1Match.attr('value',  vlUploadQueueAutoOverlay1Match2.attr('value'));
             vlUploadMergeProfile.attr('value',  vlUploadMergeProfile2.attr('value'));
@@ -833,8 +833,8 @@ function vlHandleQueueItemsAction(action) {
             }
             
             // reset the widgets to prevent accidental future actions
-            vlUploadQueueAutoImport.attr('value',  false);
-            vlUploadQueueAutoImport2.attr('value', false);
+            vlUploadQueueImportNoMatch.attr('value',  false);
+            vlUploadQueueImportNoMatch2.attr('value', false);
             vlUploadQueueAutoOverlayExact.attr('value', false);
             vlUploadQueueAutoOverlayExact2.attr('value', false);
             vlUploadQueueAutoOverlay1Match.attr('value', false);
@@ -901,23 +901,38 @@ function vlImportAllRecords() {
         function(){displayGlobalDiv('vl-queue-div');});
 }
 
-function vlImportRecordQueue(type, queueId, noMatchOnly, onload) {
+function vlImportRecordQueue(type, queueId, onload) {
     displayGlobalDiv('vl-generic-progress-with-total');
     var method = 'open-ils.vandelay.bib_queue.import';
-    if(noMatchOnly)
-        method = method.replace('import', 'nomatch.import');
     if(type == 'auth')
         method = method.replace('bib', 'auth');
 
+
+    var mergeOpt = false;
     var options = {};
+
+    if(vlUploadQueueImportNoMatch.checked) {
+        options.import_no_match = true;
+        vlUploadQueueImportNoMatch.checked = false;
+    }
+
     if(vlUploadQueueAutoOverlayExact.checked) {
         options.auto_overlay_exact = true;
         vlUploadQueueAutoOverlayExact.checked = false;
+        mergeOpt = true;
     }
 
     if(vlUploadQueueAutoOverlay1Match.checked) {
         options.auto_overlay_1match = true;
         vlUploadQueueAutoOverlay1Match.checked = false;
+        mergeOpt = true;
+    }
+
+    if(!mergeOpt) {
+        // in the interest of speed, if no merge options are 
+        // chosen, tell the back-end code to only process records
+        // that have no matches
+        method = method.replace('\.import', '.nomatch.import');
     }
     
     var profile = vlUploadMergeProfile.attr('value');
@@ -949,16 +964,18 @@ function batchUpload() {
     currentType = dijit.byId('vl-record-type').getValue();
 
     var handleProcessSpool = function() {
-        if(vlUploadQueueAutoImport.checked || vlUploadQueueAutoOverlayExact.checked || vlUploadQueueAutoOverlay1Match.checked) {
-            var noMatchOnly = !vlUploadQueueAutoOverlayExact.checked && !vlUploadQueueAutoOverlay1Match.checked;
-            vlImportRecordQueue(
-                currentType, 
-                currentQueueId, 
-                noMatchOnly,
-                function() {
-                    retrieveQueuedRecords(currentType, currentQueueId, handleRetrieveRecords);
-                }
-            );
+        if( 
+            vlUploadQueueImportNoMatch.checked || 
+            vlUploadQueueAutoOverlayExact.checked || 
+            vlUploadQueueAutoOverlay1Match.checked) {
+
+                vlImportRecordQueue(
+                    currentType, 
+                    currentQueueId, 
+                    function() {
+                        retrieveQueuedRecords(currentType, currentQueueId, handleRetrieveRecords);
+                    }
+                );
         } else {
             retrieveQueuedRecords(currentType, currentQueueId, handleRetrieveRecords);
         }
index e7d6eaf..6d231f2 100644 (file)
@@ -21,7 +21,7 @@
                 <tr>
                     <td>&vandelay.auto.import.noncolliding;</td>
                     <td colspan='4'>
-                        <input jsId='vlUploadQueueAutoImport2' dojoType='dijit.form.CheckBox'/>
+                        <input jsId='vlUploadQueueImportNoMatch2' dojoType='dijit.form.CheckBox'/>
                     </td>
                 </tr>
                 <tr>
index aca6320..43e7483 100644 (file)
@@ -26,7 +26,7 @@
         <tr>
             <td>&vandelay.auto.import.noncolliding;</td>
             <td colspan='4'>
-                <input jsId='vlUploadQueueAutoImport' dojoType='dijit.form.CheckBox'/>
+                <input jsId='vlUploadQueueImportNoMatch' dojoType='dijit.form.CheckBox'/>
             </td>
         </tr>
         <tr>