[open-ils-commits] r20239 - branches/rel_2_1/Open-ILS/src/support-scripts (gmc)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Apr 20 10:50:13 EDT 2011


Author: gmc
Date: 2011-04-20 10:50:11 -0400 (Wed, 20 Apr 2011)
New Revision: 20239

Modified:
   branches/rel_2_1/Open-ILS/src/support-scripts/marc_export
Log:
Teac marc_export how to replace the 001 field value with the record ID

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.

Signed-off-by: Galen Charlton <gmc at esilibrary.com>

Modified: branches/rel_2_1/Open-ILS/src/support-scripts/marc_export
===================================================================
--- branches/rel_2_1/Open-ILS/src/support-scripts/marc_export	2011-04-20 14:49:12 UTC (rev 20238)
+++ branches/rel_2_1/Open-ILS/src/support-scripts/marc_export	2011-04-20 14:50:11 UTC (rev 20239)
@@ -23,13 +23,26 @@
 
 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 @@
                     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 @@
 DONE
 
 sub export_record {
-    my $id = shift;
+    my $id = int(shift);
 
     my $bib; 
 
@@ -219,6 +233,11 @@
             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;



More information about the open-ils-commits mailing list