r1454@llin: dpavlin | 2007-11-02 00:39:10 +0100
authorDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 2 Nov 2007 10:54:42 +0000 (10:54 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 2 Nov 2007 10:54:42 +0000 (10:54 +0000)
 check if normalization produce any data_sctructure, and complain if it isn't

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

run.pl

diff --git a/run.pl b/run.pl
index df6a94b..f0162f2 100755 (executable)
--- a/run.pl
+++ b/run.pl
@@ -543,7 +543,7 @@ warn '## output = ',dump( $output );
                                next;   # validation doesn't create any output
                        }
 
-                       my $ds = WebPAC::Normalize::data_structure(
+                       if ( my $ds = WebPAC::Normalize::data_structure(
                                row => $row,
                                rules => $rules,
                                lookup => $lookup_hash,
@@ -557,41 +557,45 @@ warn '## output = ',dump( $output );
                                                id => $mfn,
                                        );
                                },
-                       );
+                       ) ) { # if
 
-                       $log->debug("ds = ", sub { dump($ds) }) if ($ds);
-
-                       $store->save_ds(
-                               database => $database,
-                               input => $input_name,
-                               id => $mfn,
-                               ds => $ds,
-                       ) if ($ds && !$stats);
-
-                       $indexer->add(
-                               id => "${input_name}/${mfn}",
-                               ds => $ds,
-                               type => $config->get($indexer_config)->{type},
-                       ) if ($indexer && $ds);
-
-                       if ($marc) {
-                               my $i = 0;
-
-                               while (my $fields = WebPAC::Normalize::_get_marc_fields( fetch_next => 1 ) ) {
-                                       $marc->add(
-                                               id => $mfn . ( $i ? "/$i" : '' ),
-                                               fields => $fields,
-                                               leader => WebPAC::Normalize::_get_marc_leader(),
-                                               row => $row,
-                                       );
-                                       $i++;
+                               $log->debug("ds = ", sub { dump($ds) });
+
+                               $store->save_ds(
+                                       database => $database,
+                                       input => $input_name,
+                                       id => $mfn,
+                                       ds => $ds,
+                               ) if !$stats;
+
+                               $indexer->add(
+                                       id => "${input_name}/${mfn}",
+                                       ds => $ds,
+                                       type => $config->get($indexer_config)->{type},
+                               ) if $indexer;
+
+                               if ($marc) {
+                                       my $i = 0;
+
+                                       while (my $fields = WebPAC::Normalize::_get_marc_fields( fetch_next => 1 ) ) {
+                                               $marc->add(
+                                                       id => $mfn . ( $i ? "/$i" : '' ),
+                                                       fields => $fields,
+                                                       leader => WebPAC::Normalize::_get_marc_leader(),
+                                                       row => $row,
+                                               );
+                                               $i++;
+                                       }
+
+                                       $log->info("Created $i instances of MFN $mfn\n") if ($i > 1);
                                }
 
-                               $log->info("Created $i instances of MFN $mfn\n") if ($i > 1);
-                       }
+                               foreach my $out ( @output_modules ) {
+                                       $out->add( $mfn, $ds ) if $out->can('add');
+                               }
 
-                       foreach my $out ( @output_modules ) {
-                               $out->add( $mfn, $ds ) if $out->can('add');
+                       } else {
+                               $log->warn("record $pos didn't produce any output after normalization rules!");
                        }
 
                }