From: Bill Erickson Date: Thu, 31 Dec 2015 15:55:26 +0000 (-0800) Subject: JBAS-980 local thes. falls back to Other X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=34ff4d5e0e338bfa670ab13aafa8b18c9367d270;p=working%2FEvergreen.git JBAS-980 local thes. falls back to Other 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 --- diff --git a/KCLS/linking/authority_control_fields.pl b/KCLS/linking/authority_control_fields.pl index 9743dd22f4..837917eaf3 100755 --- a/KCLS/linking/authority_control_fields.pl +++ b/KCLS/linking/authority_control_fields.pl @@ -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 first -# 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 that +# 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; }