Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Catmandu-MARC CPAN distribution.

Report information
The Basics
Id: 90849
Status: open
Priority: 0/
Queue: Catmandu-MARC

People
Owner: Nobody in particular
Requestors: magnus [...] enger.priv.no
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.1



Subject: How to get a MARC::Record object into Catmandu?
Date: Wed, 27 Nov 2013 11:20:27 +0100
To: bug-Catmandu-MARC [...] rt.cpan.org
From: Magnus Enger <magnus [...] enger.priv.no>
Hi! *** Background We want to make it possible to automatically convert MARC records from Koha into RDF and save them in a triplestore, as they are being edited and saved in Koha. *** First attempt Here is one way we have thought about doing it: https://gitorious.org/koha-marc2rdf/koha-marc2rdf/source/7c863b4ef1289b987f1303a7996eef95512fed4a:lib/Koha/MARC2RDF.pm Using Catmandu::RDF looks much nicer, though... Here is where that code gets used in the workflow: https://gitorious.org/koha/mainline/commit/ff19b7040d550811ec0f5eaee93f6fb6c6f9a014 Basically what happens is that we get MARC data from somwhere (the cataloging screen or a command line import script) in the form of a MARC::Record object. After serializing and saving the MARC to MySQL, we want to convert it to RDF and push that version to a triplestore. *** Problem How do we get our MARC::Record object into Catmandu and specifically Catmandu::RDF? As far as I can see, Catmandu::Importer::MARC is mostly about getting MARC from files... *** Possible solution 1 Make it possible to pass a MARC::Record object (or an array of such objects) to Catmandu::Importer::MARC, something like: my $records = Catmandu::Importer::MARC->new( marc_object => $record, ); (Where $record is a MARC::Record object.) *** Possible solution 2 Abstract out the parts of Catmandu::Importer::MARC that turns a MARC::Record into the internal data structure of Catmandu (an array of arrays, I believe?), into a function that could be used to turn a MARC::Record into a Catmandu structure that could be passed directly to Catmandu::Exporter::RDF, something like: $marc_as_structure = marcobecject2marcstructure( $record ); my $exporter = Catmandu::Exporter::RDF->new( type => 'Turtle', fix => 'marc2rdf.fix' ); $exporter->add( $marc_as_structure ); *** Conclusion Any thoughts on what would be the best solution and how doable it would be? Best regards, Magnus Enger
Hi Magnus, I've implemented "solution 1" at https://github.com/jorol/Catmandu-MARC/tree/bug90849. use Catmandu::Importer::MARC; # import from array of MARC::Record objects my $importer = Catmandu::Importer::MARC->new(records => \@records); my $records = $importer->to_array; Best regards, Johann
Hi Magnus, the solution is merged in the master branch and a new version is published on CPAN. Regards, Johann
Subject: Re: [rt.cpan.org #90849] How to get a MARC::Record object into Catmandu?
Date: Fri, 13 Dec 2013 11:55:06 +0100
To: bug-Catmandu-MARC [...] rt.cpan.org
From: Magnus Enger <magnus [...] enger.priv.no>
That is just awesome! Thanks for fixing this so quickly! Best regards, Magnus On 3 December 2013 16:33, Johann Rolschewski via RT <bug-Catmandu-MARC@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=90849 > > > Hi Magnus, > > the solution is merged in the master branch and a new version is published on CPAN. > > Regards, Johann