| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Catmandu::Store::Datahub; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.07'; |
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
743
|
use Catmandu::Sane; |
|
|
1
|
|
|
|
|
124911
|
|
|
|
1
|
|
|
|
|
6
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
221
|
use Moo; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
5
|
|
|
8
|
1
|
|
|
1
|
|
554
|
use Catmandu::Store::Datahub::Bag; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
35
|
|
|
9
|
1
|
|
|
1
|
|
417
|
use Catmandu::Store::Datahub::OAuth; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
26
|
|
|
10
|
1
|
|
|
1
|
|
6
|
use LWP::UserAgent; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
241
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'Catmandu::Store'; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has url => (is => 'ro', required => 1); |
|
15
|
|
|
|
|
|
|
has client_id => (is => 'ro', required => 1); |
|
16
|
|
|
|
|
|
|
has client_secret => (is => 'ro', required => 1); |
|
17
|
|
|
|
|
|
|
has username => (is => 'ro', required => 1); |
|
18
|
|
|
|
|
|
|
has password => (is => 'ro', required => 1); |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has client => (is => 'lazy'); |
|
21
|
|
|
|
|
|
|
has access_token => ( |
|
22
|
|
|
|
|
|
|
is => 'lazy', |
|
23
|
|
|
|
|
|
|
writer => '_set_access_token', |
|
24
|
|
|
|
|
|
|
builder => '_build_access_token' |
|
25
|
|
|
|
|
|
|
); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
## |
|
28
|
|
|
|
|
|
|
# TODO: error reporting 'n stuff |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub _build_client { |
|
31
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
32
|
0
|
|
|
|
|
|
return LWP::UserAgent->new(); |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _build_access_token { |
|
36
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
37
|
0
|
|
|
|
|
|
return $self->generate_token(); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub set_access_token { |
|
41
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
42
|
|
|
|
|
|
|
# Used to regenerate the token when it becomes invalid |
|
43
|
0
|
|
|
|
|
|
return $self->_set_access_token($self->generate_token()); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub generate_token { |
|
47
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
48
|
0
|
|
|
|
|
|
my $oauth = Catmandu::Store::Datahub::OAuth->new(username => $self->username, password => $self->password, client_id => $self->client_id, client_secret => $self->client_secret, url => $self->url); |
|
49
|
0
|
|
|
|
|
|
return $oauth->token(); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 NAME |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=for html <a href="https://travis-ci.org/thedatahub/Catmandu-Store-Datahub"><img src="https://travis-ci.org/thedatahub/Catmandu-Store-Datahub.svg?branch=master"></a> |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Catmandu::Store::Datahub - Store/retrieve items from the Datahub |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
A module that allows to interface with the Datahub as a Catmandu::Store. |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Supports retrieving, adding, deleting and updating of data. |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Configure the L<Datahub|https://github.com/thedatahub/Datahub> as a L<store|http://librecat.org/Catmandu/#stores> for L<Catmandu|http://librecat.org/>. |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
With Catmandu, it is possible to convert (almost) any data to L<LIDO|http://lido-schema.org/>, which is suitable for importing in the Datahub. This module allows you to integrate the importing in your Catmandu workflow by setting up a Catmandu-compatible interface between the Datahub and Catmandu. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Note that you must convert your data to LIDO in order to use this module. All other formats will result in an error. |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 CONFIGURATION |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
To configure the store, the location of the Datahub is required. As OAuth2 is used, a client id and secret are also required, as well as a username and a password. |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=over |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=item C<url> |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
base url of the Datahub (e.g. I<http://www.datahub.be>). |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item C<client_id> |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
OAuth2 client ID. |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item C<client_secret> |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
OAuth2 client secret. |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item C<username> |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Datahub username. |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item C<password> |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Datahub password. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=back |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 USAGE |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
See L<the Catmandu documentation|http://librecat.org/Catmandu/#stores> for more information on how to use Stores. |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
L<Catmandu::LIDO> and L<Catmandu> |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 AUTHORS |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Matthias Vandermaesen <matthias.vandermaesen@vlaamsekunstcollectie.be> |
|
113
|
|
|
|
|
|
|
Pieter De Praetere <pieter@packed.be> |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
This software is copyright (c) 2016 by PACKED, vzw, Vlaamse Kunstcollectie, vzw. |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, Version 3, June 2007. |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=cut |