JBAS-980 bib linking minor repairs and logging updates
authorBill Erickson <berickxx@gmail.com>
Fri, 20 Nov 2015 16:57:05 +0000 (08:57 -0800)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
KCLS/linking/authority_control_fields.pl

index 230e9a3..577fedb 100755 (executable)
@@ -592,7 +592,9 @@ if($input_file) {
 sub find_matching_auth_for_thesaurus {
     my ($e, $bib_field, $auth_ids) = @_;
 
-    my $cfield_ind2 = $bib_field->indicator(2) || '';
+    my $cfield_ind2 = $bib_field->indicator(2);
+
+    announce("6XX indicator 2 value = $cfield_ind2");
 
     if ($cfield_ind2 eq '7') {
         # subject thesaurus code is embedded in the bib field subfield 2
@@ -600,9 +602,9 @@ sub find_matching_auth_for_thesaurus {
         my $thesaurus = $bib_field->subfield('2') || '';
         announce("Found local thesaurus value $thesaurus");
 
-        $cfield_ind2 = $BIB_SF2_TO_AUTH{$thesaurus} || '';
+        $cfield_ind2 = $BIB_SF2_TO_AUTH{$thesaurus};
 
-        if ($cfield_ind2) {
+        if (defined $cfield_ind2) {
             announce("Mapped local thesaurus '$thesaurus' to '$cfield_ind2'");
         } else {
             announce("No mapping found for local thesaurus '$thesaurus'");
@@ -620,8 +622,11 @@ sub find_matching_auth_for_thesaurus {
         my $value = $leader->{value};
         next unless $value;
         my $thesaurus = substr($value, 11, 1); # leader/11 -- zero based.
-        return $leader->{record} if
-            $AUTH_TO_BIB_IND2{$thesaurus} eq $cfield_ind2;
+        if ($AUTH_TO_BIB_IND2{$thesaurus} eq $cfield_ind2) {
+            announce("Found a match on thesaurus ".
+                "'$thesaurus' for " . $leader->{record});
+            return $leader->{record};
+        }
     }
 
     return undef;
@@ -645,7 +650,6 @@ foreach my $rec_id (@records) {
 
         foreach my $c_tag (@c_fields) {
             my @c_subfields = keys %{$controllees{"$c_tag"}};
-            announce "Inspecting controlled field $c_tag";
 
             # Get the MARCXML from the record and check for controlled fields/subfields
             my @bib_fields = ($marc->field($c_tag));
@@ -673,8 +677,8 @@ foreach my $rec_id (@records) {
                 }
                 next if !$match_tag;
 
-                announce("Searching for matches (auth tag=$match_tag): \n\t".  
-                    Dumper(\@searches));
+                announce("Searching for matches on controlled field $c_tag ".
+                    "(auth tag=$match_tag): \n - ".Dumper(\@searches));
 
                 my @tags = ($match_tag);