Browse Source

fixing nomenclature on files in misc/, adding a few new utilities

Signed-off-by: Joshua Ferraro <jmf@liblime.com>
3.0.x
Joshua Ferraro 15 years ago
parent
commit
dd3f557f53
  1. 64
      misc/batchCompareMARCvsFrameworks.pl
  2. 0
      misc/batchDeleteUnusedSubfields.pl
  3. 7
      misc/batchImportMARCWithBiblionumbers.pl
  4. 0
      misc/batchRebuildBiblioTables.pl
  5. 2
      misc/batchRepairMissingBiblionumbers.pl
  6. 4
      misc/batchupdateISBNs.pl
  7. 12
      misc/benchmark.pl
  8. 51
      misc/dumpmarc.pl
  9. 28
      misc/exportauth.pl
  10. 0
      misc/migration_tools/bulkauthimport.pl
  11. 148
      misc/migration_tools/check_dirs.pl
  12. 47
      misc/migration_tools/check_marc_definition.pl
  13. 0
      misc/migration_tools/merge_authority.pl
  14. 53
      misc/migration_tools/rebuild_zebra_idx.pl
  15. 21
      misc/migration_tools/test_cql2rpn.pl
  16. 8
      misc/perlmodule_ls.pl
  17. 19
      misc/perlmodule_rm.pl
  18. 92
      misc/rebuild_marc_newframework.pl
  19. 5
      misc/sax_parser_print.pl
  20. 22
      misc/sax_parser_test.pl
  21. 164
      misc/sync_koha_plugin.pl
  22. 46
      misc/xmlintobiblioitems.pl

64
misc/compare_iso_and_marc_parameters.pl → 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 <<EOF
This script compare an iso2709 file and the MARC parameters
It will show the marc fields/subfields used in Koha, and that are not anywhere in the iso2709 file and which fields/subfields that are used in the iso2709 file and not in Koha.
to solve this, just modify Koha parameters (change TAB)
print <<EOF
This script compares an iso2709 file and Koha's MARC frameworks
It will show the marc fields/subfields used in Koha, and that
are not in the iso2709 file and which fields/subfields that are
used in the iso2709 file and not in Koha.
parameters :
\tv : this version/help screen
\tfile /path/to/file/to/dump : the file to dump
\tw : warning and strict off. If your dump fail, try -w option. It it works, then, the file is iso2709, but a buggy one !
\tw : warning and strict off. If your dump fails, try -w option. It it works, then, the file is iso2709, but a buggy one !
\tc : the frameworkcode. If omitted, set to ""
SAMPLE : ./compare_iso_and_marc_parameters.pl -file /home/paul/koha.dev/local/npl -n 1
EOF
;
die;
@ -55,44 +59,44 @@ $sth->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";

0
misc/cleanmarcdb.pl → misc/batchDeleteUnusedSubfields.pl

7
misc/marcimport_to_biblioitems.pl → 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 <<EOF
small script to import an iso2709 file into Koha with existing biblionumbers in marc record.
If your ISO2709 file already has biblionumbers, you can use this script
to import the MARC into your database.
parameters :
\th : this version/help screen
\tfile /path/to/file/to/dump : the file to dump

0
misc/rebuildnonmarc.pl → misc/batchRebuildBiblioTables.pl

2
misc/missing090field.pl → misc/batchRepairMissingBiblionumbers.pl

@ -1,5 +1,5 @@
#!/usr/bin/perl
# This script finds and fixes missing 090 fields in Koha for MARC21
# This script finds and fixes missing biblionumber/biblioitemnumber fields in Koha
# Written by TG on 01/10/2005
# Revised by Joshua Ferraro on 03/31/2006
use strict;

4
misc/bulkupdate.pl → misc/batchupdateISBNs.pl

@ -17,9 +17,9 @@
=head1 bulkupdate.pl
=head1 batchupdateISBNs.pl
This script allows you to update your database/records after a bulkmarckimport integration.
This script batch updates ISBN fields
=cut

12
misc/benchmark.pl

@ -1,5 +1,7 @@
#!/usr/bin/perl
# This is an example script for how to benchmark various
# parts of your Koha system. It's useful for measuring the
# impact of mod_perl on performance.
use strict;
BEGIN {
# find Koha's Perl modules
@ -10,7 +12,7 @@ BEGIN {
use HTTPD::Bench::ApacheBench;
use C4::Context;
# 1st, find some maximal values
# 1st, find some max values
my $dbh=C4::Context->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";
}

51
misc/dumpmarc.pl

@ -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 <<EOF
small script to dump an iso2709 file.
parameters :
\tv : this version/help screen
\tfile /path/to/file/to/dump : the file to dump
\tn : the number of the record to dump. If missing, all the file is dumped
\tw : warning and strict off. If your dump fail, try -w option. It it works, then, the file is iso2709, but a buggy one !
SAMPLE : ./dumpmarc.pl -file /home/paul/koha.dev/local/npl -n 1
EOF
;
die;
}
my $batch = MARC::Batch->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";

28
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);

0
misc/bulkauthimport.pl → misc/migration_tools/bulkauthimport.pl

148
misc/migration_tools/check_dirs.pl

@ -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";
}
}

47
misc/migration_tools/check_marc_definition.pl

@ -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 <<EOF
Script that compare the datas in the DB and the setting of MARC structure
It show all fields/subfields that are in the MARC DB but NOT in any tab (= fields used but not visible) Usually, this means you made an error in your MARC editor. Sometimes, this is something normal.
Enter $0 -c to run this script (the -c being here only to "confirm"
EOF
;#
exit;
}#/
my $dbh = C4::Context->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";

0
misc/merge_authority.pl → misc/migration_tools/merge_authority.pl

53
misc/migration_tools/rebuild_zebra_idx.pl

@ -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 <<EOF
script to write files for zebra DB reindexing. Once it's done, run zebraidx update biblios
run the script with -c to confirm the reindexing.
EOF
;#'
die;
}
$|=1; # flushes output
my $dbh = C4::Context->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";

21
misc/migration_tools/test_cql2rpn.pl

@ -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();

8
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";
}

19
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;

92
misc/rebuild_marc_newframework.pl

@ -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; $i<length($key); $i++){
push @subf,substr($key,$i,1);
push @newsub,substr($mapping_list{$key},$i,1);
}##
foreach my $field ($record->field($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();

5
misc/migration_tools/check_parser.pl → 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";

22
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("<xml>\x{65}\x{301}</xml>"));
$parser->parse_string("<xml>\xEF\xBB\xBF\x{65}\x{301}</xml>");
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
}

164
misc/sync_koha_plugin.pl

@ -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 <<FIN;
Sync the Koha plugin with the appropriate files from HEAD. Assumes
that you've set up your Koha install to use CVS symlinked to the
normal locations.
Usage: sync_koha_plugin.pl --head_dir=<cvs head directory>
--rel_2_2_dir=<cvs rel_2_2 directory>
[--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 <option value=''>Relevance</option> to the search
pages to sort by relevance by default
\n";

46
misc/xmlintobiblioitems.pl

@ -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;
Loading…
Cancel
Save