Marcel de Rooy
590cae04fd
After feedback from the dev mailing list, it seems appropriate here to propose making the Default framework authoritative for Koha to MARC mappings. This implies checking only the Default framework in the routines: [1] GetMarcFromKohaField: The parameter frameworkcode is removed. A follow-up report (19097) will update the calls not adjusted here. This is safe since the parameter is silently ignored. [2] GetMarcSubfieldStructureFromKohaField: Framework parameter is removed and calls are adjusted. Includes acquisitions_stats.pl. [3] TransformKohaToMarc: The parameter is removed; all calls are verified or adjusted. [4] TransformMarcToKoha: The parameter is no longer used and will be removed in a follow-up report (19097). It always goes to Default now. [5] TransformMarcToKohaOneField: The parameter is removed and all calls are adjusted. Including: Breeding, XISBN and MetadataRecord modules. [6] C4::Koha::IsKohaFieldLinked: This routine was called only once (in C4::Items::_build_default_values_for_mod_marc. It can be replaced by calling GetMarcFromKohaField. If there is no kohafield linked, undef is returned. (Corresponding unit test is removed here.) [7] C4::Items::ModItemFromMarc: The helper routine _build_default_values_for_mod_marc does no longer have a framework parameter. The cache key default_value_for_mod_marc- is no longer combined with a frameworkcode. Three admin scripts are adjusted accordingly; some tests will be corrected in the next patch. Test plan: See next patch. That patch adjusts all tests involved. Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
125 lines
3.1 KiB
Perl
125 lines
3.1 KiB
Perl
package Koha::MetadataRecord;
|
|
|
|
# Copyright 2013 C & P Bibliography Services
|
|
#
|
|
# This file is part of Koha.
|
|
#
|
|
# Koha is free software; you can redistribute it and/or modify it under the
|
|
# terms of the GNU General Public License as published by the Free Software
|
|
# Foundation; either version 3 of the License, or (at your option) any later
|
|
# version.
|
|
#
|
|
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License along
|
|
# with Koha; if not, write to the Free Software Foundation, Inc.,
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
=head1 NAME
|
|
|
|
Koha::MetadataRecord - base class for metadata records
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
my $record = new Koha::MetadataRecord({ 'record' => $record });
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
Object-oriented class that encapsulates all metadata (i.e. bibliographic
|
|
and authority) records in Koha.
|
|
|
|
=cut
|
|
|
|
use Modern::Perl;
|
|
|
|
use Carp;
|
|
use C4::Biblio;
|
|
use Koha::Util::MARC;
|
|
|
|
use base qw(Class::Accessor);
|
|
|
|
__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;
|
|
}
|
|
|
|
if (!defined $params->{ schema }) {
|
|
carp 'No schema passed';
|
|
return;
|
|
}
|
|
|
|
$params->{format} //= 'MARC';
|
|
my $self = $class->SUPER::new($params);
|
|
|
|
bless $self, $class;
|
|
return $self;
|
|
}
|
|
|
|
=head2 createMergeHash
|
|
|
|
Create a hash for use when merging records. At the moment the only
|
|
metadata schema supported is MARC.
|
|
|
|
=cut
|
|
|
|
sub createMergeHash {
|
|
my ($self, $tagslib) = @_;
|
|
if ($self->schema =~ m/marc/) {
|
|
return Koha::Util::MARC::createMergeHash($self->record, $tagslib);
|
|
}
|
|
}
|
|
|
|
=head2 getKohaField
|
|
|
|
$metadata->{$key} = $record->getKohaField($kohafield);
|
|
|
|
=cut
|
|
|
|
sub getKohaField {
|
|
my ($self, $kohafield) = @_;
|
|
if ($self->schema =~ m/marc/) {
|
|
return C4::Biblio::TransformMarcToKohaOneField($kohafield, $self->record);
|
|
}
|
|
}
|
|
|
|
1;
|