r1312@llin: dpavlin | 2007-08-23 22:28:19 +0200
authorDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 23 Aug 2007 20:28:10 +0000 (20:28 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 23 Aug 2007 20:28:10 +0000 (20:28 +0000)
 added generic output handler to run.pl (if this design proves itself, I will
 port all output to it)

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

conf/llin.yml
conf/log.conf
run.pl

index f50399e..83bae3a 100644 (file)
@@ -333,3 +333,18 @@ databases:
       normalize:
         path: 'conf/normalize/common.pl'
 #      mapping_path: 'conf/input/dbf/cas2000.yml'
+
+  exhibit:
+    name: 'SMILE Exhibit based ouptput for WebPAC'
+    input:
+      name: 'FFZG - Psihologija'
+      type: marc
+      path: 'ps.marc'
+      encoding: 'cp852'
+      #limit: 100
+      normalize:
+        path: 'conf/normalize/json.pl'
+    output:
+      module: 'JSON'
+      path: 'out/exhibit/ps.js'
+
index a51161c..78cc380 100644 (file)
@@ -47,6 +47,8 @@ log4perl.rootLogger=INFO, LOG, SCREEN
 
 #log4perl.logger.WebPAC.Output.TT=DEBUG
 #log4perl.logger.WebPAC.Output.Estraier=DEBUG
+log4perl.logger.WebPAC.Output.JSON=DEBUG
+#
 #log4perl.logger.WebPAC.Search.Estraier=DEBUG
 
 #log4perl.logger.WebPAC.Common=DEBUG
diff --git a/run.pl b/run.pl
index 0198730..27fc11f 100755 (executable)
--- a/run.pl
+++ b/run.pl
@@ -299,7 +299,7 @@ foreach my $database ( sort keys %{ $config->databases } ) {
        # now WebPAC::Store
        #
        my $abs_path = abs_path($0);
-       $abs_path =~ s#/[^/]*$#/#;
+       $abs_path =~ s#/[^/]*$#/#;      #
 
        my $db_path = $config->webpac('db_path');
 
@@ -315,6 +315,20 @@ foreach my $database ( sort keys %{ $config->databases } ) {
                debug => $debug,
        );
 
+       #
+       # prepare output
+       #
+       my @outputs;
+       if (defined( $db_config->{output} )) {
+               my $module = $db_config->{output}->{module} || $log->logdie("need module in output section of $database");
+               $module = 'WebPAC::Output::' . $module unless $module =~ m/::/;
+               $log->debug("loading output module $module");
+               eval "require $module";
+               my $out = new $module->new( $db_config->{output} );
+               $out->init;
+               push @outputs, $out;
+       }
+
 
        #
        # now, iterate through input formats
@@ -507,7 +521,7 @@ foreach my $database ( sort keys %{ $config->databases } ) {
 
                        my $mfn = $row->{'000'}->[0];
 
-                       if (! $mfn || $mfn !~ m#^\d+$#) {
+                       if (! $mfn || $mfn !~ m{^\d+$}) {
                                $log->warn("record $pos doesn't have valid MFN but '$mfn', using $pos");
                                $mfn = $pos;
                                push @{ $row->{'000'} }, $pos;
@@ -569,6 +583,13 @@ foreach my $database ( sort keys %{ $config->databases } ) {
 
                                $log->info("Created $i instances of MFN $mfn\n") if ($i > 1);
                        }
+
+                       foreach my $out ( @outputs ) {
+                               if ( $out->can('add') ) {
+                                       $out->add( $mfn, $ds );
+                               }
+                       }
+
                }
 
                if ($validate) {