[Koha-cvs] koha/misc/migration_tools/unimarc export.pl mis... [rel_3_0]

paul poulain paul at koha-fr.org
Tue Nov 28 11:09:33 CET 2006


CVSROOT:	/sources/koha
Module name:	koha
Branch:		rel_3_0
Changes by:	paul poulain <tipaul>	06/11/28 10:09:33

Removed files:
	misc/migration_tools/unimarc: export.pl missing090field.pl 
	                              move_marc_to_biblioitems.pl 
	                              rebuild_100.pl rebuild_leader.pl 

Log message:
	directory cleaning : 
	* moving 
	- all tools to migrate from 2.2 to 3.0 into misc/migration_tools/22_to_30 directory
	- all zebra configuration files to misc/zebra/
	
	* removing previous directories :
	- migration_tools/unimarc
	- zebraplugin
	- misc/zebraauthorities
	- misc/zebra/unimarc
	- misc/zebra/usmarc
	
	* updating misc/migration_tools/rebuild_zebra.pl script
	
	I'll summarize the final result on koha-devel, the main goal being, as kados suggested :
	- to have all config files in a single place, and with a common naming convention
	- all tools scripts in a single place too. The 22_to_30 directory being only for migrations from 2.2 to 3.0 Scripts useful to reindex... will stay in misc/migration_tools

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/misc/migration_tools/unimarc/export.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.1.2.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/koha/misc/migration_tools/unimarc/missing090field.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.1.2.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/koha/misc/migration_tools/unimarc/move_marc_to_biblioitems.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.1.2.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/koha/misc/migration_tools/unimarc/rebuild_100.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.1.2.2&r2=0
http://cvs.savannah.gnu.org/viewcvs/koha/misc/migration_tools/unimarc/rebuild_leader.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.1.2.1&r2=0

Patches:
Index: export.pl
===================================================================
RCS file: export.pl
diff -N export.pl
--- export.pl	10 Oct 2006 15:23:09 -0000	1.1.2.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,60 +0,0 @@
-#!/usr/bin/perl 
-# This script finds and fixes missing 090 fields in Koha for MARC21
-#  Written by TG on 01/10/2005
-#  Revised by Joshua Ferraro on 03/31/2006
-use strict;
-
-# Koha modules used
-
-use C4::Context;
-use C4::Biblio;
-use MARC::Record;
-use MARC::File::XML(BinaryEncoding=>"utf8");
-#use MARC::Charset;
-#MARC::Charset->assume_unicode(1);
-#MARC::File::XML::default_record_format("UNIMARC");
-
-my $dbh = C4::Context->dbh;
-
-my $sth=$dbh->prepare("select marc,marcxml from biblioitems");
-	$sth->execute();
-
-while (my ($marc,$marcxml)=$sth->fetchrow ){
-#   my $record;
-  print $marc;
-  
-#		MARCmodrecord($biblionumber,$record,$time);
-# 		
-}
-
-sub MARCmodrecord{
-my ($biblionumber,$record,$time)=@_;
-my $update=0;
-#warn "".$record->leader();
-#if (length($record->leader())>24){
-#	$record->leader(substr($record->leader,0,24));	
-#	$update =1;
-#} elsif (length($record->leader())<24){
-	$record->leader('     nac  22     1u 4500');
- 	$update=1;
-#}
-    my $string = POSIX::strftime("%Y%m%d", localtime);
-    $string=~s/\-//g;
-     $string = sprintf("%-*s",35, $string);
-     substr($string,22,6,"frey50");
-     unless ($record->subfield(100,"a")){
-       $record->insert_fields_ordered(MARC::Field->new(100,"","","a"=>$string));
-     }
-  warn $record->as_formatted;
-# 
-# warn "leader : ".$record->leader if ($biblionumber==2262);
- foreach ($record->field('995')) {
- 	$record->delete_field($_);
-}
- if ($update){	
- 	&MARCmodbiblio($dbh,$biblionumber,$record,'',0);
- 	print "$biblionumber \n";	
- }
-
-}
-END;

Index: missing090field.pl
===================================================================
RCS file: missing090field.pl
diff -N missing090field.pl
--- missing090field.pl	10 Oct 2006 15:23:09 -0000	1.1.2.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,53 +0,0 @@
-#!/usr/bin/perl
-# This script finds and fixes missing 090 fields in Koha for MARC21
-#  Written by TG on 01/10/2005
-#  Revised by Joshua Ferraro on 03/31/2006
-use strict;
-
-# Koha modules used
-
-use C4::Context;
-use C4::Biblio;
-use MARC::Record;
-use MARC::File::USMARC;
-
-
-my $dbh = C4::Context->dbh;
-
-my $sth=$dbh->prepare("select m.bibid,b.biblioitemnumber from marc_biblio m left join biblioitems b on b.biblionumber=m.biblionumber");
-	$sth->execute();
-
-while (my ($biblionumber,$biblioitemnumber)=$sth->fetchrow ){
- my $record = MARCgetbiblio($dbh,$biblionumber);
-    print "$biblionumber \n";	
- 
-		MARCmodbiblionumber($biblionumber,$biblioitemnumber,$record);
-		
-}
-
-sub MARCmodbiblionumber{
-my ($biblionumber,$biblioitemnumber,$record)=@_;
-
-my ($tagfield,$biblionumtagsubfield) = &MARCfind_marc_from_kohafield($dbh,"biblio.biblionumber","");
-my ($tagfield2,$biblioitemtagsubfield) = &MARCfind_marc_from_kohafield($dbh,"biblio.biblioitemnumber","");
-	
-my $update=0;
-      my @tags = $record->field($tagfield);
-
-my $newrec = MARC::Field->new( $tagfield,'','', $biblionumtagsubfield => $biblionumber,$biblioitemtagsubfield=>$biblioitemnumber);
-if (!@tags){
-    $record->append_fields($newrec);
-} else{
-	$record->field($tagfield)->replace_with($newrec)
-}	
-
-foreach ($record->field('995')){
-	$record->delete_field($_);
-}	
-#if ($update){	
-&MARCmodbiblio($dbh,$biblionumber,$record,'',0);
-	print "$biblionumber \n";	
-#	}
-
-}
-END;

Index: move_marc_to_biblioitems.pl
===================================================================
RCS file: move_marc_to_biblioitems.pl
diff -N move_marc_to_biblioitems.pl
--- move_marc_to_biblioitems.pl	10 Oct 2006 15:23:09 -0000	1.1.2.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,39 +0,0 @@
-#!/usr/bin/perl
-
-# script to shift marc to biblioitems
-# scraped from updatedatabase for dev week by chris at katipo.co.nz
-
-use C4::Context;
-use C4::Biblio;
-use MARC::Record;
-use MARC::File::XML ( BinaryEncoding => 'utf8' );
-
-print "moving MARC record to biblioitems table\n";
-
-my $dbh = C4::Context->dbh();
-# changing marc field type
-$dbh->do('ALTER TABLE biblioitems CHANGE marc marc BLOB NULL DEFAULT NULL ');
-
-# adding marc xml, just for convenience
-$dbh->do(
-'ALTER TABLE biblioitems ADD marcxml TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL '
-);
-
-# moving data from marc_subfield_value to biblio
-$sth = $dbh->prepare('select bibid,biblionumber from marc_biblio');
-$sth->execute;
-my $sth_update =
-  $dbh->prepare(
-    'update biblioitems set marcxml=?, marc=? where biblionumber=?');
-my $totaldone = 0;
-while ( my ( $bibid, $biblionumber ) = $sth->fetchrow ) {
-    my $record = MARCgetbiblio( $dbh, $bibid );
-print $record->as_formatted;
-    #Force UTF-8 in record leader
-    $record->encoding('UTF-8');
-    $sth_update->execute( $record->as_xml(),$record->as_usmarc(),
-        $biblionumber );
-    $totaldone++;
-    print "\r$totaldone / $totaltodo" unless ( $totaldone % 100 );
-}
-print "\rdone\n";

Index: rebuild_100.pl
===================================================================
RCS file: rebuild_100.pl
diff -N rebuild_100.pl
--- rebuild_100.pl	11 Oct 2006 15:23:22 -0000	1.1.2.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,59 +0,0 @@
-#!/usr/bin/perl
-# This script finds and fixes missing 090 fields in Koha for MARC21
-#  Written by TG on 01/10/2005
-#  Revised by Joshua Ferraro on 03/31/2006
-use strict;
-
-# Koha modules used
-
-use C4::Context;
-use C4::Biblio;
-use MARC::Record;
-use MARC::File::USMARC;
-
-
-my $dbh = C4::Context->dbh;
-
-my $sth=$dbh->prepare("select biblionumber,timestamp from biblioitems");
-	$sth->execute();
-
-while (my ($biblionumber,$time)=$sth->fetchrow ){
-#   my $record;
-  my $record = MARCgetbiblio($dbh,$biblionumber);
-#print $record->as_marc;
-		MARCmodrecord($biblionumber,$record,$time);
-#
-}
-
-sub MARCmodrecord {
-    my ($biblionumber,$record,$time)=@_;
-#     warn "AVANT : ".$record->as_formatted;
-    my $update=0;
-        $record->leader('     nac  22     1u 4500');
-        $update=1;
-        my $string;
-        if ($record->subfield(100,"a")) {
-            $string = $record->subfield(100,"a");
-            my $f100 = $record->field(100);
-            $record->delete_field($f100);
-        } else {
-            $string = POSIX::strftime("%Y%m%d", localtime);
-            $string=~s/\-//g;
-            $string = sprintf("%-*s",35, $string);
-        }
-        substr($string,22,6,"frey50");
-        unless ($record->subfield(100,"a")){
-            $record->insert_fields_ordered(MARC::Field->new(100,"","","a"=>$string));
-        }
-#     warn "APRES : ".$record->as_formatted;
-    # delete all items related fields
-    foreach ($record->field('995')) {
-        $record->delete_field($_);
-    }
-    if ($update){	
-        &MARCmodbiblio($dbh,$biblionumber,$record,'',0);
-        print "$biblionumber \n";	
-    }
-
-}
-END;

Index: rebuild_leader.pl
===================================================================
RCS file: rebuild_leader.pl
diff -N rebuild_leader.pl
--- rebuild_leader.pl	10 Oct 2006 15:23:09 -0000	1.1.2.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,50 +0,0 @@
-#!/usr/bin/perl
-# This script finds and fixes missing 090 fields in Koha for MARC21
-#  Written by TG on 01/10/2005
-#  Revised by Joshua Ferraro on 03/31/2006
-use strict;
-
-# Koha modules used
-
-use C4::Context;
-use C4::Biblio;
-use MARC::Record;
-use MARC::File::USMARC;
-
-
-my $dbh = C4::Context->dbh;
-
-my $sth=$dbh->prepare("select m.bibid,b.biblioitemnumber from marc_biblio m left join biblioitems b on b.biblionumber=m.biblionumber ");
-	$sth->execute();
-
-while (my ($biblionumber,$biblioitemnumber)=$sth->fetchrow ){
- my $record = MARCgetbiblio($dbh,$biblionumber);
-		
-		MARCmodleader($biblionumber,$record);
-		
-}
-
-sub MARCmodleader{
-my ($biblionumber,$record)=@_;
-
-my $update=0;
-#warn "".$record->leader();
-#if (length($record->leader())>24){
-#	$record->leader(substr($record->leader,0,24));	
-#	$update =1;
-#} elsif (length($record->leader())<24){
-	$record->leader('     nac  22     1u 4500');
-	$update=1;
-#}
-
-warn "leader : ".$record->leader if ($biblionumber==2262);
-foreach ($record->field('995')) {
-	$record->delete_field($_);
-}
-if ($update){	
-	&MARCmodbiblio($dbh,$biblionumber,$record,'',0);
-	print "$biblionumber \n";	
-}
-
-}
-END;





More information about the Koha-cvs mailing list