removed unncessary schema declared on column and fixed issue where value needed was...
[migration-tools.git] / eg_staged_bib_overlay
index 1755ada..4df0cde 100755 (executable)
@@ -33,7 +33,7 @@ my $dbpw;
 my $dbhost;
 my $batch;
 my $cutoff;
-my $wait = 1;
+my $wait = 0;
 my $output;
 my $link_skipped;
 
@@ -281,14 +281,19 @@ sub handle_stage_bibs {
             $dbh->commit;
             $dbh->begin_work;
         }
-        my $marc = MARC::Record->new_from_usmarc($_);
-        my $bibid = $marc->subfield('901', 'c');
-        if ($bibid !~ /^\d+$/) {
-            print STDERR "Record $i is suspect; skipping\n";
+        eval {
+            my $marc = MARC::Record->new_from_usmarc($_);
+            my $bibid = $marc->subfield('901', 'c');
+            if ($bibid !~ /^\d+$/) {
+                die('Subfield 901$c is not numeric or missing.');
+            }
+            my $xml = OpenILS::Application::AppUtils->entityize($marc->as_xml_record());
+            $ins->execute($xml, $bibid);
+        };
+        if ($@) {
+            warn("Record $i is bad: $@; skipping.");
             next;
         }
-        my $xml = OpenILS::Application::AppUtils->entityize($marc->as_xml_record());
-        $ins->execute($xml, $bibid);
     }
     $dbh->commit;
     report_progress("Records staged", $i) if 0 != $i % 100;
@@ -399,7 +404,7 @@ sub handle_load_bibs {
             )
         });
         $dbh->commit;
-        sleep $wait;
+        sleep $wait if ($wait);
     }
 }
 
@@ -445,25 +450,31 @@ sub handle_stage_auths {
             $dbh->commit;
             $dbh->begin_work;
         }
-        my $marc = MARC::Record->new_from_usmarc($_);
-        my $authid = $marc->subfield('901', 'c');
-        if (defined($authid) && $authid !~ /^\d+$/) {
-            undef $authid;
-        }
-        my $lccn = $marc->subfield('010', 'a');
-        if (defined $lccn) {
-            $lccn =~ s/^\s+//;
-            $lccn =~ s/\s+$//;
-            $lccn =~ s/\s+/ /g;
-        }
-        my $cancelled_lccn = $marc->subfield('010', 'z');
-        if (defined $cancelled_lccn) {
-            $cancelled_lccn =~ s/^\s+//;
-            $cancelled_lccn =~ s/\s+$//;
-            $cancelled_lccn =~ s/\s+/ /g;
+        eval {
+            my $marc = MARC::Record->new_from_usmarc($_);
+            my $authid = $marc->subfield('901', 'c');
+            if (defined($authid) && $authid !~ /^\d+$/) {
+                undef $authid;
+            }
+            my $lccn = $marc->subfield('010', 'a');
+            if (defined $lccn) {
+                $lccn =~ s/^\s+//;
+                $lccn =~ s/\s+$//;
+                $lccn =~ s/\s+/ /g;
+            }
+            my $cancelled_lccn = $marc->subfield('010', 'z');
+            if (defined $cancelled_lccn) {
+                $cancelled_lccn =~ s/^\s+//;
+                $cancelled_lccn =~ s/\s+$//;
+                $cancelled_lccn =~ s/\s+/ /g;
+            }
+            my $xml = OpenILS::Application::AppUtils->entityize($marc->as_xml_record());
+            $ins->execute($xml, $authid, $lccn, $cancelled_lccn, $xml);
+        };
+        if ($@) {
+            warn("Record $i is bad: $@; skipping.");
+            next;
         }
-        my $xml = OpenILS::Application::AppUtils->entityize($marc->as_xml_record());
-        $ins->execute($xml, $authid, $lccn, $cancelled_lccn, $xml);
     }
     $dbh->commit;
     report_progress("Records staged", $i) if 0 != $i % 100;