[Koha-patches] [PATCH] ISBN13 support
Galen Charlton
galen.charlton at liblime.com
Fri Jul 31 21:53:58 CEST 2009
Allows for search by equivalent ISBN-10 and ISBN-13
numbers.
* rebuild_zebra.pl now inserts 999$e subfields into
bib records containing the ISBN-10 and ISBN-13
forms off all ISBNs in the original MARC record.
* added 999$e to ISBN index
* Adds dependency on Business::ISBN
This work was sponsored by the Plano Independent School
District.
---
Makefile.PL | 1 +
about.pl | 1 +
etc/zebradb/marc_defs/marc21/biblios/record.abs | 7 +++--
misc/migration_tools/rebuild_zebra.pl | 32 +++++++++++++++++++++++
4 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/Makefile.PL b/Makefile.PL
index 3150394..db791d8 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -534,6 +534,7 @@ WriteMakefile(
PREREQ_PM => {
'Algorithm::CheckDigits' => 0.50,
'Biblio::EndnoteStyle' => 0.05,
+ 'Business::ISBN' => 2.05,
'CGI' => 3.15,
'CGI::Carp' => 1.29,
'CGI::Session' => 4.20,
diff --git a/about.pl b/about.pl
index 56d1717..df8d4c4 100755
--- a/about.pl
+++ b/about.pl
@@ -64,6 +64,7 @@ my @component_names =
qw/
Algorithm::CheckDigits
Biblio::EndnoteStyle
+Business::ISBN
CGI
CGI::Carp
CGI::Session
diff --git a/etc/zebradb/marc_defs/marc21/biblios/record.abs b/etc/zebradb/marc_defs/marc21/biblios/record.abs
index 47be88f..047f13b 100644
--- a/etc/zebradb/marc_defs/marc21/biblios/record.abs
+++ b/etc/zebradb/marc_defs/marc21/biblios/record.abs
@@ -52,9 +52,10 @@ melm 015 BNB-card-number,BGF-number,Number-db,Number-natl-biblio,Identifi
melm 017 Number-legal-deposit,Identifier-standard
melm 018 Identifier-standard
melm 020$a ISBN:w,Identifier-standard:w
-melm 020 Identifier-standard
-melm 022$a ISSN:w,Identifier-standard:w
-melm 022 Identifier-standard
+melm 999$e ISBN:w,Identifier-standard:w
+melm 020 ISBN,Identifier-standard
+melm 022$a ISSN:w,ISBN:w
+melm 022 ISSN,Identifier-standard
melm 023 Identifier-standard
melm 024$a Identifier-other
melm 024 Identifier-standard
diff --git a/misc/migration_tools/rebuild_zebra.pl b/misc/migration_tools/rebuild_zebra.pl
index 0f4b4a0..9751bf3 100755
--- a/misc/migration_tools/rebuild_zebra.pl
+++ b/misc/migration_tools/rebuild_zebra.pl
@@ -8,6 +8,7 @@ use File::Temp qw/ tempdir /;
use File::Path;
use C4::Biblio;
use C4::AuthoritiesMarc;
+use Business::ISBN;
#
# script that checks zebradir structure & create directories & mandatory files if needed
@@ -380,6 +381,7 @@ sub get_corrected_marc_record {
if ($record_type eq 'biblio') {
my $succeeded = fix_biblio_ids($marc, $record_number);
return unless $succeeded;
+ add_isbn13s($marc);
} else {
fix_authority_id($marc, $record_number);
}
@@ -477,6 +479,36 @@ sub fix_biblio_ids {
return 1;
}
+sub add_isbn13s {
+ my $marc = shift;
+
+ my ($isbntag, $isbnsubfield) = GetMarcFromKohaField('biblioitems.isbn', '');
+ return unless $isbntag and $isbnsubfield;
+ my %isbns =();
+ foreach my $field ($marc->field($isbntag)) {
+ my $sfa = $field->subfield('a');
+ next unless $sfa;
+ my ($isbn_str) = $sfa =~ /^([0-9-]+[0-9xX])/;
+ next unless defined $isbn_str;
+ $isbn_str =~ s/-//;
+ $isbns{$isbn_str}++;
+ my $isbn = Business::ISBN->new($isbn_str);
+ next unless $isbn->is_valid();
+ next unless $isbn->is_valid();
+ my $isbn13_str = $isbn->as_isbn13()->as_string([]);
+ $isbns{$isbn13_str}++;
+ my $isbn10 = $isbn->as_isbn10();
+ next unless defined $isbn10;
+ $isbns{$isbn10->as_string([])}++;
+ }
+ return unless %isbns;
+ if (my $f999 = $marc->field('999')) {
+ $f999->add_subfields(map { ('e' => $_) } keys %isbns);
+ } else {
+ $marc->append_field(MARC::Field->new('999', ' ', ' ', map { ('e' => $_) } keys %isbns));
+ }
+}
+
sub fix_authority_id {
# FIXME - as with fix_biblio_ids, the authid must be present
# for Zebra's sake. However, this really belongs
--
1.5.6.5
More information about the Koha-patches
mailing list