From: gmc Date: Wed, 20 Apr 2011 14:50:13 +0000 (+0000) Subject: Teach marc_export how to export bibs for specified libraries X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=3cc4432ea3a3052365f0506f54044ff2298f3737;p=evergreen%2Fjoelewis.git Teach marc_export how to export bibs for specified libraries Useful shortcut for getting the bibs for libraries based on the non-deleted callnumbers they have attached to non-deleted bibs. Doesn't guarantee that they also have either a visible copy or localized URI attached but whaddya want, magic? :) Usage: marc_export --library BR1 --library BR2 Signed-off-by: Galen Charlton git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_2_1@20240 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/support-scripts/marc_export b/Open-ILS/src/support-scripts/marc_export index 8d0b68778f..ecd79a5892 100755 --- a/Open-ILS/src/support-scripts/marc_export +++ b/Open-ILS/src/support-scripts/marc_export @@ -36,6 +36,7 @@ my $export_mfhd = undef; my $type = 'biblio'; my $all_records = undef; my $replace_001 = undef; +my @library = (); GetOptions( 'help' => \$help, @@ -51,6 +52,7 @@ GetOptions( 'xml-idl=s' => \$idl, 'encoding=s' => \$encoding, 'timeout=i' => \$timeout, + 'library=s' => \@library, ); if ($help) { @@ -79,6 +81,9 @@ Usage: $0 [options] have a lot of items attached to them. --type or -t Record type (BIBLIO, AUTHORITY) [BIBLIO] --all or -a Export all records; ignores input list + --library Export the bibliographic records that have attached + holdings for the listed library or libraries as + identified by shortname --replace_001 Replace the 001 field value with the record ID Additional options for type = 'BIBLIO': @@ -99,10 +104,21 @@ To export a set of MARC21XML authority records in a file named "output.xml" for all authority records in the database: $0 --format XML --type AUTHORITY --all > output.xml +To export a set of USMARC bibliographic records encoded in UTF-8 in a file +named "sys1_bibs.mrc" based on records which have attached callnumbers for the +libraries with the short names "BR1" and "BR2": + + $0 --library BR1 --library BR2 --encoding UTF-8 > sys1_bibs.mrc + HELP exit; } +if ($all_records && @library) { + die('Incompatible arguments: you cannot combine a request for all ' . + 'records with a request for records by library'); +} + $type = lc($type); $format = uc($format); $encoding = uc($encoding); @@ -175,12 +191,39 @@ if ($all_records) { for (my $i = 0; $i++ < $top_record;) { export_record($i); } +} elsif (@library) { + my $recids = $editor->json_query({ + select => { bre => ['id'] }, + from => { bre => 'acn' }, + where => { + '+bre' => { deleted => 'f' }, + '+acn' => { + deleted => 'f', + owning_lib => { + in => { + select => {'aou' => ['id'] }, + from => 'aou', + where => { shortname => { in => \@library } } + } + } + } + }, + distinct => 1, + order_by => [{ + class => 'bre', + field => 'id', + direction => 'ASC' + }] + }); + + foreach my $record (@$recids) { + export_record($record->{id}); + }; } else { while ( my $i = <> ) { export_record($i); } } - print "\n" if ($format eq 'XML'); $speed = $count{did} / (time - $start);