From: miker Date: Mon, 11 Oct 2010 16:07:47 +0000 (+0000) Subject: Working template-based batch bib updater! X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=9ff46a260b099db50d3e64e83c8145e0aca80ea0;p=contrib%2FConifer.git Working template-based batch bib updater! git-svn-id: svn://svn.open-ils.org/ILS/trunk@18264 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm b/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm index f1b23032e8..df16b4e0ed 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm @@ -248,25 +248,23 @@ sub template_overlay_container { my $items = $e->search_container_biblio_record_entry_bucket_item({ bucket => $container }); + my $titem; if (!$template) { - my $titem = $e->retrieve_biblio_record_entry( - map { $_->target_biblio_record_entry } - grep { $_->target_biblio_record_entry < 0 } @$items - ); - + ($titem) = grep { $_->target_biblio_record_entry < 0 } @$items; if (!$titem) { $e->rollback; return undef; } + $items = [grep { $_->target_biblio_record_entry > 0 } @$items]; - $template = $titem->marc; - return $e->die_event unless ($e->delete_container_biblio_record_entry_bucket_item($titem)); + $template = $e->retrieve_biblio_record_entry( $titem->target_biblio_record_entry )->marc; } my $responses = []; + my $some_failed = 0; $self->respond_complete( - $actor->request('open-ils.actor.anon_cache.set_value', $responses)->gather(1) + $actor->request('open-ils.actor.anon_cache.set_value', $auth, res_list => $responses)->gather(1) ) if ($actor); for my $item ( @$items ) { @@ -280,36 +278,44 @@ sub template_overlay_container { )->[0]->{'vandelay.template_overlay_bib_record'}; } + $some_failed++ if ($success eq 'f'); + if ($actor) { push @$responses, { record => $rec->id, success => $success }; - $actor->request('open-ils.actor.anon_cache.set_value', $responses); + $actor->request('open-ils.actor.anon_cache.set_value', $auth, res_list => $responses); } else { $conn->respond({ record => $rec->id, success => $success }); } - unless ($e->delete_container_biblio_record_entry_bucket_item($item)) { - $e->rollback; - if ($actor) { - push @$responses, { complete => 1, success => 'f' }; - $actor->request('open-ils.actor.anon_cache.set_value', $responses); - return undef; - } else { - return { complete => 1, success => 'f' }; + if ($success eq 't') { + unless ($e->delete_container_biblio_record_entry_bucket_item($item)) { + $e->rollback; + if ($actor) { + push @$responses, { complete => 1, success => 'f' }; + $actor->request('open-ils.actor.anon_cache.set_value', $auth, res_list => $responses); + return undef; + } else { + return { complete => 1, success => 'f' }; + } } } } + if ($titem && !$some_failed) { + return $e->die_event unless ($e->delete_container_biblio_record_entry_bucket_item($titem)); + } + if ($e->commit) { if ($actor) { push @$responses, { complete => 1, success => 't' }; - $actor->request('open-ils.actor.anon_cache.set_value', $responses); + $actor->request('open-ils.actor.anon_cache.set_value', $auth, res_list => $responses); } else { return { complete => 1, success => 't' }; } } else { if ($actor) { push @$responses, { complete => 1, success => 'f' }; - $actor->request('open-ils.actor.anon_cache.set_value', $responses); + $actor->request('open-ils.actor.anon_cache.set_value', $auth, res_list => $responses); } else { return { complete => 1, success => 'f' }; } diff --git a/Open-ILS/src/perlmods/OpenILS/WWW/TemplateBatchBibUpdate.pm b/Open-ILS/src/perlmods/OpenILS/WWW/TemplateBatchBibUpdate.pm index 5e88fea14d..b51d69ab32 100644 --- a/Open-ILS/src/perlmods/OpenILS/WWW/TemplateBatchBibUpdate.pm +++ b/Open-ILS/src/perlmods/OpenILS/WWW/TemplateBatchBibUpdate.pm @@ -138,7 +138,10 @@ sub handler { # create the new container for the records and the template my $bucket = Fieldmapper::container::biblio_record_entry_bucket->new; $bucket->owner($usr->id); - $bucket->name('Temporary Merge Bucket'); + $bucket->btype('template_merge'); + + my $bname = $cgi->param('bname') || 'Temporary Merge Bucket '. localtime() . ' ' . $usr->id; + $bucket->name($bname); $bucket = $e->request('open-ils.cstore.direct.container.biblio_record_entry_bucket.create', $bucket )->gather(1); @@ -159,8 +162,8 @@ sub handler { # fire the background bucket processor my $cache_key = OpenSRF::AppSession - ->create('open-ils.actor') - ->request('open-ils.cat.container.template_overlay.background', $bucket->id) + ->create('open-ils.cat') + ->request('open-ils.cat.container.template_overlay.background', $authid, $bucket->id) ->gather(1); return show_processing_template($r, $bucket->id, \@records, $cache_key); @@ -221,29 +224,29 @@ sub show_processing_template { dojo.require('fieldmapper.dojoData'); dojo.require('openils.User'); dojo.require('openils.CGI'); - dojo.require('openils.widget.PogressDialog'); + dojo.require('openils.widget.ProgressDialog'); var cgi = new openils.CGI(); var u = new openils.User({ authcookie : 'ses' }); - var rec_count = $rec_string; - var cache_key = '$cache_key'; - dojo.addOnLoad(function () { progress_dialog.show(true); - progress_dialog.update({maximum:rec_ids.length}); + progress_dialog.update({maximum:$rec_string}); - setInterval( function() { + var interval; + interval = setInterval( function() { fieldmapper.standardRequest( ['open-ils.actor','open-ils.actor.anon_cache.get_value'], { async : false, - params: [ cache_key ], + params: [ u.authtoken, 'res_list' ], + onerror : function (r) { progress_dialog.hide(); }, onresponse : function (r) { var counter = { success : 0, fail : 0, total : 0 }; dojo.forEach( openils.Util.readResponse(r), function(x) { if (x.complete) { + clearInterval(interval); progress_dialog.hide(); - if (x.success == 'f') dojo.byId('complete_msg').innerHTML = 'Overlay completed successfully'; + if (x.success == 't') dojo.byId('complete_msg').innerHTML = 'Overlay completed successfully'; else dojo.byId('complete_msg').innerHTML = 'Overlay did not complet successfully'; } else { counter.total++; @@ -487,34 +490,49 @@ sub show_template {
-
- -
- -
-
- -
or
- -
- - -
- -
or
- - - -
-
+ + + + + + + + + + + + + + + + + + + +
Optional merge queue name:
Batch update records in Bucket: +
+ +
+
or
Batch update records from CSV file:
Column starting from 0
or
Test Ruleset by applying to one record:
@@ -541,10 +559,9 @@ sub show_template { Rule Type diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index 9dc925131f..dee49b8a2e 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -2345,6 +2345,7 @@ INSERT INTO container.biblio_record_entry_bucket_type (code,label) VALUES ('misc INSERT INTO container.biblio_record_entry_bucket_type (code,label) VALUES ('staff_client', oils_i18n_gettext('staff_client', 'General Staff Client container', 'cbrebt', 'label')); INSERT INTO container.biblio_record_entry_bucket_type (code,label) VALUES ('bookbag', oils_i18n_gettext('bookbag', 'Book Bag', 'cbrebt', 'label')); INSERT INTO container.biblio_record_entry_bucket_type (code,label) VALUES ('reading_list', oils_i18n_gettext('reading_list', 'Reading List', 'cbrebt', 'label')); +INSERT INTO container.biblio_record_entry_bucket_type (code,label) VALUES ('template_merge',oils_i18n_gettext('template_merge','Template Merge Container', 'cbrebt', 'label')); INSERT INTO container.user_bucket_type (code,label) VALUES ('misc', oils_i18n_gettext('misc', 'Miscellaneous', 'cubt', 'label')); INSERT INTO container.user_bucket_type (code,label) VALUES ('folks', oils_i18n_gettext('folks', 'Friends', 'cubt', 'label')); diff --git a/Open-ILS/src/sql/Pg/upgrade/0434.data.merge_template_container_type.sql b/Open-ILS/src/sql/Pg/upgrade/0434.data.merge_template_container_type.sql new file mode 100644 index 0000000000..1a0fd0f5e7 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0434.data.merge_template_container_type.sql @@ -0,0 +1,9 @@ + +BEGIN; + +INSERT INTO config.upgrade_log (version) VALUES ('0434'); + +INSERT INTO container.biblio_record_entry_bucket_type (code,label) VALUES ('template_merge','Template Merge Container'); + +COMMIT; +