7 |
use Data::Dumper; |
use Data::Dumper; |
8 |
use lib './lib'; |
use lib './lib'; |
9 |
|
|
10 |
|
use WebPAC::Common 0.02; |
11 |
use WebPAC::Lookup; |
use WebPAC::Lookup; |
12 |
use WebPAC::Input::ISIS; |
use WebPAC::Input::ISIS; |
13 |
use WebPAC::Store 0.03; |
use WebPAC::Store 0.03; |
14 |
use WebPAC::Normalize::XML; |
use WebPAC::Normalize::XML; |
15 |
use WebPAC::Output::TT; |
use WebPAC::Output::TT; |
16 |
use WebPAC::Output::Estraier 0.02; |
use WebPAC::Output::Estraier 0.05; |
17 |
use YAML qw/LoadFile/; |
use YAML qw/LoadFile/; |
18 |
use LWP::Simple; |
use LWP::Simple; |
19 |
|
|
29 |
|
|
30 |
while (my ($database, $db_config) = each %{ $config->{databases} }) { |
while (my ($database, $db_config) = each %{ $config->{databases} }) { |
31 |
|
|
32 |
my $type = lc($db_config->{input}->{type}); |
my $log = _new WebPAC::Common()->_get_logger(); |
33 |
|
|
34 |
die "I know only how to handle input type isis, not '$type'!\n" unless ($type eq 'isis'); |
# |
35 |
|
# open Hyper Estraier database |
36 |
|
# |
37 |
|
|
38 |
my $abs_path = abs_path($0); |
my $est_config = $config->{hyperestraier} || $log->logdie("can't find 'hyperestraier' part in confguration"); |
39 |
$abs_path =~ s#/[^/]*$#/#; |
$est_config->{database} = $database; |
40 |
|
|
41 |
|
$log->info("using HyperEstraier URL $est_config->{masterurl}"); |
42 |
|
|
43 |
my $lookup = new WebPAC::Lookup( |
my $est = new WebPAC::Output::Estraier( |
44 |
lookup_file => $db_config->{input}->{lookup}, |
%{ $est_config }, |
45 |
); |
); |
46 |
|
|
47 |
my $db_path = $config->{webpac}->{db_path} . '/' . $database; |
# |
48 |
|
# now WebPAC::Store |
49 |
|
# |
50 |
|
my $abs_path = abs_path($0); |
51 |
|
$abs_path =~ s#/[^/]*$#/#; |
52 |
|
|
53 |
|
my $db_path = $config->{webpac}->{db_path} . '/' . $database; |
54 |
|
|
|
my $log = $lookup->_get_logger; |
|
55 |
$log->info("working on $database in $db_path"); |
$log->info("working on $database in $db_path"); |
56 |
|
|
57 |
my $db = new WebPAC::Store( |
my $db = new WebPAC::Store( |
58 |
path => $db_path, |
path => $db_path, |
59 |
database => $database, |
database => $database, |
60 |
|
debug => 1, |
61 |
); |
); |
62 |
|
|
|
my $est_config = $config->{hyperestraier} || $log->logdie("can't find 'hyperestraier' part in confguration"); |
|
|
$est_config->{database} = $database; |
|
|
|
|
|
$log->info("using HyperEstraier URL $est_config->{masterurl}"); |
|
|
|
|
|
my $est = new WebPAC::Output::Estraier( |
|
|
%{ $est_config }, |
|
|
); |
|
63 |
|
|
64 |
# |
# |
65 |
# now, iterate through input formats |
# now, iterate through input formats |
68 |
my @inputs; |
my @inputs; |
69 |
if (ref($db_config->{input}) eq 'ARRAY') { |
if (ref($db_config->{input}) eq 'ARRAY') { |
70 |
@inputs = @{ $db_config->{input} }; |
@inputs = @{ $db_config->{input} }; |
71 |
} else { |
} elsif ($db_config->{input}) { |
72 |
push @inputs, $db_config->{input}; |
push @inputs, $db_config->{input}; |
73 |
|
} else { |
74 |
|
$log->info("database $database doesn't have inputs defined"); |
75 |
} |
} |
76 |
|
|
77 |
foreach my $input (@inputs) { |
foreach my $input (@inputs) { |
78 |
|
|
79 |
|
print Dumper($input); |
80 |
|
|
81 |
|
my $type = lc($input->{type}); |
82 |
|
|
83 |
|
die "I know only how to handle input type isis, not '$type'!\n" unless ($type eq 'isis'); |
84 |
|
|
85 |
|
my $lookup = new WebPAC::Lookup( |
86 |
|
lookup_file => $input->{lookup}, |
87 |
|
); |
88 |
|
|
89 |
$log->info("working on input $input->{path} [$input->{type}]"); |
$log->info("working on input $input->{path} [$input->{type}]"); |
90 |
|
|
91 |
my $isis = new WebPAC::Input::ISIS( |
my $isis = new WebPAC::Input::ISIS( |
92 |
code_page => $config->{webpac}->{webpac_encoding}, |
code_page => $config->{webpac}->{webpac_encoding}, |
93 |
limit_mfn => $input->{limit}, |
limit_mfn => $input->{limit}, |
94 |
|
lookup => $lookup, |
95 |
); |
); |
96 |
|
|
97 |
my $maxmfn = $isis->open( |
my $maxmfn = $isis->open( |
104 |
db => $db, |
db => $db, |
105 |
lookup_regex => $lookup->regex, |
lookup_regex => $lookup->regex, |
106 |
lookup => $lookup, |
lookup => $lookup, |
107 |
|
prefix => $input->{name}, |
108 |
); |
); |
109 |
|
|
110 |
$n->open( |
$n->open( |
132 |
}; |
}; |
133 |
|
|
134 |
$log->info("$total_rows records indexed"); |
$log->info("$total_rows records indexed"); |
135 |
|
|
136 |
|
# |
137 |
|
# add Hyper Estraier links to other databases |
138 |
|
# |
139 |
|
if (ref($db_config->{links}) eq 'ARRAY') { |
140 |
|
foreach my $link (@{ $db_config->{links} }) { |
141 |
|
$log->info("adding link $database -> $link->{to} [$link->{credit}]"); |
142 |
|
$est->add_link( |
143 |
|
from => $database, |
144 |
|
to => $link->{to}, |
145 |
|
credit => $link->{credit}, |
146 |
|
); |
147 |
|
} |
148 |
|
} |
149 |
|
|
150 |
} |
} |
151 |
|
|