Koha-Contrib-Sudoc
view release on metacpan or search on metacpan
lib/Koha/Contrib/Sudoc/Converter.pm view on Meta::CPAN
package Koha::Contrib::Sudoc::Converter;
# ABSTRACT: Classe de base pour convertir les notices
$Koha::Contrib::Sudoc::Converter::VERSION = '2.49';
use Moose;
use utf8;
use Modern::Perl;
# Moulinette SUDOC
has sudoc => ( is => 'rw', isa => 'Koha::Contrib::Sudoc', required => 1 );
has log => ( is => 'rw', isa => 'Log::Dispatch' );
has item => ( is => 'rw', isa => 'HashRef' );
sub build {
my ($self, $record) = @_;
# On crée la structure de données items
my $myrcr = $self->sudoc->c->{rcr};
my $item = {};
for my $field ( @{$record->fields} ) {
next if ref $field eq 'MARC::Moose::Field::Control';
my $value = $field->subfield('5');
next unless $value;
my ($rcr, $id) = $value =~ /(.*):(.*)/;
next unless $rcr; # Probablement un champ 035
unless ( $myrcr->{$rcr} ) {
# Cas, improbable, d'un RCR qui ne serait pas dans la liste des RCR
# FIXME On pourrait le logguer quelque part.
next;
}
$item->{$rcr} ||= {};
$item->{$rcr}->{$id} ||= {};
$item->{$rcr}->{$id}->{$field->tag} = $field;
}
$self->item($item);
}
sub skip {
return 0;
}
sub init {
my ($self, $record) = @_;
# On supprime de la notice SUDOC les champs à exclure
my $exclure = $self->sudoc->c->{biblio}->{exclure};
if ( $exclure && ref($exclure) eq 'ARRAY' ) {
my %hexclure;
$hexclure{$_} = 1 for @$exclure;
$record->fields( [ grep { not $hexclure{$_->tag} } @{$record->fields} ] );
}
}
sub authoritize {
my ($self, $record) = @_;
# Ne rien faire si c'est demandé pour l'ILN
return unless $self->sudoc->c->{biblio}->{authoritize};
my $koha = $self->sudoc->koha;
( run in 1.769 second using v1.01-cache-2.11-cpan-5b529ec07f3 )