From fc0eb0f35468056157e51517b27b97cdafb8ada4 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Mon, 20 Aug 2018 09:51:55 +0300 Subject: [PATCH] Bug 11175: Show record component parts in the detail view Shows the component records of a host on the host intranet detail view, with clickable links to the component records. Host has no linking entries to the components, but the components link to the host record via 773$w. Adds a new search index, Control-number-identifier (aka cni), which indexes the 003 controlfield. When looking up the component part records, the code searches for records with (773$w=Host001 and 003=Host003) or 773$w='Host003 Host001'. Does not use easyanalytics. Only for MARC21 biblios - MARC21 holdings and UNIMARC indexdefs haven't been updated. Only for the intranet detail page. Staff-client.css has not been recreated, so you need to sass that Test plan: 1) perl bulkmarcimport -file /tmp/easypiano.mrc -m MARCXML 2) rebuild the zebra biblio index 3) Search for "easy piano" in staff client, and go to the biblio detail page. You should see a list of component part records on the detail page. Signed-off-by: Pasi Kallinen --- C4/Search.pm | 2 + C4/XSLT.pm | 19 ++++++- Koha/Biblio.pm | 41 ++++++++++++++ Koha/QueryParser/Driver/PQF.pm | 2 + etc/searchengine/queryparser.yaml | 10 ++++ etc/zebradb/biblios/etc/bib1.att | 1 + etc/zebradb/ccl.properties | 3 + .../marc21/biblios/biblio-koha-indexdefs.xml | 3 + .../marc21/biblios/biblio-zebra-indexdefs.xsl | 5 ++ .../intranet-tmpl/prog/css/src/staff-global.scss | 8 +++ .../prog/en/xslt/MARC21slim2intranetDetail.xsl | 2 + .../intranet-tmpl/prog/en/xslt/MARC21slimUtils.xsl | 66 ++++++++++++++++++++++ t/QueryParser.t | 2 +- 13 files changed, 162 insertions(+), 2 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index 06e837de03..5f6020cf8a 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1119,6 +1119,8 @@ sub getIndexes{ 'Conference-name-seealso', 'Content-type', 'Control-number', + 'Control-number-identifier', + 'cni', 'copydate', 'Corporate-name', 'Corporate-name-heading', diff --git a/C4/XSLT.pm b/C4/XSLT.pm index bf2647ab74..1029a45a47 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -243,7 +243,24 @@ sub XSLTParse4Display { my $itemsxml = buildKohaItemsNamespace($biblionumber, $hidden_items); my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour')); - $xmlrecord =~ s/\<\/record\>/$itemsxml$sysxml\<\/record\>/; + my $partsxml = ''; + # Add component part records only for Detail view + if ( $xslsyspref =~ m/Details/ ) { + my $biblio = Koha::Biblios->find( $biblionumber ); + if ( $biblio->components() ) { + my @componentPartRecordXML = (''); + for my $cb ( @{ $biblio->components() } ) { + # Remove the xml header + $cb =~ s/^<\?xml.*?\?>//; + push @componentPartRecordXML, decode('utf8', $cb); + } + push @componentPartRecordXML, ''; + + $partsxml = join "\n", @componentPartRecordXML; + } + } + + $xmlrecord =~ s/\<\/record\>/$itemsxml$sysxml$partsxml\<\/record\>/; if ($fixamps) { # We need to correct the HTML entities that Zebra outputs $xmlrecord =~ s/\&amp;/\&/g; $xmlrecord =~ s/\&\;lt\;/\<\;/g; diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 1dca4d9cf6..1c54620354 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -36,6 +36,8 @@ use Koha::IssuingRules; use Koha::Item::Transfer::Limits; use Koha::Libraries; use Koha::Subscriptions; +use Koha::SearchEngine; +use Koha::SearchEngine::Search; =head1 NAME @@ -386,6 +388,45 @@ sub biblioitem { return $self->{_biblioitem}; } +=head3 components + +my $components = $self->components(); + +Returns an array of MARCXML data, which are component parts of +this object (MARC21 773$w points to this) + +=cut + +sub components { + my ($self) = @_; + + return undef if (C4::Context->preference('marcflavour') ne 'MARC21'); + + if (!defined($self->{_components})) { + my $marc = C4::Biblio::GetMarcBiblio({ biblionumber => $self->id }); + my $pf001 = $marc->field('001') || undef; + my $pf003 = $marc->field('003') || undef; + + my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX}); + + if (defined($pf001)) { + # search for (773$w='Host001' and 003='Host003') or 773$w='Host003 Host001') + my $searchstr = "(rcn='".$pf001->data()."'"; + $searchstr .= " and cni='".$pf003->data()."'" if (defined($pf003)); + $searchstr .= ")"; + $searchstr .= " or rcn='".$pf003->data()." ".$pf001->data()."'" if (defined($pf003)); + + my ( $errors, $results, $total_hits ) = $searcher->simple_search_compat( $searchstr, 0, undef ); + + $self->{_components} = $results if ( defined($results) && scalar(@$results) ); + } else { + warn "Record $self->id has no 001"; + } + } + + return $self->{_components}; +} + =head3 subscriptions my $subscriptions = $self->subscriptions diff --git a/Koha/QueryParser/Driver/PQF.pm b/Koha/QueryParser/Driver/PQF.pm index 8181cd3dd1..3cc277aa90 100644 --- a/Koha/QueryParser/Driver/PQF.pm +++ b/Koha/QueryParser/Driver/PQF.pm @@ -727,6 +727,8 @@ sub TEST_SETUP { $self->add_search_field_alias( 'keyword' => 'note' => 'nt' ); $self->add_bib1_field_map('keyword' => 'record-control-number' => 'biblioserver' => { '1' => '1045' } ); $self->add_search_field_alias( 'keyword' => 'record-control-number' => 'rcn' ); + $self->add_bib1_field_map('keyword' => 'control-number-identifier' => 'biblioserver' => { '1' => '9014' } ); + $self->add_search_field_alias( 'keyword' => 'control-number-identifier' => 'cni' ); $self->add_bib1_field_map('subject' => '' => 'biblioserver' => { '1' => '21' } ); $self->add_search_field_alias( 'subject' => '' => 'su' ); $self->add_search_field_alias( 'subject' => '' => 'su-to' ); diff --git a/etc/searchengine/queryparser.yaml b/etc/searchengine/queryparser.yaml index d9f637bfd3..174c935571 100644 --- a/etc/searchengine/queryparser.yaml +++ b/etc/searchengine/queryparser.yaml @@ -321,6 +321,16 @@ field_mappings: aliases: - control-number label: Control-number + control-number-identifier: + bib1_mapping: + biblioserver: + 1: 9014 + enabled: 1 + index: control-number-identifier + aliases: + - control-number-identifier + - cni + label: Control-number-identifier copynumber: bib1_mapping: biblioserver: diff --git a/etc/zebradb/biblios/etc/bib1.att b/etc/zebradb/biblios/etc/bib1.att index 7acdc1816b..dc64854226 100644 --- a/etc/zebradb/biblios/etc/bib1.att +++ b/etc/zebradb/biblios/etc/bib1.att @@ -221,6 +221,7 @@ att 9010 cn-suffix att 9011 Suppress att 9012 Identifier-other att 9013 not-onloan-count +att 9014 Control-number-identifier # Items Index att 8001 withdrawn diff --git a/etc/zebradb/ccl.properties b/etc/zebradb/ccl.properties index a1ea690c43..420294a8d8 100644 --- a/etc/zebradb/ccl.properties +++ b/etc/zebradb/ccl.properties @@ -996,6 +996,9 @@ llength 1=llength Summary 1=Summary not-onloan-count 1=9013 4=109 +Control-number-identifier 1=9014 +cni Control-number-identifier + ### # Items Index withdrawn 1=8001 diff --git a/etc/zebradb/marc_defs/marc21/biblios/biblio-koha-indexdefs.xml b/etc/zebradb/marc_defs/marc21/biblios/biblio-koha-indexdefs.xml index b3b12a0e2b..24e2a1b193 100644 --- a/etc/zebradb/marc_defs/marc21/biblios/biblio-koha-indexdefs.xml +++ b/etc/zebradb/marc_defs/marc21/biblios/biblio-koha-indexdefs.xml @@ -16,6 +16,9 @@ Control-number:w + + Control-number-identifier:w + Date/time-last-modified:w diff --git a/etc/zebradb/marc_defs/marc21/biblios/biblio-zebra-indexdefs.xsl b/etc/zebradb/marc_defs/marc21/biblios/biblio-zebra-indexdefs.xsl index c5fed3e859..2db2c7737b 100644 --- a/etc/zebradb/marc_defs/marc21/biblios/biblio-zebra-indexdefs.xsl +++ b/etc/zebradb/marc_defs/marc21/biblios/biblio-zebra-indexdefs.xsl @@ -62,6 +62,11 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml) + + + + + diff --git a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss index 8af60e2809..e72efc1ba0 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -707,6 +707,14 @@ ol { padding: 7px 0; } +.componentPartRecordsContainer { + float: right; + overflow-y: auto; + overflow-x: hidden; + max-width: 50%; + max-height: 25em; +} + #editions { table, td { diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl index 9727767dbb..9bc08b9ac6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl +++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl @@ -110,6 +110,8 @@ + +

diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slimUtils.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slimUtils.xsl index a3db596e87..4beda2edf3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slimUtils.xsl +++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slimUtils.xsl @@ -338,6 +338,72 @@ + + + + + + +