From dd3f557f53f01dd6f5db51c044d792974e547720 Mon Sep 17 00:00:00 2001 From: Joshua Ferraro Date: Sun, 30 Dec 2007 12:52:18 -0500 Subject: [PATCH] fixing nomenclature on files in misc/, adding a few new utilities Signed-off-by: Joshua Ferraro --- ...ers.pl => batchCompareMARCvsFrameworks.pl} | 64 +++---- ...arcdb.pl => batchDeleteUnusedSubfields.pl} | 0 ...pl => batchImportMARCWithBiblionumbers.pl} | 7 +- ...nonmarc.pl => batchRebuildBiblioTables.pl} | 0 ....pl => batchRepairMissingBiblionumbers.pl} | 2 +- misc/{bulkupdate.pl => batchupdateISBNs.pl} | 4 +- misc/benchmark.pl | 12 +- misc/dumpmarc.pl | 51 ------ misc/exportauth.pl | 28 ++- misc/{ => migration_tools}/bulkauthimport.pl | 0 misc/migration_tools/check_dirs.pl | 148 ---------------- misc/migration_tools/check_marc_definition.pl | 47 ----- misc/{ => migration_tools}/merge_authority.pl | 0 misc/migration_tools/rebuild_zebra_idx.pl | 53 ------ misc/migration_tools/test_cql2rpn.pl | 21 --- misc/perlmodule_ls.pl | 8 + misc/perlmodule_rm.pl | 19 ++ misc/rebuild_marc_newframework.pl | 92 ---------- .../check_parser.pl => sax_parser_print.pl} | 5 +- misc/sax_parser_test.pl | 22 +++ misc/sync_koha_plugin.pl | 164 ------------------ misc/xmlintobiblioitems.pl | 46 ----- 22 files changed, 110 insertions(+), 683 deletions(-) rename misc/{compare_iso_and_marc_parameters.pl => batchCompareMARCvsFrameworks.pl} (54%) rename misc/{cleanmarcdb.pl => batchDeleteUnusedSubfields.pl} (100%) rename misc/{marcimport_to_biblioitems.pl => batchImportMARCWithBiblionumbers.pl} (91%) rename misc/{rebuildnonmarc.pl => batchRebuildBiblioTables.pl} (100%) rename misc/{missing090field.pl => batchRepairMissingBiblionumbers.pl} (94%) rename misc/{bulkupdate.pl => batchupdateISBNs.pl} (96%) delete mode 100755 misc/dumpmarc.pl rename misc/{ => migration_tools}/bulkauthimport.pl (100%) delete mode 100755 misc/migration_tools/check_dirs.pl delete mode 100755 misc/migration_tools/check_marc_definition.pl rename misc/{ => migration_tools}/merge_authority.pl (100%) delete mode 100755 misc/migration_tools/rebuild_zebra_idx.pl delete mode 100755 misc/migration_tools/test_cql2rpn.pl create mode 100755 misc/perlmodule_ls.pl create mode 100755 misc/perlmodule_rm.pl delete mode 100755 misc/rebuild_marc_newframework.pl rename misc/{migration_tools/check_parser.pl => sax_parser_print.pl} (63%) create mode 100755 misc/sax_parser_test.pl delete mode 100755 misc/sync_koha_plugin.pl delete mode 100755 misc/xmlintobiblioitems.pl diff --git a/misc/compare_iso_and_marc_parameters.pl b/misc/batchCompareMARCvsFrameworks.pl similarity index 54% rename from misc/compare_iso_and_marc_parameters.pl rename to misc/batchCompareMARCvsFrameworks.pl index e3f86b6173..0b806f0a2a 100755 --- a/misc/compare_iso_and_marc_parameters.pl +++ b/misc/batchCompareMARCvsFrameworks.pl @@ -24,22 +24,26 @@ GetOptions( 'n:s' => \$number, 'v' => \$version, 'w' => \$nowarning, - 'c' => \$frameworkcode, + 'c' => \$frameworkcode, ); $frameworkcode="" unless $frameworkcode; if ($version || ($input_marc_file eq '')) { - print <execute($frameworkcode); my %hash_unused; my %hash_used; while (my ($tagfield,$tagsubfield,$tab) = $sth->fetchrow) { - $hash_unused{"$tagfield$tagsubfield"} = 1 if ($tab eq -1); - $hash_used{"$tagfield$tagsubfield"} = 1 if ($tab ne -1); + $hash_unused{"$tagfield$tagsubfield"} = 1 if ($tab eq -1); + $hash_used{"$tagfield$tagsubfield"} = 1 if ($tab ne -1); } my $i=0; while ( my $record = $batch->next() ) { - $i++; - foreach my $MARCfield ($record->fields()) { - next if $MARCfield->tag()<=010; - if ($MARCfield) { - foreach my $fields ($MARCfield->subfields()) { - if ($fields) { - if ($hash_unused{$MARCfield->tag().@$fields[0]}>=1) { - $hash_unused{$MARCfield->tag().@$fields[0]}++; - } - if ($hash_used{$MARCfield->tag().@$fields[0]}>=1) { - $hash_used{$MARCfield->tag().@$fields[0]}++; - } - } - # foreach my $field (@$fields) { - # warn "==>".$MARCfield->tag().@$fields[0]; - # } - } - } - } + $i++; + foreach my $MARCfield ($record->fields()) { + next if $MARCfield->tag()<=010; + if ($MARCfield) { + foreach my $fields ($MARCfield->subfields()) { + if ($fields) { + if ($hash_unused{$MARCfield->tag().@$fields[0]}>=1) { + $hash_unused{$MARCfield->tag().@$fields[0]}++; + } + if ($hash_used{$MARCfield->tag().@$fields[0]}>=1) { + $hash_used{$MARCfield->tag().@$fields[0]}++; + } + } + # foreach my $field (@$fields) { + # warn "==>".$MARCfield->tag().@$fields[0]; + # } + } + } + } } print "Undeclared tag/subfields that exists in the file\n"; print "================================================\n"; foreach my $key (sort keys %hash_unused) { - print "$key => ".($hash_unused{$key}-1)."\n" unless ($hash_unused{$key}==1); + print "$key => ".($hash_unused{$key}-1)."\n" unless ($hash_unused{$key}==1); } print "Declared tag/subfields unused in the iso2709 file\n"; print "=================================================\n"; foreach my $key (sort keys %hash_used) { - print "$key => ".($hash_used{$key}-1)."\n" if ($hash_used{$key}==1); + print "$key => ".($hash_used{$key}-1)."\n" if ($hash_used{$key}==1); } # foreach my $x (sort keys %resB) { -# print "$x => ".$resB{$x}."\n"; +# print "$x => ".$resB{$x}."\n"; # } print "\n==================\n$i record parsed\n"; diff --git a/misc/cleanmarcdb.pl b/misc/batchDeleteUnusedSubfields.pl similarity index 100% rename from misc/cleanmarcdb.pl rename to misc/batchDeleteUnusedSubfields.pl diff --git a/misc/marcimport_to_biblioitems.pl b/misc/batchImportMARCWithBiblionumbers.pl similarity index 91% rename from misc/marcimport_to_biblioitems.pl rename to misc/batchImportMARCWithBiblionumbers.pl index 95ccde52b6..893d988a76 100755 --- a/misc/marcimport_to_biblioitems.pl +++ b/misc/batchImportMARCWithBiblionumbers.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -# script that correct the marcxml from in biblioitems -# Written by TG on 10/04/2006 +# load records that already have biblionumber set into a koha system +# Written by TG on 10/04/2006 use strict; BEGIN { # find Koha's Perl modules @@ -28,7 +28,8 @@ GetOptions( if ($version || ($input_marc_file eq '')) { print <dbh(); my $sth = $dbh->prepare("select max(borrowernumber) from borrowers"); $sth->execute; @@ -24,7 +26,7 @@ $sth = $dbh->prepare("select max(itemnumber) from items"); $sth->execute; my ($itemnumber_max) = $sth->fetchrow; -my $baseurl= "http://i17.bureau.paulpoulain.com/cgi-bin/koha"; +my $baseurl= C4::Context->preference("staffClientBaseURL")."/cgi-bin/koha/"; my $max_tries = 200; my $concurrency = 5; @@ -35,7 +37,7 @@ $|=1; my $b = HTTPD::Bench::ApacheBench->new; $b->concurrency( $concurrency ); # -# mainpage : (very) low mySQL dependancy +# mainpage : (very) low RDBMS dependency # my $b0 = HTTPD::Bench::ApacheBench->new; $b0->concurrency( $concurrency ); @@ -45,7 +47,7 @@ print "--------------\n"; print "Koha benchmark\n"; print "--------------\n"; print "benchmarking with $max_tries occurences of each operation\n"; -print "mainpage (no mySQL) "; +print "mainpage (low RDBMS dependency) "; for (my $i=1;$i<=$max_tries;$i++) { push @mainpage,"$baseurl/mainpage.pl"; } diff --git a/misc/dumpmarc.pl b/misc/dumpmarc.pl deleted file mode 100755 index b8fba0c68d..0000000000 --- a/misc/dumpmarc.pl +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/perl -# small script that dumps an iso2709 file. - - -use strict; -BEGIN { - # find Koha's Perl modules - # test carefully before changing this - use FindBin; - eval { require "$FindBin::Bin/kohalib.pl" }; -} - -# Koha modules used -use MARC::File::USMARC; -use MARC::Record; -use MARC::Batch; - -use Getopt::Long; -my ( $input_marc_file,$number,$nowarning) = ('',0); -my $version; -GetOptions( - 'file:s' => \$input_marc_file, - 'n:s' => \$number, - 'v' => \$version, - 'w' => \$nowarning, -); - -warn "NUM : $number\n"; -if ($version || ($input_marc_file eq '')) { - print <new( 'USMARC', $input_marc_file ); -$batch->warnings_off() unless $nowarning; -$batch->strict_off() unless $nowarning; -my $i=1; -while ( my $record = $batch->next() ) { - print "\nNUMBER $i =>\n".$record->as_formatted() if ($i eq $number || $number eq 0); - $i++; -} -print "\n==================\n$i record parsed\n"; diff --git a/misc/exportauth.pl b/misc/exportauth.pl index 109713fd82..31abe29e1e 100755 --- a/misc/exportauth.pl +++ b/misc/exportauth.pl @@ -11,27 +11,19 @@ BEGIN { eval { require "$FindBin::Bin/kohalib.pl" }; } require Exporter; - -use C4::Auth; +use C4::Context; use C4::Output; # contains gettemplate use C4::Biblio; -use CGI; use C4::Auth; my $outfile = $ARGV[0]; open(OUT,">$outfile") or die $!; -my $query = new CGI; -my $dbh=DBI->connect("DBI:mysql:database=koha2;host=localhost;port=3306","kohaserver","kohaserver") or die $DBI::errmsg; -#$dbh->do("set character_set_client='latin5'"); -#$dbh->do("set character_set_connection='utf8'"); -#$dbh->do("set character_set_results='latin5'"); -#my $dbh=C4::Context->dbh; - my $sth; - - $sth=$dbh->prepare("select marc from auth_header order by authid"); - $sth->execute(); - - while (my ($marc) = $sth->fetchrow) { - - print OUT $marc; - } +my $dbh=C4::Context->dbh; +#$dbh->do("set character_set_client='latin5'"); +$dbh->do("set character_set_connection='utf8'"); +#$dbh->do("set character_set_results='latin5'"); +my $sth=$dbh->prepare("select marc from auth_header order by authid"); +$sth->execute(); +while (my ($marc) = $sth->fetchrow) { + print OUT $marc; + } close(OUT); diff --git a/misc/bulkauthimport.pl b/misc/migration_tools/bulkauthimport.pl similarity index 100% rename from misc/bulkauthimport.pl rename to misc/migration_tools/bulkauthimport.pl diff --git a/misc/migration_tools/check_dirs.pl b/misc/migration_tools/check_dirs.pl deleted file mode 100755 index 9117e595bf..0000000000 --- a/misc/migration_tools/check_dirs.pl +++ /dev/null @@ -1,148 +0,0 @@ -#!/usr/bin/perl - -use C4::Context; -use Getopt::Long; -use C4::Biblio; - -# -# script that checks zebradir structure & create directories & mandatory files if needed -# -# - -$|=1; # flushes output - -print "Zebra directory =>".C4::Context->zebraconfig('biblioserver')->{directory}."\n"; -print "Koha directory =>".C4::Context->config('intranetdir')."\n"; - -my $zebradir = C4::Context->zebraconfig('biblioserver')->{directory}; -my $kohadir = C4::Context->config('intranetdir'); -my $directory; -my $skip_export; -my $keep_export; -GetOptions( - 'd:s' => \$directory, - 's' => \$skip_export, - 'k' => \$keep_export, - ); - -$directory = "export" unless $directory; - -my $created_dir_or_file = 0; -print "====================\n"; -print "checking directories & files\n"; -print "====================\n"; -unless (-d "$zebradir") { - system("mkdir -p $zebradir"); - print "created $zebradir\n"; - $created_dir_or_file++; -} -unless (-d "$zebradir/lock") { - mkdir "$zebradir/lock"; - print "created $zebradir/lock\n"; - $created_dir_or_file++; -} -unless (-d "$zebradir/register") { - mkdir "$zebradir/register"; - print "created $zebradir/register\n"; - $created_dir_or_file++; -} -unless (-d "$zebradir/shadow") { - mkdir "$zebradir/shadow"; - print "created $zebradir/shadow\n"; - $created_dir_or_file++; -} -unless (-d "$zebradir/tab") { - mkdir "$zebradir/tab"; - print "created $zebradir/tab\n"; - $created_dir_or_file++; -} - -unless (-d "$zebradir/etc") { - mkdir "$zebradir/etc"; - print "created $zebradir/etc\n"; - $created_dir_or_file++; -} - -unless (-f "$zebradir/tab/record.abs") { - system("cp -f $kohadir/zebraplugin/zebradb/biblios/tab/record_for_unimarc.abs $zebradir/tab/record.abs"); - print "copied record.abs\n"; - $created_dir_or_file++; -} -unless (-f "$zebradir/tab/sort-string-utf.chr") { - system("cp -f $kohadir/zebraplugin/zebradb/biblios/tab/sort-string-utf.chr $zebradir/tab/sort-string-utf.chr"); - print "copied sort-string-utf.chr\n"; - $created_dir_or_file++; -} -unless (-f "$zebradir/tab/word-phrase-utf.chr") { - system("cp -f $kohadir/zebraplugin/zebradb/biblios/tab/word-phrase-utf.chr $zebradir/tab/word-phrase-utf.chr"); - print "copied word-phase-utf.chr\n"; - $created_dir_or_file++; -} -unless (-f "$zebradir/tab/bib1.att") { - system("cp -f $kohadir/zebraplugin/zebradb/biblios/tab/bib1.att $zebradir/tab/bib1.att"); - print "copied bib1.att\n"; - $created_dir_or_file++; -} - -unless (-f "$zebradir/etc/zebra-biblios.cfg") { - system("cp -f $kohadir/zebraplugin/etc/zebra-biblios.cfg $zebradir/etc/zebra-biblios.cfg"); - print "copied zebra-biblios.cfg\n"; - $created_dir_or_file++; -} -unless (-f "$zebradir/etc/ccl.properties") { - system("cp -f $kohadir/zebraplugin/etc/ccl.properties $zebradir/etc/ccl.properties"); - print "copied ccl.properties\n"; - $created_dir_or_file++; -} -unless (-f "$zebradir/etc/pqf.properties") { - system("cp -f $kohadir/zebraplugin/etc/pqf.properties $zebradir/etc/pqf.properties"); - print "copied pqf.properties\n"; - $created_dir_or_file++; -} - -if ($created_dir_or_file) { - print "created : $created_dir_or_file directories & files\n"; -} else { - print "file & directories OK\n"; -} - -if ($skip_export) { - print "====================\n"; - print "SKIPPING biblio export\n"; - print "====================\n"; -} else { - print "====================\n"; - print "exporting biblios\n"; - print "====================\n"; - mkdir "$directory" unless (-d $directory); - open(OUT,">:utf8","$directory/export") or die $!; - my $dbh=C4::Context->dbh; - my $sth; - $sth=$dbh->prepare("select biblionumber from biblioitems order by biblionumber"); - $sth->execute(); - my $i=0; - while (my ($biblionumber) = $sth->fetchrow) { - my $record = MARCgetbiblio($dbh,$biblionumber); - print "."; - print "\r$i" unless ($i++ %100); - print OUT $record->as_usmarc(); - } - close(OUT); -} - -print "====================\n"; -print "REINDEXING zebra\n"; -print "====================\n"; -system("zebraidx -g iso2709 -c $zebradir/etc/zebra-biblios.cfg -d biblios update $directory"); -system("zebraidx -g iso2709 -c $zebradir/etc/zebra-biblios.cfg -d biblios commit"); - -print "====================\n"; -print "CLEANING\n"; -print "====================\n"; -if ($k) { - print "NOTHING cleaned : the $directory has been kept. You can re-run this script with the -s parameter if you just want to rebuild zebra after changing the record.abs or another zebra config file\n"; -} else { - system("rm -rf $zebradir"); - print "directory $zebradir deleted\n"; -} -} \ No newline at end of file diff --git a/misc/migration_tools/check_marc_definition.pl b/misc/migration_tools/check_marc_definition.pl deleted file mode 100755 index 6fc0491985..0000000000 --- a/misc/migration_tools/check_marc_definition.pl +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/perl -# script that rebuild thesaurus from biblio table. - -use strict; - -# Koha modules used -use MARC::File::USMARC; -use MARC::Record; -use MARC::Batch; -use C4::Context; -use C4::Biblio; -use C4::AuthoritiesMarc; -use Time::HiRes qw(gettimeofday); - -use Getopt::Long; -my ( $input_marc_file, $number) = ('',0); -my ($version,$confirm); -GetOptions( - 'h' => \$version, - 'c' => \$confirm, -); - -if ($version || ($confirm eq '')) { - print <dbh; -print "Checking\n"; -my $sth = $dbh->prepare("SELECT count(*), tag, subfieldcode, frameworkcode FROM marc_subfield_table, marc_biblio WHERE marc_biblio.bibid = marc_subfield_table.bibid group by frameworkcode,tag,subfieldcode"); -$sth->execute; -my $sth2 = $dbh->prepare("select tab,liblibrarian,kohafield from marc_subfield_structure where tagfield=? and tagsubfield=? and frameworkcode=?"); -while (my ($total,$tag,$subfield,$frameworkcode) = $sth->fetchrow) { - $sth2->execute($tag,$subfield,$frameworkcode); - my ($tab,$liblibrarian,$kohafield) = $sth2->fetchrow; - if ($tab eq -1 && $kohafield ne "biblio.biblionumber" && $kohafield ne "biblioitems.biblioitemnumber" && $kohafield ne "items.itemnumber") { - print "Tab ignore for framework $frameworkcode, $tag\$$subfield - $liblibrarian (used $total times)\n"; - } -} - -print "Done\n"; diff --git a/misc/merge_authority.pl b/misc/migration_tools/merge_authority.pl similarity index 100% rename from misc/merge_authority.pl rename to misc/migration_tools/merge_authority.pl diff --git a/misc/migration_tools/rebuild_zebra_idx.pl b/misc/migration_tools/rebuild_zebra_idx.pl deleted file mode 100755 index 2ed7a1fe41..0000000000 --- a/misc/migration_tools/rebuild_zebra_idx.pl +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/perl -# small script that import an iso2709 file into koha 2.0 - -use strict; - -# Koha modules used -use MARC::File::USMARC; -use MARC::Record; -use MARC::Batch; -use C4::Context; -use C4::Biblio; -use Time::HiRes qw(gettimeofday); - -use Getopt::Long; -my ( $input_marc_file, $number) = ('',0); -my ($confirm); -GetOptions( - 'c' => \$confirm, -); - -unless ($confirm) { - print <dbh; -my $cgidir = C4::Context->intranetdir."/"; - -my $starttime = gettimeofday; -my $sth = $dbh->prepare("select biblionumber from biblio"); -$sth->execute; -my $i=0; -while ((my $biblionumber) = $sth->fetchrow) { - my $record = GetMarcBiblio($biblionumber); - my $filename = $cgidir."/tmp/BIBLIO".$biblionumber.".iso2709"; - open F,">:utf8", $filename; - eval {print F $record->as_usmarc(); }; - warn "ERROR: writing biblio $biblionumber failed" if $@; - close F; - $i++; - print "\r$i" unless ($i % 100); -} -my $timeneeded = gettimeofday - $starttime; -print "\n$i MARC record done in $timeneeded seconds\n"; diff --git a/misc/migration_tools/test_cql2rpn.pl b/misc/migration_tools/test_cql2rpn.pl deleted file mode 100755 index 96d6203cb3..0000000000 --- a/misc/migration_tools/test_cql2rpn.pl +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/perl -use strict; -use ZOOM; - -my $query="Introduction"; -warn "QUERY : $query"; -my $Zconn; -eval { - $Zconn = new ZOOM::Connection('localhost:2100/Koha'); -}; -$Zconn->option(cqlfile => "/home/paul/koha.dev/head/zebra/pqf.properties"); -my $q = new ZOOM::Query::CQL2RPN( $query, $Zconn); -# warn "Q : $q"; -my $rs= $Zconn->search($q); -my $n = $rs->size()-1; -print "found ".($n+1)." results"; -for my $i (0..$n) { - my $rec = $rs->record($i); - print $rec->render(); -} -# warn "ERROR : ".$Zconn->errcode(); diff --git a/misc/perlmodule_ls.pl b/misc/perlmodule_ls.pl new file mode 100755 index 0000000000..818f855cc2 --- /dev/null +++ b/misc/perlmodule_ls.pl @@ -0,0 +1,8 @@ +#!/usr/bin/perl + +use ExtUtils::Installed; +my $instmod = ExtUtils::Installed->new(); +foreach my $module ($instmod->modules()) { +my $version = $instmod->version($module) || "???"; + print "$module -- $version\n"; +} diff --git a/misc/perlmodule_rm.pl b/misc/perlmodule_rm.pl new file mode 100755 index 0000000000..82e34c6a12 --- /dev/null +++ b/misc/perlmodule_rm.pl @@ -0,0 +1,19 @@ +#!/usr/bin/perl -w +# Remove a perl module +use ExtUtils::Packlist; +use ExtUtils::Installed; + +$ARGV[0] or die "Usage: $0 Module::Name\n"; + +my $mod = $ARGV[0]; + +my $inst = ExtUtils::Installed->new(); + +foreach my $item (sort($inst->files($mod))) { + print "removing $item\n"; + unlink $item; +} + +my $packfile = $inst->packlist($mod)->packlist_file(); +print "removing $packfile\n"; +unlink $packfile; diff --git a/misc/rebuild_marc_newframework.pl b/misc/rebuild_marc_newframework.pl deleted file mode 100755 index dcb797d721..0000000000 --- a/misc/rebuild_marc_newframework.pl +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/perl -#----------------------------------- -# Script Name: rebuild_marc_newframework.pl -# Script Version: 0.1.0 -# Date: 20/04/2006 -##If you change your framework for marc mapping use this script to recreate marc records in your db -## Then drop the old framework and install the new one.New frameworks are being introduced with Koha3.0 -##Re-export all your marc and recreate Zebra db. -##Writen by Tumer Garip tgarip@neu.edu.tr - - - -use strict; -BEGIN { - # find Koha's Perl modules - # test carefully before changing this - use FindBin; - eval { require "$FindBin::Bin/kohalib.pl" }; -} - -use C4::Context; -use C4::Biblio; -use MARC::Record; -use MARC::File::USMARC; -use MARC::File::XML; - -my $dbh=C4::Context->dbh; -use Time::HiRes qw(gettimeofday); - -##Write the corresponding new mappings below. this one maps old 090$c$d to new 09o$c$d and 952 holdings of NEU to 95k values -##Adjust this mapping list to your own needs -my %mapping_list = ( - '090cd' =>'09ocd', - '952abcdefpruvxyz'=>'95kkbcfazpw9d4ye', - ); - -my $starttime = gettimeofday; -my $sth=$dbh->prepare("SELECT biblionumber,marc FROM biblioitems "); -$sth->execute; - -my $update=$dbh->prepare("update biblioitems set marc=?,marcxml=? where biblionumber=?"); - -my $b=0; -my $timeneeded; -while (my ($biblionumber, $marc) = $sth->fetchrow) { - -my $record=MARC::File::USMARC::decode($marc); - -foreach my $key (keys %mapping_list){ -my $tag=substr($key,0,3); -my $newtag=substr($mapping_list{$key},0,3); -my @subf; -my @newsub; - for (my $i=3; $ifield($tag)){ -my $notnew=1; -my $addedfield; - for (my $r=0; $r<@subf; $r++){ - if ($field->subfield($subf[$r]) && $notnew){ - $addedfield=MARC::Field->new($newtag,$field->indicator(1),$field->indicator(2),$newsub[$r]=>$field->subfield($subf[$r])); - $notnew=0; - }elsif ($field->subfield($subf[$r])){ - $addedfield->update($newsub[$r]=>$field->subfield($subf[$r])); - }## a subfield exists - }## all subfields added -$record->delete_field($field); -$record->add_fields($addedfield); -}##foreach field found -##Now update-db -$update->execute($record->as_usmarc,$record->as_xml_record,$biblionumber); - -}##foreach $key - $timeneeded = gettimeofday - $starttime unless ($b % 10000); - print "$b in $timeneeded s\n" unless ($b % 10000); - print "." unless ($b % 500); - $b++; -}##while biblionumber - -##Dont forget to export all new marc records and build your zebra db - - -# $timeneeded = gettimeofday - $starttime unless ($i % 30000); -# print "$i in $timeneeded s\n" unless ($i % 30000); -# print "." unless ($i % 500); -# $i++; - - -$dbh->disconnect(); diff --git a/misc/migration_tools/check_parser.pl b/misc/sax_parser_print.pl similarity index 63% rename from misc/migration_tools/check_parser.pl rename to misc/sax_parser_print.pl index 3cdb3c2c49..9b84f9db27 100755 --- a/misc/migration_tools/check_parser.pl +++ b/misc/sax_parser_print.pl @@ -1,5 +1,6 @@ #!/usr/bin/perl - +# check the current SAX Parser use XML::SAX::ParserFactory; $parser = XML::SAX::ParserFactory->parser(); -print $parser; +print "$parser\n"; + diff --git a/misc/sax_parser_test.pl b/misc/sax_parser_test.pl new file mode 100755 index 0000000000..07d672cf09 --- /dev/null +++ b/misc/sax_parser_test.pl @@ -0,0 +1,22 @@ +#!/usr/bin/perl +use XML::SAX; +my $parser = XML::SAX::ParserFactory->parser( +Handler => MySAXHandler->new +); +binmode STDOUT, ":utf8"; +print "\x{65}\x{301}\n"; +use Encode; $parser->parse_string(encode_utf8("\x{65}\x{301}")); +$parser->parse_string("\xEF\xBB\xBF\x{65}\x{301}"); + +package MySAXHandler; + +use base qw(XML::SAX::Base); +sub start_document { + my ($self, $doc) = @_; + # process document start event +} + +sub start_element { + my ($self, $el) = @_; + # process element start event +} diff --git a/misc/sync_koha_plugin.pl b/misc/sync_koha_plugin.pl deleted file mode 100755 index 3aaaada437..0000000000 --- a/misc/sync_koha_plugin.pl +++ /dev/null @@ -1,164 +0,0 @@ -#!/usr/bin/perl -w - -use strict; -BEGIN { - # find Koha's Perl modules - # test carefully before changing this - use FindBin; - eval { require "$FindBin::Bin/kohalib.pl" }; -} -use C4::Context; -use Getopt::Long; - -my %opt = (); -GetOptions( - \%opt, - qw/head_dir=s rel_2_2_dir=s help/ -) or die "\nHouston, we got a problem\n"; - -if (exists $opt{help}) { - print < - --rel_2_2_dir= - [--help] - ---head_dir: is the directory where your Koha HEAD cvs is checked out. - ---rel_2_2_dir: is the directory where your Koha rel_2_2 cvs is checked -out and symlinked to your Koha install directories. - ---help: show this help - -FIN - - exit(0); -} -# Configurable Variables -foreach my $option (qw/head_dir rel_2_2_dir/) { - if (not exists $opt{$option}) { - die 'option "', $option, '" is mandatory', "\n"; - } - - if (not -d $opt{$option}) { - die '"', $opt{$option}, '" must be an existing directory', "\n"; - } - - if (not $opt{$option} =~ m{^/}) { - die '--', $option, ' must be an absolute path', "\n"; - } -} - -## Modules -system( - 'cp', - $opt{head_dir}.'/C4/Biblio.pm', - $opt{rel_2_2_dir}.'/C4/' -); -system( - 'cp', - $opt{head_dir}.'/C4/Context.pm', - $opt{rel_2_2_dir}.'/C4/' -); -system( - 'cp', - $opt{head_dir}.'/C4/SearchMarc.pm', - $opt{rel_2_2_dir}.'/C4/' -); -system( - 'cp', - $opt{head_dir}.'/C4/Log.pm', - $opt{rel_2_2_dir}.'/C4/' -); - -system( - 'cp', - $opt{head_dir}.'/C4/Review.pm', - $opt{rel_2_2_dir}.'/C4/' -); -system( - 'cp', - $opt{head_dir}.'/misc/plugin/Search.pm', - $opt{rel_2_2_dir}.'/C4/' -); - -## Intranet -system( - 'cp', - $opt{head_dir}.'/cataloguing/addbiblio.pl', - $opt{rel_2_2_dir}.'/acqui.simple/addbiblio.pl' -); -system( - 'cp', - $opt{head_dir}.'/cataloguing/additem.pl', - $opt{rel_2_2_dir}.'/acqui.simple/' -); -system( - 'cp', - $opt{head_dir}.'/catalogue/detail.pl', - $opt{rel_2_2_dir}.'/' -); -system( - 'cp', - $opt{head_dir}.'/catalogue/MARCdetail.pl', - $opt{rel_2_2_dir}.'/' -); -system( - 'cp', - $opt{head_dir}.'/catalogue/ISBDdetail.pl', - $opt{rel_2_2_dir}.'/' -); - -# OPAC -system( - 'cp', - $opt{head_dir}.'/opac/opac-detail.pl', - $opt{rel_2_2_dir}.'/opac/' -); -system( - 'cp', - $opt{head_dir}.'/opac/opac-MARCdetail.pl', - $opt{rel_2_2_dir}.'/opac/' -); -system( - 'cp', - $opt{head_dir}.'/opac/opac-ISBDdetail.pl', - $opt{rel_2_2_dir}.'/opac/' -); - -## Add the symlink necessary due to changes in the dir structure -system( - 'ln', - '-s', - $opt{rel_2_2_dir}.'/koha-tmpl/intranet-tmpl/npl/en/acqui.simple', - $opt{rel_2_2_dir}.'/koha-tmpl/intranet-tmpl/npl/en/cataloguing' -); - -## Add the 'record.abs' symlink -system( - 'ln', - '-s', - $opt{head_dir}.'/misc/zebra/usmarc/collection.abs', - $opt{head_dir}.'/misc/zebra/usmarc/record.abs' -); - -## Create symlink from intranet/zebra to head zebra directory -system( - 'ln', - '-s', - $opt{head_dir}.'/misc/zebra/usmarc', - C4::Context->config("intranetdir").'/zebra' -); - -print "Finished\n\nRemember, you still need to: - -1. Edit moredetail.tmpl and detail.tmpl to allow for deletions - -2. add to the search - pages to sort by relevance by default - -\n"; - diff --git a/misc/xmlintobiblioitems.pl b/misc/xmlintobiblioitems.pl deleted file mode 100755 index 0ec2e202b4..0000000000 --- a/misc/xmlintobiblioitems.pl +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/perl -# script that correct the marcxml from in biblioitems -# Written by TG on 10/04/2006 -use strict; -BEGIN { - # find Koha's Perl modules - # test carefully before changing this - use FindBin; - eval { require "$FindBin::Bin/kohalib.pl" }; -} - -# Koha modules used - -use C4::Context; -use C4::Biblio; -use MARC::Record; -use MARC::File::USMARC; -use MARC::File::XML; -use Time::HiRes qw(gettimeofday); - -my $starttime = gettimeofday; -my $timeneeded; -my $dbh = C4::Context->dbh; -my $sth=$dbh->prepare("select biblionumber,marc from biblioitems "); - $sth->execute(); - $dbh->do("LOCK TABLES biblioitems WRITE"); -my $i=0; -my $sth2 = $dbh->prepare("UPDATE biblioitems set marcxml=? where biblionumber=?" ); - - -while (my ($biblionumber,$marc)=$sth->fetchrow ){ - - my $record = MARC::File::USMARC::decode($marc); -my $xml=$record->as_xml_record(); -$sth2->execute($xml,$biblionumber); - - print "." unless ($i % 100); -$timeneeded = gettimeofday - $starttime unless ($i % 5000); - print "$i records in $timeneeded s\n" unless ($i % 5000); - $i++; -} -$dbh->do("UNLOCK TABLES "); -$timeneeded = gettimeofday - $starttime ; - print "$i records in $timeneeded s\n" ; - -END; -- 2.20.1