1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
package Catmandu::Fix::viaf_match_id;
use strict;
use warnings;
use Catmandu::Sane;
use Moo;
use Catmandu::Fix::Has;
use Catmandu::Util qw(:is);
use Catmandu::Fix::Datahub::Util qw(declare_source);
has path => (fix_arg => 1);
has lang => (fix_opt => 1, default => sub {'nl-NL'});
has fallback_lang => (fix_opt => 1, default => sub {'en-US'});
sub emit {
my ($self, $fixer) = @_;
my $perl = '';
$perl .= 'use Catmandu::VIAF::API;';
my $id = $fixer->generate_var();
my $viaf = $fixer->generate_var();
$perl .= "my ${id};";
$perl .= declare_source($fixer, $self->path, $id);
$perl .= "my ${viaf} = Catmandu::VIAF::API->new(term => ${id}, lang => '".$self->lang."');";
$perl .= $fixer->emit_create_path(
$fixer->var,
$fixer->split_path($self->path),
sub {
my $root = shift;
my $code = '';
$code .= "${root} = ${viaf}->id();";
return $code;
}
);
return $perl;
}
1;
__END__
=encoding utf-8
=head1 NAME
=for html <a href="https://travis-ci.org/thedatahub/Catmandu-VIAF"><img src="https://travis-ci.org/thedatahub/Catmandu-VIAF.svg?branch=master"></a>
Catmandu::Fix::viaf_match_id - Fetch the RDF representation of a person based on his/her VIAF ID.
=head1 SYNOPSIS
viaf_match_id(path)
=head1 DESCRIPTION
Perform a direct match between a VIAF ID and a I<mainHeadingEl> and the
I<local.personalNames> of a I<Person> in VIAF.
=head2 PARAMETERS
=head3 Required parameters
=over
=item C<path>
Path to the VIAF ID.
=back
=head1 AUTHOR
Matthias Vandermaesne <lt>matthias dot vandermaesen at vlaamsekunstcollectie dot be E<gt>
=head1 COPYRIGHT
Copyright 2017- PACKED vzw
=head1 LICENSE
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=head1 SEE ALSO
L<Catmandu>
L<Catmandu::VIAF>
L<Catmandu::Store::VIAF>
L<Catmandu::Fix::viaf_search>
=cut
|