From a28a7f0aa82d408663ea639d7faf1ea125afb92e Mon Sep 17 00:00:00 2001 From: Dan Wells Date: Wed, 1 Jul 2015 15:18:16 -0400 Subject: [PATCH] LP#1548147 Quick Export Feature for Vandelay Queues When we import records into Vandelay, sometimes some of the records are not what we expected, so they get rejected. These records often need to be loaded using a different set of options, so this link makes it convenient to get a new file of just the rejects. Signed-off-by: Dan Wells --- .../perlmods/lib/OpenILS/Application/Vandelay.pm | 62 ++++++++++++++++++++++ Open-ILS/src/templates/vandelay/inc/queue.tt2 | 1 + Open-ILS/web/js/ui/default/vandelay/vandelay.js | 32 ++++++++++- 3 files changed, 94 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Vandelay.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Vandelay.pm index a93a51e8dd..4dd3bed4eb 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Vandelay.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Vandelay.pm @@ -838,6 +838,68 @@ sub import_queue { return {complete => 1}; } +__PACKAGE__->register_method( + api_name => "open-ils.vandelay.bib_queue.export", + method => 'export_queue', + api_level => 1, + argc => 2, + stream => 1, + max_chunk_size => 0, + record_type => 'bib', + signature => { + desc => q/ + Attempts to export all non-imported records for the selected queue. + / + } +); + +__PACKAGE__->register_method( + api_name => "open-ils.vandelay.auth_queue.export", + method => 'export_queue', + api_level => 1, + argc => 2, + stream => 1, + max_chunk_size => 0, + record_type => 'auth', + signature => { + desc => q/ + Attempts to export all non-imported records for the selected queue. + / + } +); + +# TODO: Right now, this just simply exports unimported XML bibs. +# Eventually, more options (bibs for unimported items, all bibs +# in queue, selected records, different MARC formats) might make +# sense. +sub export_queue { + my($self, $conn, $auth, $q_id, $options) = @_; + my $e = new_editor(authtoken => $auth, xact => 1); + return $e->die_event unless $e->checkauth; + my $type = $self->{record_type}; + my $class = ($type eq 'bib') ? 'vqbr' : 'vqar'; + + # Collect the not-yet-imported records + my $query = {queue => $q_id, import_time => undef}; + my $search = ($type eq 'bib') ? + 'search_vandelay_queued_bib_record' : + 'search_vandelay_queued_authority_record'; + my $recs = $e->$search($query); + + my $xml = <<" HEADER"; + + + HEADER + + foreach my $rec (@$recs) { + $xml .= $rec->marc; + } + + $xml .= "\n"; + + return $xml; +} + # returns a list of queued record IDs for a given queue that # have at least one entry in the match table # XXX DEPRECATED? diff --git a/Open-ILS/src/templates/vandelay/inc/queue.tt2 b/Open-ILS/src/templates/vandelay/inc/queue.tt2 index cce9a7351b..56c39654ab 100644 --- a/Open-ILS/src/templates/vandelay/inc/queue.tt2 +++ b/Open-ILS/src/templates/vandelay/inc/queue.tt2 @@ -15,6 +15,7 @@ [% l('Import Selected Records') %] [% l('Import All Records') %] [% l('View Import Items') %] + [% l('Export Non-Imported Records') %]