From 431abf44751eb9f941b4bb3bd77cbcfac64b41f4 Mon Sep 17 00:00:00 2001 From: Wolfram Schneider Date: Tue, 27 Apr 2010 18:55:34 +0200 Subject: [PATCH] rewritten to support more options usage ./irspy-rewrite-records.pl [ options ] database --xslt=../xsl/irspy2zeerex.xsl set xslt sheet --debug=0..2 verbose level --query=cql.allRecords=1 --- bin/irspy-rewrite-records.pl | 47 ++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/bin/irspy-rewrite-records.pl b/bin/irspy-rewrite-records.pl index a560db9..3dbd731 100755 --- a/bin/irspy-rewrite-records.pl +++ b/bin/irspy-rewrite-records.pl @@ -3,28 +3,53 @@ # perl -I ../lib irspy-rewrite-records.pl localhost:8018/IR-Explain---1 use lib '../lib'; +use Data::Dumper; +use Getopt::Long; use ZOOM::IRSpy; use ZOOM::IRSpy::Utils qw(render_record); use strict; use warnings; -my($dbname) = @ARGV; -die "$0 no database name specified" if !defined $dbname; +my $irspy_to_zeerex_xsl = '../xsl/irspy2zeerex.xsl'; +my $debug = 1; +my $cql_query = "cql.allRecords=1"; -my $irspy_to_zeerex_xsl = $ARGV[1] || '../xsl/irspy2zeerex.xsl'; +sub usage { + my $message = shift; + + warn "$message\n" if defined $message; + + < \$irspy_to_zeerex_xsl, + "debug=i" => \$debug, + "query=s" => \$cql_query, +); + +my $dbname = shift; +die usage("no database name specified\n") if !defined $dbname; $ZOOM::IRSpy::irspy_to_zeerex_xsl = $irspy_to_zeerex_xsl if $irspy_to_zeerex_xsl; -my $spy = new ZOOM::IRSpy($dbname, "admin", "fruitbat"); -my $rs = $spy->{conn}->search(new ZOOM::Query::CQL("cql.allRecords=1")); -print STDERR "rewriting ", $rs->size(), " target records"; +my $spy = new ZOOM::IRSpy( $dbname, "admin", "fruitbat" ); +my $rs = $spy->{conn}->search( new ZOOM::Query::CQL($cql_query) ); +print STDERR "rewriting ", $rs->size(), " target records" if $debug; -foreach my $i (1 .. $rs->size()) { - my $xml = render_record($rs, $i-1, "zeerex"); +foreach my $i ( 1 .. $rs->size() ) { + my $xml = render_record( $rs, $i - 1, "zeerex" ); my $rec = $spy->{libxml}->parse_string($xml)->documentElement(); - ZOOM::IRSpy::_rewrite_zeerex_record($spy->{conn}, $rec); - print STDERR "."; + ZOOM::IRSpy::_rewrite_zeerex_record( $spy->{conn}, $rec ); + print STDERR "." if $debug; } -print STDERR "\nDone\n"; +print STDERR "\nDone\n" if $debug; + -- 1.7.10.4