Teac marc_export how to replace the 001 field value with the record ID
authordbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 4 Mar 2011 18:03:12 +0000 (18:03 +0000)
committerdbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 4 Mar 2011 18:03:12 +0000 (18:03 +0000)
This is option is probably more useful prior to 2.0 where we introduced
the automated "munge control numbers" option, but new features go
here, right? A site that wants to export their bibliographic records
to send to a large library consortium for control number matching
may find this a useful way to send out records with a local 001 record
ID and get standard identifier control numbers back that they can
add as a 035, per MARC standards.

git-svn-id: svn://svn.open-ils.org/ILS/trunk@19582 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/support-scripts/marc_export

index 6360b1c..8d0b687 100755 (executable)
@@ -23,13 +23,26 @@ use Getopt::Long;
 
 my @formats = qw/USMARC UNIMARC XML BRE ARE/;
 
-my ($config,$format,$encoding,$location,$dollarsign,$idl,$help,$holdings,$timeout,$export_mfhd,$type,$all_records) = ('/openils/conf/opensrf_core.xml','USMARC','MARC8','','$',0,undef,undef,0,undef,'biblio',undef);
+my $config = '/openils/conf/opensrf_core.xml';
+my $format = 'USMARC';
+my $encoding = 'MARC8';
+my $location = '';
+my $dollarsign = '$';
+my $idl = 0;
+my $help = undef;
+my $holdings = undef;
+my $timeout = 0;
+my $export_mfhd = undef;
+my $type = 'biblio';
+my $all_records = undef;
+my $replace_001 = undef;
 
 GetOptions(
         'help'       => \$help,
         'items'      => \$holdings,
         'mfhd'       => \$export_mfhd,
         'all'        => \$all_records,
+        'replace_001'=> \$replace_001,
         'location=s' => \$location,
         'money=s'    => \$dollarsign,
         'config=s'   => \$config,
@@ -66,6 +79,7 @@ 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
+ --replace_001      Replace the 001 field value with the record ID
 
  Additional options for type = 'BIBLIO':
  --items or -i      Include items (holdings) in the output
@@ -181,7 +195,7 @@ Total Time Elapsed: $time seconds
 DONE
 
 sub export_record {
-    my $id = shift;
+    my $id = int(shift);
 
     my $bib; 
 
@@ -219,6 +233,11 @@ sub export_record {
             add_bib_holdings($bib, $r);
         }
 
+        if ($replace_001) {
+            my $tcn = $r->field('001');
+            $tcn->update($id);
+        }
+
         if ($format eq 'XML') {
             my $xml = $r->as_xml_record;
             $xml =~ s/^<\?.+?\?>$//mo;