[Koha-bugs] [Bug 34828] Add Koha::MetadataExtractor class

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Tue Sep 19 20:49:28 CEST 2023


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=34828

--- Comment #1 from Tomás Cohen Arazi <tomascohen at gmail.com> ---
Created attachment 155907
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=155907&action=edit
Bug 34828: Introduce Koha::MetadataExtractor and ->get_normalized_upc

This patch introduces a new pattern for the different ->get_<thing>
methods we've been adding. The aim is that code will look more like:

my $metadata_extractor = Koha::MetadataExtractor->new;

while ( my $biblio = $biblios->next ) {
    my $record = $biblio->record;
    my $schema = $biblio->record_schema;

    $data->{$biblio->id}->{normalized_upc} =
$metadata_extractor->get_normalized_upc( { record => $record, schema =>
$schema } );
    $data->{$biblio->id}->{normalized_ean} =
$metadata_extractor->get_normalized_ean( { record => $record, schema =>
$schema } );
}

The key is that we are actually reusing the MARC::Record, and code for
each schema is organized cleanly so easier to maintain.

For the class names, I chose to add the 'MARC' name in the path, so we
don't need to refactor anything if we want to add support for another
serialization formats.

To test:
1. Apply this patch
2. Run:
   $ ktd --shell
  k$ qa -c 1
=> SUCCESS: Tests pass!
3. Sign off :-D

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.


More information about the Koha-bugs mailing list