From d8753e29df35b6311e520ae0d22ce398783dd436 Mon Sep 17 00:00:00 2001 From: tipaul Date: Tue, 10 Sep 2002 14:02:42 +0000 Subject: [PATCH] * fill_usmarc.pl => fills db with MARC21/english data structure. The modifs now maps koha item fields to 995 MARC tag. * updatedb2marc.pl => builds MARC data from old-DB. WARNING : this script translate around 30rows/seconds, which is neither good nor bad (if you consider that 1 biblio+1 item = more than 50 record in the MARC-DB). But if you plan to migrate a 30 000 books db, launch script and go for lunch ;-) --- marc/fill_usmarc.pl | 43 +++++++++++++++++++----------- marc/updatedb2marc.pl | 62 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 16 deletions(-) create mode 100755 marc/updatedb2marc.pl diff --git a/marc/fill_usmarc.pl b/marc/fill_usmarc.pl index 602597ad96..ffe9a1a60e 100755 --- a/marc/fill_usmarc.pl +++ b/marc/fill_usmarc.pl @@ -80,29 +80,29 @@ $dbh->do("update marc_subfield_structure set kohafield='biblioitems.size' where $dbh->do("update marc_subfield_structure set kohafield='biblioitems.notes' where tagfield='500' and tagsubfield='a'"); $dbh->do("update marc_subfield_structure set kohafield='biblioitems.lccn' where tagfield='010' and tagsubfield='a'"); # items -$dbh->do("update marc_subfield_structure set kohafield='items.itemnumber' where tagfield='890' and tagsubfield='c'"); +$dbh->do("update marc_subfield_structure set kohafield='items.itemnumber' where tagfield='995' and tagsubfield='s'"); #$dbh->do("update marc_subfield_structure set kohafield='items.multivolumepart' where tagfield='XXX' and tagsubfield='a'"); -$dbh->do("update marc_subfield_structure set kohafield='items.barcode' where tagfield='852' and tagsubfield='p'"); -$dbh->do("update marc_subfield_structure set kohafield='items.dateaccessioned' where tagfield='876' and tagsubfield='d'"); -$dbh->do("update marc_subfield_structure set kohafield='items.booksellerid' where tagfield='876' and tagsubfield='e'"); -$dbh->do("update marc_subfield_structure set kohafield='items.homebranch' where tagfield='876' and tagsubfield='b'"); -$dbh->do("update marc_subfield_structure set kohafield='items.replacementprice' where tagfield='876' and tagsubfield='c'"); +$dbh->do("update marc_subfield_structure set kohafield='items.barcode' where tagfield='995' and tagsubfield='f'"); +$dbh->do("update marc_subfield_structure set kohafield='items.dateaccessioned' where tagfield='995' and tagsubfield='m'"); +#$dbh->do("update marc_subfield_structure set kohafield='items.booksellerid' where tagfield='876' and tagsubfield='e'"); +$dbh->do("update marc_subfield_structure set kohafield='items.homebranch' where tagfield='995' and tagsubfield='d'"); +#$dbh->do("update marc_subfield_structure set kohafield='items.replacementprice' where tagfield='876' and tagsubfield='c'"); #$dbh->do("update marc_subfield_structure set kohafield='items.price' where tagfield='XXX' and tagsubfield='a'"); #$dbh->do("update marc_subfield_structure set kohafield='items.replacementpricedate' where tagfield='XXX' and tagsubfield='a'"); #$dbh->do("update marc_subfield_structure set kohafield='items.datelastborrowed' where tagfield='XXX' and tagsubfield='a'"); #$dbh->do("update marc_subfield_structure set kohafield='items.datelastseen' where tagfield='XXX' and tagsubfield='a'"); #$dbh->do("update marc_subfield_structure set kohafield='items.multivolume' where tagfield='XXX' and tagsubfield='a'"); #$dbh->do("update marc_subfield_structure set kohafield='items.stack' where tagfield='XXX' and tagsubfield='a'"); -$dbh->do("update marc_subfield_structure set kohafield='items.notforloan' where tagfield='876' and tagsubfield='h'"); -$dbh->do("update marc_subfield_structure set kohafield='items.itemlost' where tagfield='876' and tagsubfield='j'"); -$dbh->do("update marc_subfield_structure set kohafield='items.wthdrawn' where tagfield='876' and tagsubfield='k'"); +$dbh->do("update marc_subfield_structure set kohafield='items.notforloan' where tagfield='995' and tagsubfield='o'"); +#$dbh->do("update marc_subfield_structure set kohafield='items.itemlost' where tagfield='876' and tagsubfield='j'"); +#$dbh->do("update marc_subfield_structure set kohafield='items.wthdrawn' where tagfield='876' and tagsubfield='k'"); #$dbh->do("update marc_subfield_structure set kohafield='items.bulk' where tagfield='XXX' and tagsubfield='a'"); #$dbh->do("update marc_subfield_structure set kohafield='items.issues' where tagfield='XXX' and tagsubfield='a'"); #$dbh->do("update marc_subfield_structure set kohafield='items.renewals' where tagfield='XXX' and tagsubfield='a'"); #$dbh->do("update marc_subfield_structure set kohafield='items.reserves' where tagfield='XXX' and tagsubfield='a'"); #$dbh->do("update marc_subfield_structure set kohafield='items.restricted' where tagfield='XXX' and tagsubfield='a'"); #$dbh->do("update marc_subfield_structure set kohafield='items.binding' where tagfield='XXX' and tagsubfield='a'"); -$dbh->do("update marc_subfield_structure set kohafield='items.itemnotes' where tagfield='876' and tagsubfield='z'"); +$dbh->do("update marc_subfield_structure set kohafield='items.itemnotes' where tagfield='995' and tagsubfield='u'"); #$dbh->do("update marc_subfield_structure set kohafield='items.holdingbranch' where tagfield='XXX' and tagsubfield='a'"); #$dbh->do("update marc_subfield_structure set kohafield='items.interim' where tagfield='XXX' and tagsubfield='a'"); # additional authors @@ -9928,12 +9928,23 @@ sub marcdefs { $fields->{'886'}->{'subfields'}->{"b"}->{'repeating'}=0; $fields->{'886'}->{'subfields'}->{"2"}->{'name'}="Source of data (NR) $a-z - Foreign MARC subfield (R) $0-9 - Foreign MARC subfield (R)"; $fields->{'886'}->{'subfields'}->{"2"}->{'repeating'}=0; - $fields->{'890'}->{'name'}="KOHA item number"; - $fields->{'890'}->{'repeating'}=1; - $fields->{'890'}->{'firstindicator'}="Undefined"; - $fields->{'890'}->{'secondindicator'}="Undefined"; - $fields->{'890'}->{'subfields'}->{"c"}->{'name'}="Koha biblio number"; - $fields->{'890'}->{'subfields'}->{"c"}->{'repeating'}=1; + + $fields->{'995'}->{'name'}=""; + $fields->{'995'}->{'repeating'}=1; + $fields->{'995'}->{'firstindicator'}="Undefined"; + $fields->{'995'}->{'secondindicator'}="Undefined"; + $fields->{'995'}->{'subfields'}->{"s"}->{'name'}="Koha item number"; + $fields->{'995'}->{'subfields'}->{"s"}->{'repeating'}=1; + $fields->{'995'}->{'subfields'}->{"f"}->{'name'}="barcode"; + $fields->{'995'}->{'subfields'}->{"f"}->{'repeating'}=1; + $fields->{'995'}->{'subfields'}->{"m"}->{'name'}="dateaccessioned"; + $fields->{'995'}->{'subfields'}->{"m"}->{'repeating'}=1; + $fields->{'995'}->{'subfields'}->{"d"}->{'name'}="homebranch"; + $fields->{'995'}->{'subfields'}->{"d"}->{'repeating'}=1; + $fields->{'995'}->{'subfields'}->{"o"}->{'name'}="notforloan"; + $fields->{'995'}->{'subfields'}->{"o"}->{'repeating'}=1; + $fields->{'995'}->{'subfields'}->{"u"}->{'name'}="item notes"; + $fields->{'995'}->{'subfields'}->{"u"}->{'repeating'}=1; ; diff --git a/marc/updatedb2marc.pl b/marc/updatedb2marc.pl new file mode 100755 index 0000000000..1b83dd42ca --- /dev/null +++ b/marc/updatedb2marc.pl @@ -0,0 +1,62 @@ +#!/usr/bin/perl +# migrate koha-biblios to MARCbiblios + +package C4::test; + +# Copyright 2000-2002 Katipo Communications +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, +# Suite 330, Boston, MA 02111-1307 USA + +use strict; +require Exporter; +use C4::Database; +use C4::Catalogue; +use C4::Biblio; +use MARC::Record; +use MARC::File::USMARC; + +#die; +my $dbh=&C4Connect; +$dbh->do("delete from marc_biblio"); +$dbh->do("delete from marc_blob_subfield"); +$dbh->do("delete from marc_subfield_table"); +$dbh->do("delete from marc_word"); +my $sth=$dbh->prepare("select * from biblio left join biblioitems on biblioitems.biblionumber=biblio.biblionumber order by biblio.biblionumber"); +my ($row,$row2); +my $sth2 = $dbh->prepare("select count(*) from biblio"); +$sth2->execute; +my ($total) = $sth2->fetchrow_array; +my $rest = $total; +$sth->execute; +my $i=0; +while ($row=$sth->fetchrow_hashref) { + $i++; + $rest--; + if ($i>99) { + $i=0; + print "$rest / $total\n"; + } + my $MARCbiblio = MARCkoha2marcBiblio($dbh,$row->{biblionumber},$row->{biblioitemnumber}); + &MARCaddbiblio($dbh,$MARCbiblio,$row->{biblionumber}); + my $sth_item = $dbh->prepare("select * from items where biblionumber=? and biblioitemnumber=?"); + $sth_item->execute($row->{biblionumber},$row->{biblioitemnumber}); + while ($row2=$sth_item->fetchrow_hashref) { + my $MARCitem = &MARCkoha2marcItem($dbh,$row2->{biblionumber},$row2->{itemnumber}); + &MARCadditem($dbh,$MARCitem,$row2->{biblionumber}); + } +} + + -- 2.39.5