/[webpac2]/trunk/run.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/run.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 210 by dpavlin, Mon Dec 5 17:47:04 2005 UTC revision 251 by dpavlin, Thu Dec 15 14:12:00 2005 UTC
# Line 24  print "config = ",Dumper($config); Line 24  print "config = ",Dumper($config);
24    
25  die "no databases in config file!\n" unless ($config->{databases});  die "no databases in config file!\n" unless ($config->{databases});
26    
27  while (my ($database, $db_config) = each %{ $config->{databases} }) {  my $total_rows = 0;
   
         my $type = lc($db_config->{input}->{type});  
28    
29          die "I know only how to handle input type isis, not '$type'!\n" unless ($type eq 'isis');  while (my ($database, $db_config) = each %{ $config->{databases} }) {
30    
31          my $abs_path = abs_path($0);          my $abs_path = abs_path($0);
32          $abs_path =~ s#/[^/]*$#/#;          $abs_path =~ s#/[^/]*$#/#;
33    
         my $lookup = new WebPAC::Lookup(  
                 lookup_file => $db_config->{input}->{lookup},  
         );  
   
34          my $db_path = $config->{webpac}->{db_path} . '/' . $database;          my $db_path = $config->{webpac}->{db_path} . '/' . $database;
35    
   
         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/';  
   
36          my $db = new WebPAC::Store(          my $db = new WebPAC::Store(
37                  path => $db_path,                  path => $db_path,
38                    database => $database,
39                    debug => 1,
40          );          );
41    
42          my $n = new WebPAC::Normalize::XML(          my $log = $db->_get_logger;
43          #       filter => { 'foo' => sub { shift } },          $log->info("working on $database in $db_path");
                 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 } },  
         );  
44    
45          my $est_config = $config->{hyperestraier} || $log->logdie("can't find 'hyperestraier' part in confguration");          my $est_config = $config->{hyperestraier} || $log->logdie("can't find 'hyperestraier' part in confguration");
46          $est_config->{database} = $database;          $est_config->{database} = $database;
47    
48          $log->info("using HyperEstraier URL $est_config->{url}");          $log->info("using HyperEstraier URL $est_config->{masterurl}");
49    
50          my $est = new WebPAC::Output::Estraier(          my $est = new WebPAC::Output::Estraier(
51                  %{ $est_config },                  %{ $est_config },
52          );          );
53    
54          my $total_rows = 0;          #
55            # now, iterate through input formats
56            #
57    
58          for ( 0 ... $isis->size ) {          my @inputs;
59            if (ref($db_config->{input}) eq 'ARRAY') {
60                    @inputs = @{ $db_config->{input} };
61            } else {
62                    push @inputs, $db_config->{input};
63            }
64    
65                  my $row = $isis->fetch || next;          foreach my $input (@inputs) {
66    
67                  my $mfn = $row->{'000'}->[0] || die "can't find MFN";                  my $type = lc($input->{type});
68    
69                  my $ds = $n->data_structure($row);                  die "I know only how to handle input type isis, not '$type'!\n" unless ($type eq 'isis');
70    
71          #       print STDERR Dumper($row, $ds);                  my $lookup = new WebPAC::Lookup(
72                            lookup_file => $input->{lookup},
73                    );
74    
75          #       my $html = $out->apply(                  $log->info("working on input $input->{path} [$input->{type}]");
         #               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;  
76    
77                  $est->add(                  my $isis = new WebPAC::Input::ISIS(
78                          id => $mfn,                          code_page => $config->{webpac}->{webpac_encoding},
79                          ds => $ds,                          limit_mfn => $input->{limit},
80                          type => $config->{hyperestraier}->{type},                          lookup => $lookup,
81                  );                  );
82    
83                  $total_rows++;                  my $maxmfn = $isis->open(
84                            filename => $input->{path},
85                            code_page => $input->{encoding},        # database encoding
86                    );
87    
88    $log->info( Dumper($lookup->{_lookup_data}) );
89    
90                    my $n = new WebPAC::Normalize::XML(
91                    #       filter => { 'foo' => sub { shift } },
92                            db => $db,
93                            lookup_regex => $lookup->regex,
94                            lookup => $lookup,
95                            prefix => $input->{name},
96                    );
97    
98                    $n->open(
99                            tag => $input->{normalize}->{tag},
100                            xml_file => $input->{normalize}->{path},
101                    );
102    
103                    for ( 0 ... $isis->size ) {
104    
105                            my $row = $isis->fetch || next;
106    
107                            my $mfn = $row->{'000'}->[0] || die "can't find MFN";
108    
109                            my $ds = $n->data_structure($row);
110    
111                            $est->add(
112                                    id => $input->{name} . "#" . $mfn,
113                                    ds => $ds,
114                                    type => $config->{hyperestraier}->{type},
115                            );
116    
117                            $total_rows++;
118                    }
119    
120          };          };
121    

Legend:
Removed from v.210  
changed lines
  Added in v.251

  ViewVC Help
Powered by ViewVC 1.1.26