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 <samalau@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Tomás Cohen Arazi 2024-07-16 15:21:04 -03:00 committed by Katrin Fischer
parent 9936c99903
commit 7cafe5f0dd
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834

View file

@ -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);