JBAS-980 local thes. falls back to Other
authorBill Erickson <berickxx@gmail.com>
Thu, 31 Dec 2015 15:55:26 +0000 (07:55 -0800)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
When a controlled field specifies its source as local (ind2=7), consider
a link to an authority record whose thesaurus value is z=Other as always
valid.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
KCLS/linking/authority_control_fields.pl

index 9743dd2..837917e 100755 (executable)
@@ -584,25 +584,32 @@ if($input_file) {
        announce("Start $start_time for all records");
 }
 
-# given a set of authority record ID's and a controlled bib field
-# indicator 2 (thesaurus) value, returns the ID of the firs
-# authority record in the set that matches the thesaurus.
+# given a set of authority record ID's and a controlled bib field,
+# returns the ID of the first authority record in the set tha
+# matches the thesaurus spec of the bib record.
 sub find_matching_auth_for_thesaurus {
     my ($e, $bib_field, $auth_ids) = @_;
 
+    # bib field thesaurus spec
     my $cfield_ind2 = $bib_field->indicator(2);
 
     announce("6XX indicator 2 value = $cfield_ind2");
 
+    my $is_local = 0;
     if ($cfield_ind2 eq '7') {
         # subject thesaurus code is embedded in the bib field subfield 2
+        
+        $is_local = 1;
 
         my $thesaurus = $bib_field->subfield('2') || '';
         announce("Found local thesaurus value $thesaurus");
 
-        # if no remapping is found, use 7 == Other.
+        # if we have no special remapping value for the found thesaurus,
+        # fall back to ind2 => 7=Other.
         $cfield_ind2 = $REMAP_BIB_SF2_TO_IND2{$thesaurus} || '7';
-        announce("Local thesaurus '$thesaurus' mapped to ind2 value '$cfield_ind2'");
+
+        announce("Local thesaurus '$thesaurus' ".
+            "remapped to ind2 value '$cfield_ind2'");
     }
 
     my $auth_leaders = $e->json_query({
@@ -611,10 +618,17 @@ sub find_matching_auth_for_thesaurus {
         where => {'+afr' => {tag => '008', record => $auth_ids}}
     });
 
+    my $authz_found = undef;
     for my $leader (@$auth_leaders) {
         my $value = $leader->{value};
         next unless $value;
+
         my $thesaurus = substr($value, 11, 1); # leader/11 -- zero based.
+
+        # Note for later that we encountered an authority record 
+        # whose thesaurus values is z=Other.
+        $authz_found = $leader->{record} if $thesaurus eq 'z';
+
         if ($AUTH_TO_BIB_IND2{$thesaurus} eq $cfield_ind2) {
             announce("Found a match on thesaurus ".
                 "'$thesaurus' for " . $leader->{record});
@@ -622,6 +636,11 @@ sub find_matching_auth_for_thesaurus {
         }
     }
 
+    # If the bib field in question has a locally encoded thesaurus
+    # (ind2=7) and no auth record was found above via remapped 
+    # thesaurus value, use the authority record with thesaurus z=Other.
+    return $authz_found if $is_local;
+
     return undef;
 }