r11526@llin: dpavlin | 2005-12-05 02:21:09 +0100
authorDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 5 Dec 2005 17:47:23 +0000 (17:47 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 5 Dec 2005 17:47:23 +0000 (17:47 +0000)
 index multiple input sources in one database

git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@213 07558da8-63fa-0310-ba24-9fe276d99e06

lib/WebPAC/Output/Estraier.pm
run.pl

index 1b65de4..ba9f067 100644 (file)
@@ -153,9 +153,9 @@ sub add {
        }
 
        my $type = $args->{'type'};
-       my $mfn = $args->{'id'};
+       my $id = $args->{'id'};
 
-       my $uri = "file:///$type/$database/$mfn";
+       my $uri = "file:///$type/$database/$id";
        $log->debug("creating $uri");
 
        my $doc = HyperEstraier::Document->new;
diff --git a/run.pl b/run.pl
index 5a09b6b..231c1de 100755 (executable)
--- a/run.pl
+++ b/run.pl
@@ -24,6 +24,8 @@ print "config = ",Dumper($config);
 
 die "no databases in config file!\n" unless ($config->{databases});
 
+my $total_rows = 0;
+
 while (my ($database, $db_config) = each %{ $config->{databases} }) {
 
        my $type = lc($db_config->{input}->{type});
@@ -43,83 +45,73 @@ while (my ($database, $db_config) = each %{ $config->{databases} }) {
        my $log = $lookup->_get_logger;
        $log->info("working on $database in $db_path");
 
-       my $isis = new WebPAC::Input::ISIS(
-               code_page => $config->{webpac}->{webpac_encoding},
-               limit_mfn => $db_config->{input}->{limit},
-       );
-
-       my $maxmfn = $isis->open(
-               filename => $db_config->{input}->{path},
-               code_page => $db_config->{input}->{encoding},   # database encoding
-       );
-
        my $path = './db/';
 
        my $db = new WebPAC::Store(
                path => $db_path,
        );
 
-       my $n = new WebPAC::Normalize::XML(
-       #       filter => { 'foo' => sub { shift } },
-               db => $db,
-               lookup_regex => $lookup->regex,
-               lookup => $lookup,
-       );
-
-       $n->open(
-               tag => $db_config->{normalize}->{tag},
-               xml_file => $db_config->{normalize}->{path},
-       );
-
-       my $out = new WebPAC::Output::TT(
-               include_path => $config->{webpac}->{template_path},
-               filters => { foo => sub { shift } },
-       );
-
        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->{url}");
+       $log->info("using HyperEstraier URL $est_config->{masterurl}");
 
        my $est = new WebPAC::Output::Estraier(
                %{ $est_config },
        );
 
-       my $total_rows = 0;
-
-       for ( 0 ... $isis->size ) {
+       #
+       # now, iterate through input formats
+       #
 
-               my $row = $isis->fetch || next;
+       my @inputs;
+       if (ref($db_config->{input}) eq 'ARRAY') {
+               @inputs = @{ $db_config->{input} };
+       } else {
+               push @inputs, $db_config->{input};
+       }
 
-               my $mfn = $row->{'000'}->[0] || die "can't find MFN";
+       foreach my $input (@inputs) {
+               $log->info("working on input $input->{path} [$input->{type}]");
 
-               my $ds = $n->data_structure($row);
+               my $isis = new WebPAC::Input::ISIS(
+                       code_page => $config->{webpac}->{webpac_encoding},
+                       limit_mfn => $input->{limit},
+               );
 
-       #       print STDERR Dumper($row, $ds);
+               my $maxmfn = $isis->open(
+                       filename => $input->{path},
+                       code_page => $input->{encoding},        # database encoding
+               );
 
-       #       my $html = $out->apply(
-       #               template => 'html_ffzg.tt',
-       #               data => $ds,
-       #       );
-       #
-       #       # create test output
-       #
-       #       my $file = sprintf('out/%02d.html', $mfn );
-       #       open(my $fh, '>', $file) or die "can't open $file: $!";
-       #       print $fh $html;
-       #       close($fh);
-       #
-       #       $html =~ s#\s*[\n\r]+\s*##gs;
-       #
-       #       print STDERR $html;
+               my $n = new WebPAC::Normalize::XML(
+               #       filter => { 'foo' => sub { shift } },
+                       db => $db,
+                       lookup_regex => $lookup->regex,
+                       lookup => $lookup,
+               );
 
-               $est->add(
-                       id => $mfn,
-                       ds => $ds,
-                       type => $config->{hyperestraier}->{type},
+               $n->open(
+                       tag => $input->{normalize}->{tag},
+                       xml_file => $input->{normalize}->{path},
                );
 
-               $total_rows++;
+               for ( 0 ... $isis->size ) {
+
+                       my $row = $isis->fetch || next;
+
+                       my $mfn = $row->{'000'}->[0] || die "can't find MFN";
+
+                       my $ds = $n->data_structure($row);
+
+                       $est->add(
+                               id => $input->{name} . "#" . $mfn,
+                               ds => $ds,
+                               type => $config->{hyperestraier}->{type},
+                       );
+
+                       $total_rows++;
+               }
 
        };