Bugzilla – Attachment 42313 Details for
Bug 14639
Extend Koha::MetadataRecord to handle serialization format
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14639: Extend Koha::MetadataRecord to handle serialization format and record id
Bug-14639-Extend-KohaMetadataRecord-to-handle-seri.patch (text/plain), 3.24 KB, created by
Marcel de Rooy
on 2015-09-03 12:21:50 UTC
(
hide
)
Description:
Bug 14639: Extend Koha::MetadataRecord to handle serialization format and record id
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2015-09-03 12:21:50 UTC
Size:
3.24 KB
patch
obsolete
>From 161bc698a0599957d7abc1ea02a219cdda308581 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 3 Aug 2015 11:41:23 -0300 >Subject: [PATCH] Bug 14639: Extend Koha::MetadataRecord to handle > serialization format and record id >Content-Type: text/plain; charset=utf-8 > >The description of this changes is on the regression tests commit >message. > >To test: >- Apply the test patch >- Run > $ prove t/Koha_MetadataRecord.t >=> FAIL: Tests fail because changes are not implemented >- Apply this patch >- Run > $ prove t/Koha_MetadataRecord.t >=> SUCCESS: tests pass >- Run > $ prove t/Koha_Util_MARC.t >=> SUCCESS: it still passes >- Sign off :-D > >NOTE: Tested as above. Read code. Seems to cover all cases. > >Signed-off-by: Mark Tompsett <mtompset@hotmail.com> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/MetadataRecord.pm | 66 ++++++++++++++++++++++++++++++++++++++++++++---- > 1 file changed, 61 insertions(+), 5 deletions(-) > >diff --git a/Koha/MetadataRecord.pm b/Koha/MetadataRecord.pm >index 865dc0d..cec2487 100644 >--- a/Koha/MetadataRecord.pm >+++ b/Koha/MetadataRecord.pm >@@ -23,7 +23,7 @@ Koha::MetadataRecord - base class for metadata records > > =head1 SYNOPSIS > >- my $record = new Koha::MetadataRecord({ 'record' => $marcrecord }); >+ my $record = new Koha::MetadataRecord({ 'record' => $record }); > > =head1 DESCRIPTION > >@@ -32,15 +32,71 @@ and authority) records in Koha. > > =cut > >-use strict; >-use warnings; >-use C4::Context; >+use Modern::Perl; >+ >+use Carp; > use Koha::Util::MARC; > > use base qw(Class::Accessor); > >-__PACKAGE__->mk_accessors(qw( record schema )); >+__PACKAGE__->mk_accessors(qw( record schema format id )); >+ >+ >+=head2 new >+ >+ my $metadata_record = new Koha::MetadataRecord({ >+ record => $record, >+ schema => $schema, >+ format => $format, >+ id => $id >+ }); >+ >+Returns a Koha::MetadataRecord object encapsulating record metadata. >+ >+C<$record> is expected to be a deserialized object (for example >+a MARC::Record or XML::LibXML::Document object or JSON). >+ >+C<$schema> is used to describe the metadata schema (for example >+marc21, unimarc, dc, mods, etc). >+ >+C<$format> is used to specify the serialization format. It is important >+for Koha::RecordProcessor because it will pick the right Koha::Filter >+implementation based on this parameter. Valid values are: >+ >+ MARC (for MARC::Record objects) >+ XML (for XML::LibXML::Document objects) >+ JSON (for JSON objects) >+ >+(optional) C<$id> is used so the record carries its own id and Koha doesn't >+need to look for it inside the record. > >+=cut >+ >+sub new { >+ >+ my $class = shift; >+ my $params = shift; >+ >+ if (!defined $params->{ record }) { >+ carp 'No record passed'; >+ return; >+ } >+ >+ my $record = $params->{ record }; >+ my $schema = $params->{ schema } // 'marc21'; >+ my $format = $params->{ format } // 'MARC'; >+ my $id = $params->{ id }; >+ >+ my $self = $class->SUPER::new({ >+ record => $record, >+ schema => $schema, >+ format => $format, >+ id => $id >+ }); >+ >+ bless $self, $class; >+ return $self; >+} > > =head2 createMergeHash > >-- >1.7.10.4
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 14639
:
41315
|
41316
|
41357
|
41358
|
41360
|
41361
|
41386
|
41387
|
42312
| 42313 |
42316