From 7cafe5f0ddcb3fc6c4ebd813d6564b7149e4884a Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 16 Jul 2024 15:21:04 -0300 Subject: [PATCH] Bug 37380: Add get_control_number() to the metadata extractor This simple patch implements C4::Biblio::GetMarcControlnumber in the right spot on the Koha::* namespace. To test: 1. Apply this patches 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Biblio/Metadata/Extractor/MARC.t => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: Sam Lau Signed-off-by: Jonathan Druart Signed-off-by: Katrin Fischer --- Koha/Biblio/Metadata/Extractor/MARC.pm | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Koha/Biblio/Metadata/Extractor/MARC.pm b/Koha/Biblio/Metadata/Extractor/MARC.pm index ceaabf2aa1..99e3f6032c 100644 --- a/Koha/Biblio/Metadata/Extractor/MARC.pm +++ b/Koha/Biblio/Metadata/Extractor/MARC.pm @@ -76,6 +76,30 @@ sub metadata { return $self->{metadata}; } +=head2 get_control_number + + my $control_number = $extractor->get_control_number(); + +Returns the control number/record identifier as extracted from the metadata. +It returns an empty string if no 001 present or if undef. + +=cut + +sub get_control_number { + my ($self) = @_; + + my $record = $self->metadata; + my $field = $record->field('001'); + + my $control_number = q{}; + + if ($field) { + $control_number = $field->data() // q{}; + } + + return $control_number; +} + =head3 _normalize_string my $normalized_string = $self->_normalize_string($string); -- 2.39.5