Bugzilla – Attachment 70948 Details for
Bug 14769
Authorities merge: Set correct indicators in biblio field
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14769: Introduce Koha::Authority::BiblioIndicators
Bug-14769-Introduce-KohaAuthorityBiblioIndicators.patch (text/plain), 4.26 KB, created by
Marcel de Rooy
on 2018-01-26 11:17:26 UTC
(
hide
)
Description:
Bug 14769: Introduce Koha::Authority::BiblioIndicators
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2018-01-26 11:17:26 UTC
Size:
4.26 KB
patch
obsolete
>From 911cc7a11c5e57f956b069f464aaf2a204ac5e8e Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 26 Jan 2018 11:06:59 +0100 >Subject: [PATCH] Bug 14769: Introduce Koha::Authority::BiblioIndicators >Content-Type: text/plain; charset=utf-8 > >--- > Koha/Authority/BiblioIndicators.pm | 126 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 126 insertions(+) > create mode 100644 Koha/Authority/BiblioIndicators.pm > >diff --git a/Koha/Authority/BiblioIndicators.pm b/Koha/Authority/BiblioIndicators.pm >new file mode 100644 >index 0000000..e6d8966 >--- /dev/null >+++ b/Koha/Authority/BiblioIndicators.pm >@@ -0,0 +1,126 @@ >+package Koha::Authority::BiblioIndicators; >+ >+# Copyright 2018 Rijksmuseum >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use Koha::Caches; >+ >+our $cached_indicators; >+ >+sub new { return bless ref($_[1]) ? $_[1] : {}, shift; } >+ >+=head1 NAME >+ >+Koha::Authority::BiblioIndicators - Obtain biblio indicators, controlled by authority record >+ >+=head1 API >+ >+=head2 METHODS >+ >+=cut >+ >+=head3 get >+ >+ $self->get({ >+ auth_record => $record, >+ report_tag => $authtype->auth_tag_to_report, >+ biblio_tag => $tag, >+ flavour => $flavour, >+ }); >+ >+=cut >+ >+sub get { >+ my ( $self, $params ) = @_; >+ my $flavour = $params->{flavour} // q{}; >+ my $tag = $params->{biblio_tag} // q{}; >+ my $record = $params->{auth_record}; >+ my $report_tag = $params->{report_tag} // q{}; >+ >+ _load_config() if !defined $cached_indicators; >+ >+ my $result = {}; >+ return $result if !exists $cached_indicators->{$flavour}; >+ my $rule = $cached_indicators->{$flavour}->{$tag} // >+ $cached_indicators->{$flavour}->{'*'} // >+ {}; >+ my $report_fld = $record ? $record->field( $report_tag ) : undef; >+ >+ foreach my $ind ( 'ind1', 'ind2' ) { >+ if( exists $rule->{$ind} ) { >+ if( !$rule->{$ind} ) { >+ $result->{$ind} = $rule->{$ind}; # undef or empty string >+ } elsif( $rule->{$ind} eq 'auth1' ) { >+ $result->{$ind} = $report_fld->indicator(1) if $report_fld; >+ } elsif( $rule->{$ind} eq 'auth2' ) { >+ $result->{$ind} = $report_fld->indicator(2) if $report_fld; >+ } elsif( $rule->{$ind} eq 'thesaurus' ) { >+ } else { >+ $result->{$ind} = substr( $rule->{$ind}, 0, 1); >+ } >+ } >+ } >+ >+ return $result; >+} >+ >+sub _load_config { >+ my $cache = Koha::Caches->get_instance; >+ my $val; >+ $val = $cache->get_from_cache("auth_controlled_bibind") if $cache; >+ if( $val ) { >+ $cached_indicators = $val; >+ return; >+ } >+ >+ # TODO Load the config file (will be done on report 20...) >+ # This sample makes UNIMARC always fall back to authority indicators. >+ # For MARC21 it only corrects ind1 for 100, 600 and 700 as well as ind2 >+ # for 100 and 600. Other indicators are not touched. >+ $cached_indicators = { >+ UNIMARCAUTH => { >+ '*' => { ind1 => 'auth1', ind2 => 'auth2' }, >+ }, >+ MARC21 => { >+ '100' => { ind1 => 'auth1', ind2 => undef }, >+ '600' => { ind1 => 'auth1', ind2 => 'thesaurus' }, >+ '700' => { ind1 => 'auth1' }, >+ }, >+ }; >+ >+ # Save into cache >+ $cache->set_in_cache( "auth_controlled_bibind", $cached_indicators ) >+ if $cache; >+} >+ >+=head3 clear >+ >+ Clear the cached indicator values >+ >+ $self->clear; >+ >+=cut >+ >+sub clear { >+ $cached_indicators = undef; >+ my $cache = Koha::Caches->get_instance; >+ $cache->clear_from_cache("auth_controlled_bibind"); >+} >+ >+1; >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14769
:
42197
|
69343
|
70948
|
70949
|
70950
|
70951
|
71338
|
71339
|
71340
|
71341
|
71342
|
71343
|
71351
|
71352
|
71353
|
71354
|
71355
|
71366
|
71374
|
71375
|
71376
|
71377
|
71378
|
71379
|
71380
|
71381
|
72398
|
72399
|
72400
|
72401
|
72402
|
72403
|
72404
|
73389
|
73773
|
73774
|
73775
|
73776
|
73777
|
73778
|
73779
|
74052