return 0;
}
+sub update_record {
+ my ($record, $marc) = @_;
+
+ my $xml = $marc->as_xml_record();
+ $xml =~ s/\n//sgo;
+ $xml =~ s/^<\?xml.+\?\s*>//go;
+ $xml =~ s/>\s+</></go;
+ $xml =~ s/\p{Cc}//go;
+ $xml = OpenILS::Application::AppUtils->entityize($xml);
+
+ $record->marc($xml);
+
+ my $editor = OpenILS::Utils::CStoreEditor->new(xact=>1);
+ if ($editor->update_biblio_record_entry($record)) {
+ $editor->commit();
+ } else {
+ $editor->rollback();
+ }
+}
+
foreach my $rec_id (@records) {
announce("processing bib record $rec_id");
foreach my $bib_field (@bib_fields) {
my $sf0 = $bib_field->subfield('0') || '';
+ my $is_fast_heading = is_fast_heading($bib_field);
- if (is_fast_heading($bib_field)) {
- # Ignore all 'fast' headings.
- announce("Skipping FAST on rec=$rec_id and tag=$c_tag \$0 $sf0");
+ if ($is_fast_heading && $sf0 =~ /\)fst/) {
+ # fast heading looks OK. ignore it.
+ announce("Ignoring FAST heading field on ".
+ "rec=$rec_id and tag=$c_tag \$0 $sf0");
next;
}
$changed = 1;
}
+ if ($is_fast_heading) {
+ # Update record after potentially removing a bogus
+ # fast heading above.
+ update_record($record, $marc) if $changed;
+
+ # We don't control fast headings, so there's nothing
+ # left to do. Move on to the next field...
+ announce("No linking performed on FAST heading ".
+ "field on rec=$rec_id and tag=$c_tag");
+ next;
+ }
+
my %match_subfields;
my $match_tag;
my @searches;
}
}
- if ($changed) {
-
- # print $marc->as_formatted();
- my $xml = $marc->as_xml_record();
- $xml =~ s/\n//sgo;
- $xml =~ s/^<\?xml.+\?\s*>//go;
- $xml =~ s/>\s+</></go;
- $xml =~ s/\p{Cc}//go;
- $xml = OpenILS::Application::AppUtils->entityize($xml);
-
- $record->marc($xml);
-
- my $editor = OpenILS::Utils::CStoreEditor->new(xact=>1);
- if ($editor->update_biblio_record_entry($record)) {
- $editor->commit();
- } else {
- $editor->rollback();
- }
- }
+ update_record($record, $marc) if $changed;
+
} otherwise {
my $err = shift;
print STDERR "\nRecord # $rec_id : $err\n";
import MARC::File::XML; # reset SAX parser so that one bad record doesn't kill the entire process
}
}
+
my $end_time = localtime();
if($input_file) {