[open-ils-commits] r11911 - trunk/Open-ILS/src/extras/import
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Jan 22 13:10:25 EST 2009
Author: phasefx
Date: 2009-01-22 13:10:22 -0500 (Thu, 22 Jan 2009)
New Revision: 11911
Modified:
trunk/Open-ILS/src/extras/import/marc_add_ids
Log:
-set_001_003 param to set 001 to record id and 003 to repository code (specified by -repository_code param, defaults to Evergreen). This is to support XC's OAIToolkit. Also show specific errors on failed records.
Modified: trunk/Open-ILS/src/extras/import/marc_add_ids
===================================================================
--- trunk/Open-ILS/src/extras/import/marc_add_ids 2009-01-22 17:19:03 UTC (rev 11910)
+++ trunk/Open-ILS/src/extras/import/marc_add_ids 2009-01-22 18:10:22 UTC (rev 11911)
@@ -16,9 +16,13 @@
binmode(STDOUT, ':utf8');
my ($delim, @fields) = (' \| ');
+my $set_001_003 = 0;
+my $repository_code = 'Evergreen';
GetOptions(
'delimiter=s' => \$delim,
'field=s' => \@fields,
+ 'set_001_003' => \$set_001_003,
+ 'repository_code=s' => \$repository_code,
);
my %partmap;
@@ -58,9 +62,26 @@
$r->delete_field($_) for ($r->field('901'));
$r->append_fields( $f );
+ if ($set_001_003) {
+ my $old_001 = $r->field('001');
+ if ($old_001) {
+ $old_001->update($partlist{id});
+ } else {
+ my $new_001 = new MARC::Field('001',$partlist{id});
+ $r->insert_fields_ordered($new_001);
+ }
+ my $old_003 = $r->field('003');
+ if ($old_003) {
+ $old_003->update($repository_code);
+ } else {
+ my $new_003 = new MARC::Field('003',$repository_code);
+ $r->insert_fields_ordered($new_003);
+ }
+ }
+
print $r->as_xml_record;
} otherwise {
- warn "failed on record $., $partlist{marc}\n";
+ warn "failed on record $., $partlist{marc}, for $@\n";
};
}
More information about the open-ils-commits
mailing list