Bug 33296: Linker should search for authority records with an appropriate 008/14,15,16 value

In an authority record, 008/14 = 'a' says it's appropriate for use as a
main or added entry (1xx, 7xx), 008/15 = 'a' says it's appropriate for
use as a subject entry, and 008/16 = 'a' says it's appropriate for use
as a series entry.

Test plan:
==========
1. Have a standard KTD environment. Have the patches from Bug 38494
   applied.
2. Set AutoLinkBiblios system preference to 'Do', and
   ConsiderHeadingUse to 'Do'.
3. Open an existing bibliographic record and add a new field 650. In
   subfield $a enter 'Application software' (without quotes), and in $x
   'Development.' (with final dot).
4. Save the record. In Normal view control that the entered subject
   heading entry has been linked with the existing authority record (note
   the magnifying glass icon).
5. Apply the patch ; restart all.
6. Repeat p. 3. Note that this time the newly entered subject heading
   entry has not been linked with the existing authority record. This is
   because the authority record has 008/15 = '|' while 'a' is required with
   ConsiderHeadingUse.
7. In Authorities, find the record for 'Application
   software--Development.' Modify it by changing 008/15 to 'a' (Heading
   use--subject added entry).
8. Return to the bibliographic record. Open it in the editor and save.
   The subject heading entry for 'Application software--Development.'
   should now be linked with the existing authority record.

Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Janusz Kaczmarek 2024-11-23 15:42:15 +00:00 committed by Lucas Gass
parent 27230e64ad
commit 082de62252
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
1 changed files with 22 additions and 3 deletions

View File

@ -22,7 +22,7 @@ use Modern::Perl;
use MARC::Field;
use C4::Context;
use Module::Load qw( load );
use List::Util qw( none );
use List::Util qw( none first );
=head1 NAME
@ -210,6 +210,25 @@ sub _search {
push @value, $thesaurus;
}
if ( C4::Context->preference('ConsiderHeadingUse') ) {
my $marcflavour = C4::Context->preference('marcflavour');
my $biblio_tag = $self->{'field'}->tag;
if ( $marcflavour eq 'MARC21' ) {
my $heading_use_search_field =
$biblio_tag =~ /^[127]/ ? 'Heading-use-main-or-added-entry'
: $biblio_tag =~ /^6/ ? 'Heading-use-subject-added-entry'
: $biblio_tag =~ /^[48]/ ? 'Heading-use-series-added-entry'
: undef;
if ($heading_use_search_field) {
push @marclist, $heading_use_search_field;
push @and_or, 'and';
push @excluding, '';
push @operator, 'is';
push @value, 'a';
}
}
}
require Koha::SearchEngine::QueryBuilder;
require Koha::SearchEngine::Search;
@ -240,8 +259,8 @@ sub _search {
)
)
{
pop @value;
push @value, 'notdefined';
my $thesaurus_idx = first { $marclist[$_] eq 'thesaurus' } 0 .. $#marclist;
$value[$thesaurus_idx] = 'notdefined';
$search_query = $builder->build_authorities_query_compat(
\@marclist, \@and_or,
\@excluding, \@operator, \@value, $self->{'auth_type'},