Bugzilla – Attachment 156746 Details for
Bug 34828
Add Koha::Biblio::Metadata::Extractor* classes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34828: Make normalized_oclc uses Koha::Biblio::Metadata::Extractor
Bug-34828-Make-normalizedoclc-uses-KohaBiblioMetad.patch (text/plain), 2.96 KB, created by
Tomás Cohen Arazi (tcohen)
on 2023-10-09 15:02:15 UTC
(
hide
)
Description:
Bug 34828: Make normalized_oclc uses Koha::Biblio::Metadata::Extractor
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2023-10-09 15:02:15 UTC
Size:
2.96 KB
patch
obsolete
>From 891d232ef1d38090b414fc2bfe5480a3630e1d55 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 5 Oct 2023 11:48:59 +0200 >Subject: [PATCH] Bug 34828: Make normalized_oclc uses > Koha::Biblio::Metadata::Extractor > >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Biblio.pm | 2 +- > Koha/Biblio/Metadata/Extractor/MARC/MARC21.pm | 22 +++++++++++++++++++ > .../Biblio/Metadata/Extractor/MARC/MARC21.t | 19 +++++++++++++++- > 3 files changed, 41 insertions(+), 2 deletions(-) > >diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm >index 881e51014ca..86b71517695 100644 >--- a/Koha/Biblio.pm >+++ b/Koha/Biblio.pm >@@ -1321,7 +1321,7 @@ Normalizes and returns the OCLC number found in the MARC record. > sub normalized_oclc { > my ($self) = @_; > my $marc_record = $self->metadata->record; >- return C4::Koha::GetNormalizedOCLCNumber($marc_record); >+ return $self->metadata_extractor->get_normalized_oclc; > } > > =head3 to_api >diff --git a/Koha/Biblio/Metadata/Extractor/MARC/MARC21.pm b/Koha/Biblio/Metadata/Extractor/MARC/MARC21.pm >index 8c4c7343f46..4fe7df8afe5 100644 >--- a/Koha/Biblio/Metadata/Extractor/MARC/MARC21.pm >+++ b/Koha/Biblio/Metadata/Extractor/MARC/MARC21.pm >@@ -74,6 +74,28 @@ sub get_normalized_upc { > } > } > >+=head2 get_normalized_oclc >+ >+ my $normalized_oclc = $extractor->get_normalized_oclc(); >+ >+Returns a normalized OCLC number. >+ >+=cut >+ >+sub get_normalized_oclc { >+ my ($self) = @_; >+ >+ my $record = $self->metadata; >+ my @fields = $record->field('035'); >+ foreach my $field (@fields) { >+ my $oclc = $field->subfield('a'); >+ if ( $oclc && $oclc =~ /OCoLC/ ) { >+ $oclc =~ s/\(OCoLC\)//; >+ return $oclc; >+ } >+ } >+} >+ > =head1 AUTHOR > > Tomas Cohen Arazi, E<lt>tomascohen@theke.ioE<gt> >diff --git a/t/db_dependent/Koha/Biblio/Metadata/Extractor/MARC/MARC21.t b/t/db_dependent/Koha/Biblio/Metadata/Extractor/MARC/MARC21.t >index fcb17b3b514..80211f1271e 100755 >--- a/t/db_dependent/Koha/Biblio/Metadata/Extractor/MARC/MARC21.t >+++ b/t/db_dependent/Koha/Biblio/Metadata/Extractor/MARC/MARC21.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 2; >+use Test::More tests => 3; > use Test::Exception; > > use t::lib::TestBuilder; >@@ -69,3 +69,20 @@ subtest 'get_normalized_upc() tests' => sub { > is( $extractor->get_normalized_upc, "" ); > > }; >+ >+subtest 'get_normalized_oclc() tests' => sub { >+ >+ plan tests => 2; >+ >+ my $record = MARC::Record->new(); >+ $record->append_fields( MARC::Field->new( '035', ' ', ' ', a => "(OCoLC)902632762" ) ); >+ >+ my $extractor = Koha::Biblio::Metadata::Extractor->new( { metadata => $record } ); >+ is( $extractor->get_normalized_oclc, '902632762' ); >+ >+ $record = MARC::Record->new(); >+ $extractor = Koha::Biblio::Metadata::Extractor->new( { metadata => $record } ); >+ >+ is( $extractor->get_normalized_oclc, "" ); >+ >+}; >-- >2.42.0
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 34828
:
155907
|
156565
|
156566
|
156567
|
156568
|
156575
|
156576
|
156577
|
156578
|
156743
|
156744
|
156745
| 156746 |
156789
|
156791