1 |
#!/usr/bin/perl -w |
#!/usr/bin/perl -w |
2 |
|
|
3 |
use strict; |
=head1 NAME |
|
use OpenIsis; |
|
|
use Getopt::Std; |
|
|
use Data::Dumper; |
|
|
use XML::Simple; |
|
|
|
|
|
my $config=XMLin(); |
|
|
|
|
|
print Dumper($config); |
|
|
|
|
|
my %opts; |
|
4 |
|
|
5 |
getopts('d:m:q', \%opts); |
all2all.pl - basic script for all WebPAC needs |
6 |
|
|
7 |
my $db_dir = $opts{d}; |
=cut |
8 |
|
|
9 |
die "usage: $0 -d [database_dir] -m [database1,database2] " if (! %opts); |
use strict; |
10 |
|
use Data::Dumper; |
11 |
#-------------------------------------------------------------------- |
use Carp; |
|
|
|
|
my $last_tell=0; |
|
|
|
|
|
my @isis_dirs = ( '.' ); # use dirname as database name |
|
12 |
|
|
13 |
if ($opts{m}) { |
use lib './lib'; |
14 |
@isis_dirs = split(/,/,$opts{m}); |
use WebPAC; |
|
} |
|
15 |
|
|
16 |
my @isis_dbs; |
my $webpac = new WebPAC( |
17 |
|
code_page => 'ISO-8859-2', |
18 |
|
limit_mfn => 500, |
19 |
|
debug => 1, |
20 |
|
) || die; |
21 |
|
|
22 |
|
$|=1; |
23 |
|
|
24 |
|
my $maxmfn = $webpac->open_isis( |
25 |
|
filename => shift @ARGV || '/data/hidra/THS/THS', |
26 |
|
lookup => [ |
27 |
|
{ 'key' => 'd:v900', 'val' => 'v250^a' }, |
28 |
|
# { 'eval' => '"v901^a" eq "Područje"', 'key' => 'pa:v561^4:v562^4:v461^1', 'val' => 'v900' }, |
29 |
|
# { 'eval '=> '"v901^a" eq "Mikrotezaurus"', 'key' => 'a:v561^4:v562^4:v461^1', 'val' => 'v900' }, |
30 |
|
# { 'eval' => '"v901^a" eq "Deskriptor"', 'key' => 'a:v561^4:v562^4:v461^1', 'val' => 'v900' }, |
31 |
|
{ 'key' => 'a:v561^4:v562^4:v461^1', 'val' => 'v900' }, |
32 |
|
], |
33 |
|
); |
34 |
|
|
35 |
|
print "rows: $maxmfn\n\n"; |
36 |
|
|
37 |
|
$webpac->open_import_xml(type => 'isis_hidra_ths'); |
38 |
|
|
39 |
|
while (my $rec = $webpac->fetch_rec) { |
40 |
|
|
41 |
|
my @ds = $webpac->data_structure($rec); |
42 |
|
|
43 |
|
print $webpac->output( |
44 |
|
template => 'text.tt', |
45 |
|
data => \@ds, |
46 |
|
) if (@ds); |
47 |
|
|
|
foreach (@isis_dirs) { |
|
|
if (-e "$common::isis_data/$db_dir/$_/LIBRI") { |
|
|
push @isis_dbs,"$common::isis_data/$db_dir/$_/LIBRI/LIBRI"; |
|
|
} |
|
|
if (-e "$common::isis_data/$db_dir/$_/PERI") { |
|
|
push @isis_dbs,"$common::isis_data/$db_dir/$_/PERI/PERI"; |
|
|
} |
|
|
if (-e "$common::isis_data/$db_dir/$_/AMS") { |
|
|
push @isis_dbs,"$common::isis_data/$db_dir/$_/AMS/AMS"; |
|
|
} |
|
|
if (-e "$common::isis_data/$db_dir/$_/ARTI") { |
|
|
# push @isis_dbs,"$common::isis_data/$db_dir/$_/ARTI/ARTI"; |
|
|
} |
|
48 |
} |
} |
49 |
|
|
50 |
foreach my $isis_db (@isis_dbs) { |
print "## lookup ",Dumper($webpac->{'lookup'}); |
51 |
|
print "## data ",Dumper($webpac->{'data'}); |
|
my $db = OpenIsis::open( "$isis_db" ) || warn "can't open '$isis_db'"; |
|
|
|
|
|
my $max_rowid = OpenIsis::maxRowid( $db ); |
|
|
|
|
|
my $last_pcnt = 0; |
|
|
|
|
|
for (my $row_id = 1; $row_id <= $max_rowid; $row_id++ ) { |
|
|
my $row = OpenIsis::read( $db, $row_id ); |
|
|
|
|
|
# output current process indicator |
|
|
my $pcnt = int($row->{mfn} * 100 / $max_rowid); |
|
|
if ($pcnt != $last_pcnt) { |
|
|
printf STDERR ("%5d / %5d -- %-2d %%\n",$row->{mfn},$max_rowid,$pcnt) if (! $opts{q}); |
|
|
$last_pcnt = $pcnt; |
|
|
} |
|
|
} |
|
|
} |
|