line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MARC::Convert::Wikidata::Item; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
115667
|
use strict; |
|
11
|
|
|
|
|
42
|
|
|
11
|
|
|
|
|
308
|
|
4
|
11
|
|
|
11
|
|
57
|
use warnings; |
|
11
|
|
|
|
|
32
|
|
|
11
|
|
|
|
|
358
|
|
5
|
|
|
|
|
|
|
|
6
|
11
|
|
|
11
|
|
3885
|
use Class::Utils qw(set_params); |
|
11
|
|
|
|
|
110953
|
|
|
11
|
|
|
|
|
267
|
|
7
|
11
|
|
|
11
|
|
11495
|
use DateTime; |
|
11
|
|
|
|
|
6099686
|
|
|
11
|
|
|
|
|
537
|
|
8
|
11
|
|
|
11
|
|
140
|
use English; |
|
11
|
|
|
|
|
28
|
|
|
11
|
|
|
|
|
101
|
|
9
|
11
|
|
|
11
|
|
6038
|
use Error::Pure qw(err); |
|
11
|
|
|
|
|
63
|
|
|
11
|
|
|
|
|
698
|
|
10
|
11
|
|
|
11
|
|
91
|
use Scalar::Util qw(blessed); |
|
11
|
|
|
|
|
48
|
|
|
11
|
|
|
|
|
516
|
|
11
|
11
|
|
|
11
|
|
5908
|
use Unicode::UTF8 qw(decode_utf8); |
|
11
|
|
|
|
|
5958
|
|
|
11
|
|
|
|
|
668
|
|
12
|
11
|
|
|
11
|
|
5190
|
use Wikibase::Datatype::Reference; |
|
11
|
|
|
|
|
52992
|
|
|
11
|
|
|
|
|
371
|
|
13
|
11
|
|
|
11
|
|
5090
|
use Wikibase::Datatype::Snak; |
|
11
|
|
|
|
|
99866
|
|
|
11
|
|
|
|
|
401
|
|
14
|
11
|
|
|
11
|
|
5472
|
use Wikibase::Datatype::Statement; |
|
11
|
|
|
|
|
27803
|
|
|
11
|
|
|
|
|
2179
|
|
15
|
11
|
|
|
11
|
|
10667
|
use Wikibase::Datatype::Value::Item; |
|
11
|
|
|
|
|
15848
|
|
|
11
|
|
|
|
|
374
|
|
16
|
11
|
|
|
11
|
|
4874
|
use Wikibase::Datatype::Value::Monolingual; |
|
11
|
|
|
|
|
5643
|
|
|
11
|
|
|
|
|
319
|
|
17
|
11
|
|
|
11
|
|
5064
|
use Wikibase::Datatype::Value::Quantity; |
|
11
|
|
|
|
|
9533
|
|
|
11
|
|
|
|
|
358
|
|
18
|
11
|
|
|
11
|
|
4919
|
use Wikibase::Datatype::Value::String; |
|
11
|
|
|
|
|
3139
|
|
|
11
|
|
|
|
|
390
|
|
19
|
11
|
|
|
11
|
|
5134
|
use Wikibase::Datatype::Value::Time; |
|
11
|
|
|
|
|
10392
|
|
|
11
|
|
|
|
|
45106
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = 0.02; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Constructor. |
24
|
|
|
|
|
|
|
sub new { |
25
|
0
|
|
|
0
|
0
|
|
my ($class, @params) = @_; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Create object. |
28
|
0
|
|
|
|
|
|
my $self = bless {}, $class; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Cover callback. |
31
|
0
|
|
|
|
|
|
$self->{'callback_cover'} = undef; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Lang callback. |
34
|
0
|
|
|
|
|
|
$self->{'callback_lang'} = undef; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# People callback. |
37
|
0
|
|
|
|
|
|
$self->{'callback_people'} = undef; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Place of publication Wikidata lookup callback. |
40
|
0
|
|
|
|
|
|
$self->{'callback_publisher_place'} = undef; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Publisher Wikidata lookup callback. |
43
|
0
|
|
|
|
|
|
$self->{'callback_publisher_name'} = undef; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# Book series Wikidata lookup callback. |
46
|
0
|
|
|
|
|
|
$self->{'callback_series'} = undef; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Retrieved date. |
49
|
0
|
|
|
|
|
|
$self->{'date_retrieved'} = undef; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# MARC::Record object. |
52
|
0
|
|
|
|
|
|
$self->{'marc_record'} = undef; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# Transform object. |
55
|
0
|
|
|
|
|
|
$self->{'transform_object'} = undef; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# Process parameters. |
58
|
0
|
|
|
|
|
|
set_params($self, @params); |
59
|
|
|
|
|
|
|
|
60
|
0
|
0
|
|
|
|
|
if (! defined $self->{'marc_record'}) { |
61
|
0
|
|
|
|
|
|
err "Parameter 'marc_record' is required."; |
62
|
|
|
|
|
|
|
} |
63
|
0
|
0
|
0
|
|
|
|
if (! blessed($self->{'marc_record'}) |
64
|
|
|
|
|
|
|
|| ! $self->{'marc_record'}->isa('MARC::Record')) { |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
err "Parameter 'marc_record' must be a MARC::Record object."; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
0
|
0
|
|
|
|
|
if (! defined $self->{'date_retrieved'}) { |
70
|
0
|
|
|
|
|
|
$self->{'date_retrieved'} = '+'.DateTime->now |
71
|
|
|
|
|
|
|
->truncate('to' => 'day')->iso8601().'Z'; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
return $self; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub wikidata_authors { |
78
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
return $self->wikidata_people('authors', 'P50'); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub wikidata_authors_of_afterword { |
84
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
return $self->wikidata_people('authors_of_afterword', 'P2680'); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub wikidata_authors_of_introduction { |
90
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
return $self->wikidata_people('authors_of_introduction', 'P2679'); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub wikidata_ccnb { |
96
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
97
|
|
|
|
|
|
|
|
98
|
0
|
0
|
|
|
|
|
if (! defined $self->{'transform_object'}->ccnb) { |
99
|
0
|
|
|
|
|
|
return; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
return ( |
103
|
|
|
|
|
|
|
Wikibase::Datatype::Statement->new( |
104
|
|
|
|
|
|
|
'references' => [$self->wikidata_reference], |
105
|
|
|
|
|
|
|
'snak' => Wikibase::Datatype::Snak->new( |
106
|
|
|
|
|
|
|
'datatype' => 'external-id', |
107
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::String->new( |
108
|
0
|
|
|
|
|
|
'value' => $self->{'transform_object'}->ccnb, |
109
|
|
|
|
|
|
|
), |
110
|
|
|
|
|
|
|
'property' => 'P3184', |
111
|
|
|
|
|
|
|
), |
112
|
|
|
|
|
|
|
), |
113
|
|
|
|
|
|
|
); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub wikidata_descriptions { |
117
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
118
|
|
|
|
|
|
|
|
119
|
0
|
0
|
|
|
|
|
if (! defined $self->{'transform_object'}->full_name) { |
120
|
0
|
|
|
|
|
|
return (); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
return ( |
124
|
0
|
|
|
|
|
|
'descriptions' => [ |
125
|
|
|
|
|
|
|
Wikibase::Datatype::Value::Monolingual->new( |
126
|
|
|
|
|
|
|
'language' => 'cs', |
127
|
|
|
|
|
|
|
'value' => $self->_description('cs'), |
128
|
|
|
|
|
|
|
), |
129
|
|
|
|
|
|
|
Wikibase::Datatype::Value::Monolingual->new( |
130
|
|
|
|
|
|
|
'language' => 'en', |
131
|
|
|
|
|
|
|
'value' => $self->_description('en'), |
132
|
|
|
|
|
|
|
), |
133
|
|
|
|
|
|
|
], |
134
|
|
|
|
|
|
|
); |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub wikidata_directors { |
138
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
139
|
|
|
|
|
|
|
|
140
|
0
|
|
|
|
|
|
return $self->wikidata_people('directors', 'P57'); |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub wikidata_edition_number { |
144
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
145
|
|
|
|
|
|
|
|
146
|
0
|
0
|
|
|
|
|
if (! defined $self->{'transform_object'}->edition_number) { |
147
|
0
|
|
|
|
|
|
return; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
return ( |
151
|
|
|
|
|
|
|
Wikibase::Datatype::Statement->new( |
152
|
|
|
|
|
|
|
'references' => [$self->wikidata_reference], |
153
|
|
|
|
|
|
|
'snak' => Wikibase::Datatype::Snak->new( |
154
|
|
|
|
|
|
|
'datatype' => 'string', |
155
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::String->new( |
156
|
0
|
|
|
|
|
|
'value' => $self->{'transform_object'}->edition_number, |
157
|
|
|
|
|
|
|
), |
158
|
|
|
|
|
|
|
'property' => 'P393', |
159
|
|
|
|
|
|
|
), |
160
|
|
|
|
|
|
|
), |
161
|
|
|
|
|
|
|
); |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub wikidata_editors { |
165
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
166
|
|
|
|
|
|
|
|
167
|
0
|
|
|
|
|
|
return $self->wikidata_people('editors', 'P98'); |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub wikidata_end_time { |
171
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
172
|
|
|
|
|
|
|
|
173
|
0
|
0
|
|
|
|
|
if (! defined $self->{'transform_object'}->end_time) { |
174
|
0
|
|
|
|
|
|
return; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
# XXX end_time is every year? Probably not. |
178
|
0
|
|
|
|
|
|
my $end_time = $self->{'transform_object'}->end_time; |
179
|
|
|
|
|
|
|
|
180
|
0
|
|
|
|
|
|
return $self->_year($end_time, 'end time', 'P582'); |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub wikidata_compilers { |
184
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
185
|
|
|
|
|
|
|
|
186
|
0
|
|
|
|
|
|
my $property_snaks_ar = [ |
187
|
|
|
|
|
|
|
Wikibase::Datatype::Snak->new( |
188
|
|
|
|
|
|
|
'datatype' => 'wikibase-item', |
189
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Item->new( |
190
|
|
|
|
|
|
|
'value' => 'Q29514511', |
191
|
|
|
|
|
|
|
), |
192
|
|
|
|
|
|
|
'property' => 'P3831', |
193
|
|
|
|
|
|
|
), |
194
|
|
|
|
|
|
|
]; |
195
|
0
|
|
|
|
|
|
return $self->wikidata_people('compilers', 'P98', $property_snaks_ar); |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
sub wikidata_dml { |
199
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
200
|
|
|
|
|
|
|
|
201
|
0
|
0
|
|
|
|
|
if (! defined $self->{'transform_object'}->dml) { |
202
|
0
|
|
|
|
|
|
return; |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
return Wikibase::Datatype::Statement->new( |
206
|
|
|
|
|
|
|
'references' => [$self->wikidata_reference], |
207
|
|
|
|
|
|
|
'snak' => Wikibase::Datatype::Snak->new( |
208
|
|
|
|
|
|
|
'datatype' => 'external-id', |
209
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::String->new( |
210
|
0
|
|
|
|
|
|
'value' => $self->{'transform_object'}->dml, |
211
|
|
|
|
|
|
|
), |
212
|
|
|
|
|
|
|
'property' => 'P11378', |
213
|
|
|
|
|
|
|
), |
214
|
|
|
|
|
|
|
); |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
sub wikidata_illustrators { |
218
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
219
|
|
|
|
|
|
|
|
220
|
0
|
|
|
|
|
|
return $self->wikidata_people('illustrators', 'P110'); |
221
|
|
|
|
|
|
|
} |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
sub wikidata_isbn_10 { |
224
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
225
|
|
|
|
|
|
|
|
226
|
0
|
0
|
|
|
|
|
if (! @{$self->{'transform_object'}->isbns}) { |
|
0
|
|
|
|
|
|
|
227
|
0
|
|
|
|
|
|
return; |
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
|
230
|
0
|
|
|
|
|
|
my @ret; |
231
|
0
|
|
|
|
|
|
foreach my $isbn (@{$self->{'transform_object'}->isbns}) { |
|
0
|
|
|
|
|
|
|
232
|
0
|
0
|
|
|
|
|
if ($isbn->type != 10) { |
233
|
0
|
|
|
|
|
|
next; |
234
|
|
|
|
|
|
|
} |
235
|
0
|
|
|
|
|
|
my $publisher = $self->_isbn_publisher($isbn); |
236
|
0
|
|
|
|
|
|
my $cover_qid = $self->_isbn_cover($isbn); |
237
|
0
|
0
|
|
|
|
|
push @ret, Wikibase::Datatype::Statement->new( |
|
|
0
|
|
|
|
|
|
238
|
|
|
|
|
|
|
'references' => [$self->wikidata_reference], |
239
|
|
|
|
|
|
|
'snak' => Wikibase::Datatype::Snak->new( |
240
|
|
|
|
|
|
|
'datatype' => 'external-id', |
241
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::String->new( |
242
|
|
|
|
|
|
|
'value' => $isbn->isbn, |
243
|
|
|
|
|
|
|
), |
244
|
|
|
|
|
|
|
'property' => 'P957', |
245
|
|
|
|
|
|
|
), |
246
|
|
|
|
|
|
|
defined $publisher ? ( |
247
|
|
|
|
|
|
|
'property_snaks' => [ |
248
|
|
|
|
|
|
|
Wikibase::Datatype::Snak->new( |
249
|
|
|
|
|
|
|
'datatype' => 'wikibase-item', |
250
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Item->new( |
251
|
|
|
|
|
|
|
'value' => $publisher->[0], |
252
|
|
|
|
|
|
|
), |
253
|
|
|
|
|
|
|
'property' => 'P123', |
254
|
|
|
|
|
|
|
), |
255
|
|
|
|
|
|
|
], |
256
|
|
|
|
|
|
|
) : (), |
257
|
|
|
|
|
|
|
defined $cover_qid ? ( |
258
|
|
|
|
|
|
|
'property_snaks' => [ |
259
|
|
|
|
|
|
|
Wikibase::Datatype::Snak->new( |
260
|
|
|
|
|
|
|
'datatype' => 'wikibase-item', |
261
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Item->new( |
262
|
|
|
|
|
|
|
'value' => $cover_qid, |
263
|
|
|
|
|
|
|
), |
264
|
|
|
|
|
|
|
'property' => 'P437', |
265
|
|
|
|
|
|
|
), |
266
|
|
|
|
|
|
|
], |
267
|
|
|
|
|
|
|
) : (), |
268
|
|
|
|
|
|
|
); |
269
|
|
|
|
|
|
|
} |
270
|
|
|
|
|
|
|
|
271
|
0
|
|
|
|
|
|
return @ret; |
272
|
|
|
|
|
|
|
} |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
sub wikidata_isbn_13 { |
275
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
276
|
|
|
|
|
|
|
|
277
|
0
|
0
|
|
|
|
|
if (! @{$self->{'transform_object'}->isbns}) { |
|
0
|
|
|
|
|
|
|
278
|
0
|
|
|
|
|
|
return; |
279
|
|
|
|
|
|
|
} |
280
|
|
|
|
|
|
|
|
281
|
0
|
|
|
|
|
|
my @ret; |
282
|
0
|
|
|
|
|
|
foreach my $isbn (@{$self->{'transform_object'}->isbns}) { |
|
0
|
|
|
|
|
|
|
283
|
0
|
0
|
|
|
|
|
if ($isbn->type != 13) { |
284
|
0
|
|
|
|
|
|
next; |
285
|
|
|
|
|
|
|
} |
286
|
0
|
|
|
|
|
|
my $publisher = $self->_isbn_publisher($isbn); |
287
|
0
|
|
|
|
|
|
my $cover_qid = $self->_isbn_cover($isbn); |
288
|
0
|
0
|
|
|
|
|
push @ret, Wikibase::Datatype::Statement->new( |
|
|
0
|
|
|
|
|
|
289
|
|
|
|
|
|
|
'references' => [$self->wikidata_reference], |
290
|
|
|
|
|
|
|
'snak' => Wikibase::Datatype::Snak->new( |
291
|
|
|
|
|
|
|
'datatype' => 'external-id', |
292
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::String->new( |
293
|
|
|
|
|
|
|
'value' => $isbn->isbn, |
294
|
|
|
|
|
|
|
), |
295
|
|
|
|
|
|
|
'property' => 'P212', |
296
|
|
|
|
|
|
|
), |
297
|
|
|
|
|
|
|
defined $publisher ? ( |
298
|
|
|
|
|
|
|
'property_snaks' => [ |
299
|
|
|
|
|
|
|
Wikibase::Datatype::Snak->new( |
300
|
|
|
|
|
|
|
'datatype' => 'wikibase-item', |
301
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Item->new( |
302
|
|
|
|
|
|
|
'value' => $publisher->[0], |
303
|
|
|
|
|
|
|
), |
304
|
|
|
|
|
|
|
'property' => 'P123', |
305
|
|
|
|
|
|
|
), |
306
|
|
|
|
|
|
|
], |
307
|
|
|
|
|
|
|
) : (), |
308
|
|
|
|
|
|
|
defined $cover_qid ? ( |
309
|
|
|
|
|
|
|
'property_snaks' => [ |
310
|
|
|
|
|
|
|
Wikibase::Datatype::Snak->new( |
311
|
|
|
|
|
|
|
'datatype' => 'wikibase-item', |
312
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Item->new( |
313
|
|
|
|
|
|
|
'value' => $cover_qid, |
314
|
|
|
|
|
|
|
), |
315
|
|
|
|
|
|
|
'property' => 'P437', |
316
|
|
|
|
|
|
|
), |
317
|
|
|
|
|
|
|
], |
318
|
|
|
|
|
|
|
) : (), |
319
|
|
|
|
|
|
|
); |
320
|
|
|
|
|
|
|
} |
321
|
|
|
|
|
|
|
|
322
|
0
|
|
|
|
|
|
return @ret; |
323
|
|
|
|
|
|
|
} |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
sub wikidata_issn { |
326
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
327
|
|
|
|
|
|
|
|
328
|
0
|
0
|
|
|
|
|
if (! $self->{'transform_object'}->issn) { |
329
|
0
|
|
|
|
|
|
return; |
330
|
|
|
|
|
|
|
} |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
return ( |
333
|
|
|
|
|
|
|
Wikibase::Datatype::Statement->new( |
334
|
|
|
|
|
|
|
'references' => [$self->wikidata_reference], |
335
|
|
|
|
|
|
|
'snak' => Wikibase::Datatype::Snak->new( |
336
|
|
|
|
|
|
|
'datatype' => 'external-id', |
337
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::String->new( |
338
|
0
|
|
|
|
|
|
'value' => $self->{'transform_object'}->issn, |
339
|
|
|
|
|
|
|
), |
340
|
|
|
|
|
|
|
'property' => 'P236', |
341
|
|
|
|
|
|
|
), |
342
|
|
|
|
|
|
|
), |
343
|
|
|
|
|
|
|
); |
344
|
|
|
|
|
|
|
} |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
sub wikidata_labels { |
347
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
348
|
|
|
|
|
|
|
|
349
|
0
|
0
|
|
|
|
|
if (! defined $self->{'transform_object'}->full_name) { |
350
|
0
|
|
|
|
|
|
return (); |
351
|
|
|
|
|
|
|
} |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
return ( |
354
|
|
|
|
|
|
|
'labels' => [ |
355
|
|
|
|
|
|
|
Wikibase::Datatype::Value::Monolingual->new( |
356
|
|
|
|
|
|
|
'language' => 'cs', |
357
|
|
|
|
|
|
|
'value' => $self->{'transform_object'}->full_name, |
358
|
|
|
|
|
|
|
), |
359
|
|
|
|
|
|
|
Wikibase::Datatype::Value::Monolingual->new( |
360
|
|
|
|
|
|
|
'language' => 'en', |
361
|
0
|
|
|
|
|
|
'value' => $self->{'transform_object'}->full_name, |
362
|
|
|
|
|
|
|
), |
363
|
|
|
|
|
|
|
], |
364
|
|
|
|
|
|
|
); |
365
|
|
|
|
|
|
|
} |
366
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
sub wikidata_language { |
368
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
369
|
|
|
|
|
|
|
|
370
|
0
|
0
|
|
|
|
|
if (! @{$self->{'transform_object'}->languages}) { |
|
0
|
|
|
|
|
|
|
371
|
0
|
|
|
|
|
|
return; |
372
|
|
|
|
|
|
|
} |
373
|
|
|
|
|
|
|
|
374
|
0
|
0
|
|
|
|
|
if (! defined $self->{'callback_lang'}) { |
375
|
0
|
|
|
|
|
|
warn "No callback method for translation of language.\n"; |
376
|
0
|
|
|
|
|
|
return; |
377
|
|
|
|
|
|
|
} |
378
|
|
|
|
|
|
|
|
379
|
0
|
|
|
|
|
|
my @language_qids; |
380
|
0
|
|
|
|
|
|
foreach my $lang (@{$self->{'transform_object'}->languages}) { |
|
0
|
|
|
|
|
|
|
381
|
0
|
|
|
|
|
|
my $language_qid = $self->{'callback_lang'}->($lang); |
382
|
0
|
0
|
|
|
|
|
if (defined $language_qid) { |
383
|
0
|
|
|
|
|
|
push @language_qids, $language_qid; |
384
|
|
|
|
|
|
|
} |
385
|
|
|
|
|
|
|
} |
386
|
|
|
|
|
|
|
|
387
|
0
|
|
|
|
|
|
my @lang; |
388
|
0
|
|
|
|
|
|
foreach my $language_qid (@language_qids) { |
389
|
0
|
|
|
|
|
|
push @lang, Wikibase::Datatype::Statement->new( |
390
|
|
|
|
|
|
|
'references' => [$self->wikidata_reference], |
391
|
|
|
|
|
|
|
'snak' => Wikibase::Datatype::Snak->new( |
392
|
|
|
|
|
|
|
'datatype' => 'wikibase-item', |
393
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Item->new( |
394
|
|
|
|
|
|
|
'value' => $language_qid, |
395
|
|
|
|
|
|
|
), |
396
|
|
|
|
|
|
|
'property' => 'P407', |
397
|
|
|
|
|
|
|
), |
398
|
|
|
|
|
|
|
); |
399
|
|
|
|
|
|
|
} |
400
|
|
|
|
|
|
|
|
401
|
0
|
|
|
|
|
|
return @lang; |
402
|
|
|
|
|
|
|
} |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
sub wikidata_krameriuses { |
405
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
406
|
|
|
|
|
|
|
|
407
|
0
|
0
|
|
|
|
|
if (! defined $self->{'transform_object'}->krameriuses) { |
408
|
0
|
|
|
|
|
|
return; |
409
|
|
|
|
|
|
|
} |
410
|
|
|
|
|
|
|
|
411
|
0
|
|
|
|
|
|
my @krameriuses; |
412
|
0
|
|
|
|
|
|
foreach my $k (@{$self->{'transform_object'}->krameriuses}) { |
|
0
|
|
|
|
|
|
|
413
|
0
|
0
|
|
|
|
|
if ($k->kramerius_id eq 'mzk') { |
414
|
0
|
|
|
|
|
|
push @krameriuses, Wikibase::Datatype::Statement->new( |
415
|
|
|
|
|
|
|
'references' => [$self->wikidata_reference], |
416
|
|
|
|
|
|
|
'snak' => Wikibase::Datatype::Snak->new( |
417
|
|
|
|
|
|
|
'datatype' => 'external-id', |
418
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::String->new( |
419
|
|
|
|
|
|
|
'value' => $k->object_id, |
420
|
|
|
|
|
|
|
), |
421
|
|
|
|
|
|
|
'property' => 'P8752', |
422
|
|
|
|
|
|
|
), |
423
|
|
|
|
|
|
|
), |
424
|
|
|
|
|
|
|
} else { |
425
|
0
|
|
|
|
|
|
push @krameriuses, Wikibase::Datatype::Statement->new( |
426
|
|
|
|
|
|
|
'references' => [$self->wikidata_reference], |
427
|
|
|
|
|
|
|
'snak' => Wikibase::Datatype::Snak->new( |
428
|
|
|
|
|
|
|
'datatype' => 'url', |
429
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::String->new( |
430
|
|
|
|
|
|
|
'value' => $k->url, |
431
|
|
|
|
|
|
|
), |
432
|
|
|
|
|
|
|
'property' => 'P953', |
433
|
|
|
|
|
|
|
), |
434
|
|
|
|
|
|
|
# TODO Language of work or name: Czech |
435
|
|
|
|
|
|
|
), |
436
|
|
|
|
|
|
|
} |
437
|
|
|
|
|
|
|
} |
438
|
|
|
|
|
|
|
|
439
|
0
|
|
|
|
|
|
return @krameriuses; |
440
|
|
|
|
|
|
|
} |
441
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
sub wikidata_narrators { |
443
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
444
|
|
|
|
|
|
|
|
445
|
0
|
|
|
|
|
|
return $self->wikidata_people('narrators', 'P2438'); |
446
|
|
|
|
|
|
|
} |
447
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
sub wikidata_number_of_pages { |
449
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
450
|
|
|
|
|
|
|
|
451
|
0
|
0
|
|
|
|
|
if (! defined $self->{'transform_object'}->number_of_pages) { |
452
|
0
|
|
|
|
|
|
return; |
453
|
|
|
|
|
|
|
} |
454
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
return ( |
456
|
|
|
|
|
|
|
Wikibase::Datatype::Statement->new( |
457
|
|
|
|
|
|
|
'references' => [$self->wikidata_reference], |
458
|
|
|
|
|
|
|
'snak' => Wikibase::Datatype::Snak->new( |
459
|
|
|
|
|
|
|
'datatype' => 'quantity', |
460
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Quantity->new( |
461
|
0
|
|
|
|
|
|
'value' => $self->{'transform_object'}->number_of_pages, |
462
|
|
|
|
|
|
|
), |
463
|
|
|
|
|
|
|
'property' => 'P1104', |
464
|
|
|
|
|
|
|
), |
465
|
|
|
|
|
|
|
), |
466
|
|
|
|
|
|
|
); |
467
|
|
|
|
|
|
|
} |
468
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
sub wikidata_oclc { |
470
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
471
|
|
|
|
|
|
|
|
472
|
0
|
0
|
|
|
|
|
if (! defined $self->{'transform_object'}->oclc) { |
473
|
0
|
|
|
|
|
|
return; |
474
|
|
|
|
|
|
|
} |
475
|
|
|
|
|
|
|
|
476
|
|
|
|
|
|
|
return ( |
477
|
|
|
|
|
|
|
Wikibase::Datatype::Statement->new( |
478
|
|
|
|
|
|
|
'references' => [$self->wikidata_reference], |
479
|
|
|
|
|
|
|
'snak' => Wikibase::Datatype::Snak->new( |
480
|
|
|
|
|
|
|
'datatype' => 'external-id', |
481
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::String->new( |
482
|
0
|
|
|
|
|
|
'value' => $self->{'transform_object'}->oclc, |
483
|
|
|
|
|
|
|
), |
484
|
|
|
|
|
|
|
'property' => 'P243', |
485
|
|
|
|
|
|
|
), |
486
|
|
|
|
|
|
|
), |
487
|
|
|
|
|
|
|
); |
488
|
|
|
|
|
|
|
} |
489
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
sub wikidata_people { |
491
|
0
|
|
|
0
|
0
|
|
my ($self, $people_method, $people_property, $property_snaks_ar) = @_; |
492
|
|
|
|
|
|
|
|
493
|
0
|
0
|
|
|
|
|
if (! @{$self->{'transform_object'}->$people_method}) { |
|
0
|
|
|
|
|
|
|
494
|
0
|
|
|
|
|
|
return; |
495
|
|
|
|
|
|
|
} |
496
|
|
|
|
|
|
|
|
497
|
0
|
0
|
|
|
|
|
if (! defined $self->{'callback_people'}) { |
498
|
0
|
|
|
|
|
|
warn "No callback method for translation of people in '$people_method' method.\n"; |
499
|
0
|
|
|
|
|
|
return; |
500
|
|
|
|
|
|
|
} |
501
|
|
|
|
|
|
|
|
502
|
0
|
|
|
|
|
|
my @people_qids; |
503
|
0
|
|
|
|
|
|
foreach my $people (@{$self->{'transform_object'}->$people_method}) { |
|
0
|
|
|
|
|
|
|
504
|
0
|
|
|
|
|
|
my $people_qid = $self->{'callback_people'}->($people); |
505
|
0
|
0
|
|
|
|
|
if (defined $people_qid) { |
506
|
0
|
|
|
|
|
|
push @people_qids, $people_qid; |
507
|
|
|
|
|
|
|
} |
508
|
|
|
|
|
|
|
} |
509
|
|
|
|
|
|
|
|
510
|
0
|
|
|
|
|
|
my @people; |
511
|
0
|
|
|
|
|
|
foreach my $people_qid (@people_qids) { |
512
|
0
|
0
|
|
|
|
|
push @people, Wikibase::Datatype::Statement->new( |
513
|
|
|
|
|
|
|
defined $property_snaks_ar ? ( |
514
|
|
|
|
|
|
|
'property_snaks' => $property_snaks_ar, |
515
|
|
|
|
|
|
|
) : (), |
516
|
|
|
|
|
|
|
'references' => [$self->wikidata_reference], |
517
|
|
|
|
|
|
|
'snak' => Wikibase::Datatype::Snak->new( |
518
|
|
|
|
|
|
|
'datatype' => 'wikibase-item', |
519
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Item->new( |
520
|
|
|
|
|
|
|
'value' => $people_qid, |
521
|
|
|
|
|
|
|
), |
522
|
|
|
|
|
|
|
'property' => $people_property, |
523
|
|
|
|
|
|
|
), |
524
|
|
|
|
|
|
|
), |
525
|
|
|
|
|
|
|
} |
526
|
|
|
|
|
|
|
|
527
|
0
|
|
|
|
|
|
return @people; |
528
|
|
|
|
|
|
|
} |
529
|
|
|
|
|
|
|
|
530
|
|
|
|
|
|
|
sub wikidata_photographers { |
531
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
532
|
|
|
|
|
|
|
|
533
|
0
|
|
|
|
|
|
my $property_snaks_ar = [ |
534
|
|
|
|
|
|
|
Wikibase::Datatype::Snak->new( |
535
|
|
|
|
|
|
|
'datatype' => 'wikibase-item', |
536
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Item->new( |
537
|
|
|
|
|
|
|
'value' => 'Q33231', |
538
|
|
|
|
|
|
|
), |
539
|
|
|
|
|
|
|
'property' => 'P3831', |
540
|
|
|
|
|
|
|
), |
541
|
|
|
|
|
|
|
]; |
542
|
0
|
|
|
|
|
|
return $self->wikidata_people('photographers', 'P50', $property_snaks_ar); |
543
|
|
|
|
|
|
|
} |
544
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
sub wikidata_place_of_publication { |
546
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
547
|
|
|
|
|
|
|
|
548
|
0
|
0
|
|
|
|
|
if (! @{$self->{'transform_object'}->publishers}) { |
|
0
|
|
|
|
|
|
|
549
|
0
|
|
|
|
|
|
return; |
550
|
|
|
|
|
|
|
} |
551
|
|
|
|
|
|
|
|
552
|
0
|
|
|
|
|
|
my @places; |
553
|
0
|
|
|
|
|
|
my $publication_date = $self->{'transform_object'}->publication_date; |
554
|
0
|
0
|
|
|
|
|
if (! defined $self->{'callback_publisher_place'}) { |
555
|
0
|
|
|
|
|
|
return; |
556
|
|
|
|
|
|
|
} else { |
557
|
0
|
|
|
|
|
|
foreach my $publisher (@{$self->{'transform_object'}->publishers}) { |
|
0
|
|
|
|
|
|
|
558
|
0
|
|
|
|
|
|
my $place_qid = $self->{'callback_publisher_place'}->($publisher); |
559
|
0
|
|
|
|
|
|
my $publisher_qid = $self->{'callback_publisher_name'}->($publisher, $publication_date); |
560
|
0
|
0
|
|
|
|
|
if ($place_qid) { |
561
|
0
|
|
|
|
|
|
push @places, [$publisher_qid, $place_qid]; |
562
|
|
|
|
|
|
|
} |
563
|
|
|
|
|
|
|
} |
564
|
|
|
|
|
|
|
} |
565
|
|
|
|
|
|
|
|
566
|
0
|
0
|
|
|
|
|
if (! @places) { |
567
|
0
|
|
|
|
|
|
return; |
568
|
|
|
|
|
|
|
} |
569
|
|
|
|
|
|
|
|
570
|
0
|
0
|
|
|
|
|
my $multiple = @places > 1 ? 1 : 0; |
571
|
|
|
|
|
|
|
return map { |
572
|
0
|
|
|
|
|
|
Wikibase::Datatype::Statement->new( |
|
0
|
|
|
|
|
|
|
573
|
|
|
|
|
|
|
'references' => [$self->wikidata_reference], |
574
|
|
|
|
|
|
|
'snak' => Wikibase::Datatype::Snak->new( |
575
|
|
|
|
|
|
|
'datatype' => 'wikibase-item', |
576
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Item->new( |
577
|
|
|
|
|
|
|
'value' => $_->[1], |
578
|
|
|
|
|
|
|
), |
579
|
|
|
|
|
|
|
'property' => 'P291', |
580
|
|
|
|
|
|
|
), |
581
|
|
|
|
|
|
|
# TODO property snak with publisher if multiples = 1; |
582
|
|
|
|
|
|
|
); |
583
|
|
|
|
|
|
|
} @places; |
584
|
|
|
|
|
|
|
} |
585
|
|
|
|
|
|
|
|
586
|
|
|
|
|
|
|
sub wikidata_publication_date { |
587
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
588
|
|
|
|
|
|
|
|
589
|
0
|
0
|
|
|
|
|
if (! defined $self->{'transform_object'}->publication_date) { |
590
|
0
|
|
|
|
|
|
return; |
591
|
|
|
|
|
|
|
} |
592
|
|
|
|
|
|
|
|
593
|
|
|
|
|
|
|
# TODO Second parameter of publication_date(). |
594
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
# XXX Publication date is every year? Probably not. |
596
|
0
|
|
|
|
|
|
my $publication_date = $self->{'transform_object'}->publication_date; |
597
|
|
|
|
|
|
|
|
598
|
0
|
|
|
|
|
|
return $self->_year($publication_date, 'publication date', 'P577'); |
599
|
|
|
|
|
|
|
} |
600
|
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
sub wikidata_publishers { |
602
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
603
|
|
|
|
|
|
|
|
604
|
0
|
0
|
|
|
|
|
if (! @{$self->{'transform_object'}->publishers}) { |
|
0
|
|
|
|
|
|
|
605
|
0
|
|
|
|
|
|
return; |
606
|
|
|
|
|
|
|
} |
607
|
|
|
|
|
|
|
|
608
|
0
|
|
|
|
|
|
my @publisher_qids = $self->_publisher_translate(@{$self->{'transform_object'}->publishers}); |
|
0
|
|
|
|
|
|
|
609
|
0
|
0
|
|
|
|
|
if (! @publisher_qids) { |
610
|
0
|
|
|
|
|
|
return; |
611
|
|
|
|
|
|
|
} |
612
|
|
|
|
|
|
|
|
613
|
0
|
|
|
|
|
|
my @publishers; |
614
|
0
|
|
|
|
|
|
foreach my $publisher_ar (@publisher_qids) { |
615
|
0
|
|
|
|
|
|
push @publishers, Wikibase::Datatype::Statement->new( |
616
|
|
|
|
|
|
|
'references' => [$self->wikidata_reference], |
617
|
|
|
|
|
|
|
'snak' => Wikibase::Datatype::Snak->new( |
618
|
|
|
|
|
|
|
'datatype' => 'wikibase-item', |
619
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Item->new( |
620
|
|
|
|
|
|
|
'value' => $publisher_ar->[0], |
621
|
|
|
|
|
|
|
), |
622
|
|
|
|
|
|
|
'property' => 'P123', |
623
|
|
|
|
|
|
|
), |
624
|
|
|
|
|
|
|
'property_snaks' => [ |
625
|
|
|
|
|
|
|
Wikibase::Datatype::Snak->new( |
626
|
|
|
|
|
|
|
'datatype' => 'string', |
627
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::String->new( |
628
|
|
|
|
|
|
|
'value' => $publisher_ar->[1], |
629
|
|
|
|
|
|
|
), |
630
|
|
|
|
|
|
|
'property' => 'P1810', |
631
|
|
|
|
|
|
|
), |
632
|
|
|
|
|
|
|
], |
633
|
|
|
|
|
|
|
); |
634
|
|
|
|
|
|
|
} |
635
|
|
|
|
|
|
|
|
636
|
0
|
|
|
|
|
|
return @publishers; |
637
|
|
|
|
|
|
|
} |
638
|
|
|
|
|
|
|
|
639
|
|
|
|
|
|
|
sub wikidata_reference { |
640
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
641
|
|
|
|
|
|
|
|
642
|
0
|
0
|
|
|
|
|
if (! defined $self->{'transform_object'}->ccnb) { |
643
|
0
|
|
|
|
|
|
err decode_utf8('Missing ČČNB id.'); |
644
|
|
|
|
|
|
|
} |
645
|
|
|
|
|
|
|
return ( |
646
|
|
|
|
|
|
|
Wikibase::Datatype::Reference->new( |
647
|
|
|
|
|
|
|
'snaks' => [ |
648
|
|
|
|
|
|
|
# Stated in Czech National Bibliography |
649
|
|
|
|
|
|
|
Wikibase::Datatype::Snak->new( |
650
|
|
|
|
|
|
|
'datatype' => 'wikibase-item', |
651
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Item->new( |
652
|
|
|
|
|
|
|
'value' => 'Q86914821', |
653
|
|
|
|
|
|
|
), |
654
|
|
|
|
|
|
|
'property' => 'P248', |
655
|
|
|
|
|
|
|
), |
656
|
|
|
|
|
|
|
|
657
|
|
|
|
|
|
|
# Czech National Bibliography book ID |
658
|
|
|
|
|
|
|
Wikibase::Datatype::Snak->new( |
659
|
|
|
|
|
|
|
'datatype' => 'external-id', |
660
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::String->new( |
661
|
|
|
|
|
|
|
'value' => $self->{'transform_object'}->ccnb, |
662
|
|
|
|
|
|
|
), |
663
|
|
|
|
|
|
|
'property' => 'P3184', |
664
|
|
|
|
|
|
|
), |
665
|
|
|
|
|
|
|
|
666
|
|
|
|
|
|
|
# Retrieved. |
667
|
|
|
|
|
|
|
Wikibase::Datatype::Snak->new( |
668
|
|
|
|
|
|
|
'datatype' => 'time', |
669
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Time->new( |
670
|
0
|
|
|
|
|
|
'value' => $self->{'date_retrieved'}, |
671
|
|
|
|
|
|
|
), |
672
|
|
|
|
|
|
|
'property' => 'P813', |
673
|
|
|
|
|
|
|
), |
674
|
|
|
|
|
|
|
], |
675
|
|
|
|
|
|
|
), |
676
|
|
|
|
|
|
|
); |
677
|
|
|
|
|
|
|
} |
678
|
|
|
|
|
|
|
|
679
|
|
|
|
|
|
|
sub wikidata_series { |
680
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
681
|
|
|
|
|
|
|
|
682
|
0
|
0
|
|
|
|
|
if (! @{$self->{'transform_object'}->series}) { |
|
0
|
|
|
|
|
|
|
683
|
0
|
|
|
|
|
|
return; |
684
|
|
|
|
|
|
|
} |
685
|
|
|
|
|
|
|
|
686
|
0
|
|
|
|
|
|
my @series_qids; |
687
|
0
|
0
|
|
|
|
|
if (! defined $self->{'callback_series'}) { |
688
|
0
|
|
|
|
|
|
return; |
689
|
|
|
|
|
|
|
} else { |
690
|
0
|
|
|
|
|
|
foreach my $series (@{$self->{'transform_object'}->series}) { |
|
0
|
|
|
|
|
|
|
691
|
0
|
|
|
|
|
|
my $series_qid = $self->{'callback_series'}->($series); |
692
|
0
|
0
|
|
|
|
|
if ($series_qid) { |
693
|
0
|
|
|
|
|
|
push @series_qids, [ |
694
|
|
|
|
|
|
|
$series_qid, |
695
|
|
|
|
|
|
|
$series->name, |
696
|
|
|
|
|
|
|
$series->series_ordinal, |
697
|
|
|
|
|
|
|
]; |
698
|
|
|
|
|
|
|
} |
699
|
|
|
|
|
|
|
} |
700
|
|
|
|
|
|
|
} |
701
|
|
|
|
|
|
|
|
702
|
0
|
0
|
|
|
|
|
if (! @series_qids) { |
703
|
0
|
|
|
|
|
|
return; |
704
|
|
|
|
|
|
|
} |
705
|
|
|
|
|
|
|
|
706
|
0
|
|
|
|
|
|
my @series; |
707
|
0
|
|
|
|
|
|
foreach my $series_ar (@series_qids) { |
708
|
0
|
0
|
|
|
|
|
push @series, Wikibase::Datatype::Statement->new( |
709
|
|
|
|
|
|
|
'references' => [$self->wikidata_reference], |
710
|
|
|
|
|
|
|
'snak' => Wikibase::Datatype::Snak->new( |
711
|
|
|
|
|
|
|
'datatype' => 'wikibase-item', |
712
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Item->new( |
713
|
|
|
|
|
|
|
'value' => $series_ar->[0], |
714
|
|
|
|
|
|
|
), |
715
|
|
|
|
|
|
|
'property' => 'P179', |
716
|
|
|
|
|
|
|
), |
717
|
|
|
|
|
|
|
'property_snaks' => [ |
718
|
|
|
|
|
|
|
|
719
|
|
|
|
|
|
|
# Series ordinal. |
720
|
|
|
|
|
|
|
$series_ar->[2] ? ( |
721
|
|
|
|
|
|
|
Wikibase::Datatype::Snak->new( |
722
|
|
|
|
|
|
|
'datatype' => 'string', |
723
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::String->new( |
724
|
|
|
|
|
|
|
'value' => $series_ar->[2], |
725
|
|
|
|
|
|
|
), |
726
|
|
|
|
|
|
|
'property' => 'P1545', |
727
|
|
|
|
|
|
|
), |
728
|
|
|
|
|
|
|
) : (), |
729
|
|
|
|
|
|
|
], |
730
|
|
|
|
|
|
|
); |
731
|
|
|
|
|
|
|
} |
732
|
|
|
|
|
|
|
|
733
|
0
|
|
|
|
|
|
return @series; |
734
|
|
|
|
|
|
|
} |
735
|
|
|
|
|
|
|
|
736
|
|
|
|
|
|
|
sub wikidata_start_time { |
737
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
738
|
|
|
|
|
|
|
|
739
|
0
|
0
|
|
|
|
|
if (! defined $self->{'transform_object'}->start_time) { |
740
|
0
|
|
|
|
|
|
return; |
741
|
|
|
|
|
|
|
} |
742
|
|
|
|
|
|
|
|
743
|
|
|
|
|
|
|
# XXX start_time is every year? Probably not. |
744
|
0
|
|
|
|
|
|
my $start_time = $self->{'transform_object'}->start_time; |
745
|
|
|
|
|
|
|
|
746
|
0
|
|
|
|
|
|
return $self->_year($start_time, 'start time', 'P580'); |
747
|
|
|
|
|
|
|
} |
748
|
|
|
|
|
|
|
|
749
|
|
|
|
|
|
|
sub wikidata_subtitles { |
750
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
751
|
|
|
|
|
|
|
|
752
|
0
|
0
|
|
|
|
|
if (! @{$self->{'transform_object'}->subtitles}) { |
|
0
|
|
|
|
|
|
|
753
|
0
|
|
|
|
|
|
return; |
754
|
|
|
|
|
|
|
} |
755
|
|
|
|
|
|
|
|
756
|
0
|
|
|
|
|
|
my @ret; |
757
|
0
|
|
|
|
|
|
foreach my $subtitle (@{$self->{'transform_object'}->subtitles}) { |
|
0
|
|
|
|
|
|
|
758
|
0
|
|
|
|
|
|
push @ret, Wikibase::Datatype::Statement->new( |
759
|
|
|
|
|
|
|
'references' => [$self->wikidata_reference], |
760
|
|
|
|
|
|
|
'snak' => Wikibase::Datatype::Snak->new( |
761
|
|
|
|
|
|
|
'datatype' => 'monolingualtext', |
762
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Monolingual->new( |
763
|
|
|
|
|
|
|
'language' => $self->_marc_lang_to_wd_lang, |
764
|
|
|
|
|
|
|
'value' => $subtitle, |
765
|
|
|
|
|
|
|
), |
766
|
|
|
|
|
|
|
'property' => 'P1680', |
767
|
|
|
|
|
|
|
), |
768
|
|
|
|
|
|
|
), |
769
|
|
|
|
|
|
|
} |
770
|
|
|
|
|
|
|
|
771
|
0
|
|
|
|
|
|
return @ret; |
772
|
|
|
|
|
|
|
} |
773
|
|
|
|
|
|
|
|
774
|
|
|
|
|
|
|
sub wikidata_title { |
775
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
776
|
|
|
|
|
|
|
|
777
|
0
|
0
|
|
|
|
|
if (! defined $self->{'transform_object'}->title) { |
778
|
0
|
|
|
|
|
|
return; |
779
|
|
|
|
|
|
|
} |
780
|
|
|
|
|
|
|
|
781
|
|
|
|
|
|
|
return ( |
782
|
|
|
|
|
|
|
Wikibase::Datatype::Statement->new( |
783
|
|
|
|
|
|
|
'references' => [$self->wikidata_reference], |
784
|
|
|
|
|
|
|
'snak' => Wikibase::Datatype::Snak->new( |
785
|
|
|
|
|
|
|
'datatype' => 'monolingualtext', |
786
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Monolingual->new( |
787
|
|
|
|
|
|
|
'language' => $self->_marc_lang_to_wd_lang, |
788
|
0
|
|
|
|
|
|
'value' => $self->{'transform_object'}->title, |
789
|
|
|
|
|
|
|
), |
790
|
|
|
|
|
|
|
'property' => 'P1476', |
791
|
|
|
|
|
|
|
), |
792
|
|
|
|
|
|
|
), |
793
|
|
|
|
|
|
|
); |
794
|
|
|
|
|
|
|
} |
795
|
|
|
|
|
|
|
|
796
|
|
|
|
|
|
|
sub wikidata_translators { |
797
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
798
|
|
|
|
|
|
|
|
799
|
0
|
|
|
|
|
|
return $self->wikidata_people('translators', 'P655'); |
800
|
|
|
|
|
|
|
} |
801
|
|
|
|
|
|
|
|
802
|
|
|
|
|
|
|
sub _description { |
803
|
0
|
|
|
0
|
|
|
my ($self, $lang) = @_; |
804
|
|
|
|
|
|
|
|
805
|
0
|
|
|
|
|
|
err "Method _description() is abstract, you need to implement."; |
806
|
|
|
|
|
|
|
} |
807
|
|
|
|
|
|
|
|
808
|
|
|
|
|
|
|
sub _isbn_publisher { |
809
|
0
|
|
|
0
|
|
|
my ($self, $isbn_o) = @_; |
810
|
|
|
|
|
|
|
|
811
|
0
|
0
|
|
|
|
|
if (! defined $isbn_o->publisher) { |
812
|
0
|
|
|
|
|
|
return; |
813
|
|
|
|
|
|
|
} |
814
|
|
|
|
|
|
|
|
815
|
0
|
|
|
|
|
|
my ($publisher) = $self->_publisher_translate( |
816
|
|
|
|
|
|
|
$isbn_o->publisher |
817
|
|
|
|
|
|
|
); |
818
|
0
|
0
|
|
|
|
|
if (! defined $publisher) { |
819
|
0
|
|
|
|
|
|
return; |
820
|
|
|
|
|
|
|
} |
821
|
|
|
|
|
|
|
|
822
|
0
|
|
|
|
|
|
return $publisher; |
823
|
|
|
|
|
|
|
} |
824
|
|
|
|
|
|
|
|
825
|
|
|
|
|
|
|
sub _isbn_cover { |
826
|
0
|
|
|
0
|
|
|
my ($self, $isbn_o) = @_; |
827
|
|
|
|
|
|
|
|
828
|
0
|
0
|
|
|
|
|
if (! defined $isbn_o->cover) { |
829
|
0
|
|
|
|
|
|
return; |
830
|
|
|
|
|
|
|
} |
831
|
|
|
|
|
|
|
|
832
|
0
|
|
|
|
|
|
return $self->_cover_translate($isbn_o->cover); |
833
|
|
|
|
|
|
|
} |
834
|
|
|
|
|
|
|
|
835
|
|
|
|
|
|
|
sub _marc_lang_to_wd_lang { |
836
|
0
|
|
|
0
|
|
|
my $self = shift; |
837
|
|
|
|
|
|
|
|
838
|
0
|
|
|
|
|
|
my $wd_lang; |
839
|
0
|
|
|
|
|
|
my $marc_lang = $self->{'transform_object'}->languages->[0]; |
840
|
|
|
|
|
|
|
# TODO Common way. ISO 639-2 code for bibliography |
841
|
0
|
0
|
|
|
|
|
if ($marc_lang eq 'cze') { |
|
|
0
|
|
|
|
|
|
842
|
0
|
|
|
|
|
|
$wd_lang = 'cs'; |
843
|
|
|
|
|
|
|
} elsif ($marc_lang eq 'eng') { |
844
|
0
|
|
|
|
|
|
$wd_lang = 'en'; |
845
|
|
|
|
|
|
|
} |
846
|
|
|
|
|
|
|
|
847
|
0
|
|
|
|
|
|
return $wd_lang; |
848
|
|
|
|
|
|
|
} |
849
|
|
|
|
|
|
|
|
850
|
|
|
|
|
|
|
sub _publisher_translate { |
851
|
0
|
|
|
0
|
|
|
my ($self, @publishers) = @_; |
852
|
|
|
|
|
|
|
|
853
|
0
|
|
|
|
|
|
my @publisher_qids; |
854
|
0
|
|
|
|
|
|
my $publication_date = $self->{'transform_object'}->publication_date; |
855
|
0
|
0
|
|
|
|
|
if (! defined $self->{'callback_publisher_name'}) { |
856
|
0
|
|
|
|
|
|
return; |
857
|
|
|
|
|
|
|
} else { |
858
|
0
|
|
|
|
|
|
foreach my $publisher (@publishers) { |
859
|
0
|
|
|
|
|
|
my $publisher_qid = $self->{'callback_publisher_name'}->($publisher, $publication_date); |
860
|
0
|
0
|
|
|
|
|
if ($publisher_qid) { |
861
|
0
|
|
|
|
|
|
push @publisher_qids, [$publisher_qid, $publisher->name]; |
862
|
|
|
|
|
|
|
} |
863
|
|
|
|
|
|
|
} |
864
|
|
|
|
|
|
|
} |
865
|
|
|
|
|
|
|
|
866
|
0
|
|
|
|
|
|
return @publisher_qids; |
867
|
|
|
|
|
|
|
} |
868
|
|
|
|
|
|
|
|
869
|
|
|
|
|
|
|
sub _cover_translate { |
870
|
0
|
|
|
0
|
|
|
my ($self, $cover) = @_; |
871
|
|
|
|
|
|
|
|
872
|
0
|
|
|
|
|
|
my $cover_qid; |
873
|
0
|
0
|
|
|
|
|
if (! defined $self->{'callback_cover'}) { |
874
|
0
|
|
|
|
|
|
return; |
875
|
|
|
|
|
|
|
} else { |
876
|
0
|
|
|
|
|
|
$cover_qid = $self->{'callback_cover'}->($cover); |
877
|
|
|
|
|
|
|
} |
878
|
|
|
|
|
|
|
|
879
|
0
|
|
|
|
|
|
return $cover_qid; |
880
|
|
|
|
|
|
|
} |
881
|
|
|
|
|
|
|
|
882
|
|
|
|
|
|
|
sub _year { |
883
|
0
|
|
|
0
|
|
|
my ($self, $year, $title, $property) = @_; |
884
|
|
|
|
|
|
|
|
885
|
0
|
|
|
|
|
|
my $value_dt = eval { |
886
|
0
|
|
|
|
|
|
DateTime->new( |
887
|
|
|
|
|
|
|
'year' => $year, |
888
|
|
|
|
|
|
|
); |
889
|
|
|
|
|
|
|
}; |
890
|
0
|
0
|
|
|
|
|
if ($EVAL_ERROR) { |
891
|
0
|
|
|
|
|
|
return; |
892
|
0
|
|
|
|
|
|
err "Cannot process $title '$year'.", |
893
|
|
|
|
|
|
|
'Error', $EVAL_ERROR; |
894
|
|
|
|
|
|
|
} |
895
|
0
|
|
|
|
|
|
my $value = '+'.$value_dt->iso8601().'Z'; |
896
|
|
|
|
|
|
|
return ( |
897
|
0
|
|
|
|
|
|
Wikibase::Datatype::Statement->new( |
898
|
|
|
|
|
|
|
'references' => [$self->wikidata_reference], |
899
|
|
|
|
|
|
|
'snak' => Wikibase::Datatype::Snak->new( |
900
|
|
|
|
|
|
|
'datatype' => 'time', |
901
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Time->new( |
902
|
|
|
|
|
|
|
# Precision for year. |
903
|
|
|
|
|
|
|
'precision' => 9, |
904
|
|
|
|
|
|
|
'value' => $value, |
905
|
|
|
|
|
|
|
), |
906
|
|
|
|
|
|
|
'property' => $property, |
907
|
|
|
|
|
|
|
), |
908
|
|
|
|
|
|
|
), |
909
|
|
|
|
|
|
|
); |
910
|
|
|
|
|
|
|
} |
911
|
|
|
|
|
|
|
|
912
|
|
|
|
|
|
|
1; |
913
|
|
|
|
|
|
|
|
914
|
|
|
|
|
|
|
__END__ |