line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wikibase::Datatype::Statement; |
2
|
|
|
|
|
|
|
|
3
|
69
|
|
|
69
|
|
233857
|
use strict; |
|
69
|
|
|
|
|
182
|
|
|
69
|
|
|
|
|
1953
|
|
4
|
69
|
|
|
69
|
|
385
|
use warnings; |
|
69
|
|
|
|
|
156
|
|
|
69
|
|
|
|
|
1844
|
|
5
|
|
|
|
|
|
|
|
6
|
69
|
|
|
69
|
|
14215
|
use Error::Pure qw(err); |
|
69
|
|
|
|
|
351872
|
|
|
69
|
|
|
|
|
2355
|
|
7
|
69
|
|
|
69
|
|
25520
|
use List::MoreUtils qw(none); |
|
69
|
|
|
|
|
547576
|
|
|
69
|
|
|
|
|
621
|
|
8
|
69
|
|
|
69
|
|
79754
|
use Mo qw(build default is); |
|
69
|
|
|
|
|
15212
|
|
|
69
|
|
|
|
|
420
|
|
9
|
69
|
|
|
69
|
|
101715
|
use Mo::utils qw(check_array_object check_isa check_required); |
|
69
|
|
|
|
|
43304
|
|
|
69
|
|
|
|
|
2554
|
|
10
|
69
|
|
|
69
|
|
3095
|
use Readonly; |
|
69
|
|
|
|
|
185
|
|
|
69
|
|
|
|
|
19396
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Readonly::Array our @RANKS => qw(normal preferred deprecated); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = 0.29; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has id => ( |
17
|
|
|
|
|
|
|
is => 'ro', |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has property_snaks => ( |
21
|
|
|
|
|
|
|
default => [], |
22
|
|
|
|
|
|
|
is => 'ro', |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has rank => ( |
26
|
|
|
|
|
|
|
is => 'ro', |
27
|
|
|
|
|
|
|
default => 'normal', |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has references => ( |
31
|
|
|
|
|
|
|
default => [], |
32
|
|
|
|
|
|
|
is => 'ro', |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has snak => ( |
36
|
|
|
|
|
|
|
is => 'ro', |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub BUILD { |
40
|
91
|
|
|
91
|
0
|
8845
|
my $self = shift; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Check requirements. |
43
|
91
|
|
|
|
|
382
|
check_required($self, 'snak'); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# Check rank. |
46
|
90
|
100
|
100
|
5
|
|
1130
|
if (defined $self->{'rank'} && none { $_ eq $self->{'rank'} } @RANKS) { |
|
5
|
|
|
|
|
65
|
|
47
|
1
|
|
|
|
|
18
|
err "Parameter 'rank' has bad value. Possible values are ".( |
48
|
|
|
|
|
|
|
join ', ', @RANKS).'.'; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# Check snak. |
52
|
89
|
|
|
|
|
478
|
check_isa($self, 'snak', 'Wikibase::Datatype::Snak'); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# Check property snaks. |
55
|
88
|
|
|
|
|
1826
|
check_array_object($self, 'property_snaks', 'Wikibase::Datatype::Snak', |
56
|
|
|
|
|
|
|
'Property snak'); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# Check references. |
59
|
86
|
|
|
|
|
1484
|
check_array_object($self, 'references', 'Wikibase::Datatype::Reference', |
60
|
|
|
|
|
|
|
'Reference'); |
61
|
|
|
|
|
|
|
|
62
|
84
|
|
|
|
|
1258
|
return; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=pod |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=encoding utf8 |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 NAME |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Wikibase::Datatype::Statement - Wikibase statement datatype. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 SYNOPSIS |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
use Wikibase::Datatype::Statement; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my $obj = Wikibase::Datatype::Statement->new(%params); |
82
|
|
|
|
|
|
|
my $id = $obj->id; |
83
|
|
|
|
|
|
|
my $property_snaks_ar = $obj->property_snaks; |
84
|
|
|
|
|
|
|
my $rank = $obj->rank; |
85
|
|
|
|
|
|
|
my $referenes_ar = $obj->references; |
86
|
|
|
|
|
|
|
my $snak = $obj->snak; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 DESCRIPTION |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This datatype is statement class for representing claim. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 METHODS |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 C<new> |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
my $obj = Wikibase::Datatype::Statement->new(%params); |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Constructor. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Returns instance of object. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=over 8 |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item * C<id> |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Id of statement. |
107
|
|
|
|
|
|
|
Parameter is optional. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item * C<property_snaks> |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Property snaks. |
112
|
|
|
|
|
|
|
Parameter is reference to hash with Wikibase::Datatype::Snak instances. |
113
|
|
|
|
|
|
|
Parameter is optional. |
114
|
|
|
|
|
|
|
Default value is []. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item * C<rank> |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Rank value. |
119
|
|
|
|
|
|
|
Parameter is string with these possible values: normal, preferred and deprecated |
120
|
|
|
|
|
|
|
Default value is 'normal'. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=item * C<references> |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
List of references. |
125
|
|
|
|
|
|
|
Parameter is reference to hash with Wikibase::Datatype::Reference instances. |
126
|
|
|
|
|
|
|
Parameter is optional. |
127
|
|
|
|
|
|
|
Default value is []. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item * C<snak> |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Main snak. |
132
|
|
|
|
|
|
|
Parameter is Wikibase::Datatype::Snak instance. |
133
|
|
|
|
|
|
|
Parameter is required. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=back |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head2 C<id> |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
my $id = $obj->id; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Get id of statement. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Returns string. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head2 C<property_snaks> |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
my $property_snaks_ar = $obj->property_snaks; |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Get property snaks. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Returns reference to array with Wikibase::Datatype::Snak instances. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 C<rank> |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
my $rank = $obj->rank; |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Get rank value. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head2 C<references> |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
my $referenes_ar = $obj->references; |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Get references. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Returns reference to array with Wikibase::Datatype::Reference instance. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head2 C<snak> |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
my $snak = $obj->snak; |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Get main snak. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Returns Wikibase::Datatype::Snak instance. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head1 ERRORS |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
new(): |
178
|
|
|
|
|
|
|
From Mo::utils::check_array_object(): |
179
|
|
|
|
|
|
|
Parameter 'property_snaks' must be a array. |
180
|
|
|
|
|
|
|
Parameter 'references' must be a array. |
181
|
|
|
|
|
|
|
Property snak isn't 'Wikibase::Datatype::Snak' object. |
182
|
|
|
|
|
|
|
Reference isn't 'Wikibase::Datatype::Reference' object. |
183
|
|
|
|
|
|
|
From Mo::utils::check_isa(): |
184
|
|
|
|
|
|
|
Parameter 'snak' must be a 'Wikibase::Datatype::Snak' object. |
185
|
|
|
|
|
|
|
From Mo::utils::check_required(): |
186
|
|
|
|
|
|
|
Parameter 'snak' is required. |
187
|
|
|
|
|
|
|
Parameter 'rank' has bad value. Possible values are normal, preferred, deprecated. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head1 EXAMPLE |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=for comment filename=create_and_print_statement.pl |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
use strict; |
194
|
|
|
|
|
|
|
use warnings; |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
use Wikibase::Datatype::Reference; |
197
|
|
|
|
|
|
|
use Wikibase::Datatype::Statement; |
198
|
|
|
|
|
|
|
use Wikibase::Datatype::Snak; |
199
|
|
|
|
|
|
|
use Wikibase::Datatype::Value::Item; |
200
|
|
|
|
|
|
|
use Wikibase::Datatype::Value::String; |
201
|
|
|
|
|
|
|
use Wikibase::Datatype::Value::Time; |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
# Object. |
204
|
|
|
|
|
|
|
my $obj = Wikibase::Datatype::Statement->new( |
205
|
|
|
|
|
|
|
'id' => 'Q123$00C04D2A-49AF-40C2-9930-C551916887E8', |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
# instance of (P31) human (Q5) |
208
|
|
|
|
|
|
|
'snak' => Wikibase::Datatype::Snak->new( |
209
|
|
|
|
|
|
|
'datatype' => 'wikibase-item', |
210
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Item->new( |
211
|
|
|
|
|
|
|
'value' => 'Q5', |
212
|
|
|
|
|
|
|
), |
213
|
|
|
|
|
|
|
'property' => 'P31', |
214
|
|
|
|
|
|
|
), |
215
|
|
|
|
|
|
|
'property_snaks' => [ |
216
|
|
|
|
|
|
|
# of (P642) alien (Q474741) |
217
|
|
|
|
|
|
|
Wikibase::Datatype::Snak->new( |
218
|
|
|
|
|
|
|
'datatype' => 'wikibase-item', |
219
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Item->new( |
220
|
|
|
|
|
|
|
'value' => 'Q474741', |
221
|
|
|
|
|
|
|
), |
222
|
|
|
|
|
|
|
'property' => 'P642', |
223
|
|
|
|
|
|
|
), |
224
|
|
|
|
|
|
|
], |
225
|
|
|
|
|
|
|
'references' => [ |
226
|
|
|
|
|
|
|
Wikibase::Datatype::Reference->new( |
227
|
|
|
|
|
|
|
'snaks' => [ |
228
|
|
|
|
|
|
|
# stated in (P248) Virtual International Authority File (Q53919) |
229
|
|
|
|
|
|
|
Wikibase::Datatype::Snak->new( |
230
|
|
|
|
|
|
|
'datatype' => 'wikibase-item', |
231
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Item->new( |
232
|
|
|
|
|
|
|
'value' => 'Q53919', |
233
|
|
|
|
|
|
|
), |
234
|
|
|
|
|
|
|
'property' => 'P248', |
235
|
|
|
|
|
|
|
), |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
# VIAF ID (P214) 113230702 |
238
|
|
|
|
|
|
|
Wikibase::Datatype::Snak->new( |
239
|
|
|
|
|
|
|
'datatype' => 'external-id', |
240
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::String->new( |
241
|
|
|
|
|
|
|
'value' => '113230702', |
242
|
|
|
|
|
|
|
), |
243
|
|
|
|
|
|
|
'property' => 'P214', |
244
|
|
|
|
|
|
|
), |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
# retrieved (P813) 7 December 2013 |
247
|
|
|
|
|
|
|
Wikibase::Datatype::Snak->new( |
248
|
|
|
|
|
|
|
'datatype' => 'time', |
249
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Time->new( |
250
|
|
|
|
|
|
|
'value' => '+2013-12-07T00:00:00Z', |
251
|
|
|
|
|
|
|
), |
252
|
|
|
|
|
|
|
'property' => 'P813', |
253
|
|
|
|
|
|
|
), |
254
|
|
|
|
|
|
|
], |
255
|
|
|
|
|
|
|
), |
256
|
|
|
|
|
|
|
], |
257
|
|
|
|
|
|
|
); |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
# Print out. |
260
|
|
|
|
|
|
|
print 'Id: '.$obj->id."\n"; |
261
|
|
|
|
|
|
|
print 'Claim: '.$obj->snak->property.' -> '.$obj->snak->datavalue->value."\n"; |
262
|
|
|
|
|
|
|
print "Qualifiers:\n"; |
263
|
|
|
|
|
|
|
foreach my $property_snak (@{$obj->property_snaks}) { |
264
|
|
|
|
|
|
|
print "\t".$property_snak->property.' -> '. |
265
|
|
|
|
|
|
|
$property_snak->datavalue->value."\n"; |
266
|
|
|
|
|
|
|
} |
267
|
|
|
|
|
|
|
print "References:\n"; |
268
|
|
|
|
|
|
|
foreach my $reference (@{$obj->references}) { |
269
|
|
|
|
|
|
|
print "\tReference:\n"; |
270
|
|
|
|
|
|
|
foreach my $reference_snak (@{$reference->snaks}) { |
271
|
|
|
|
|
|
|
print "\t\t".$reference_snak->property.' -> '. |
272
|
|
|
|
|
|
|
$reference_snak->datavalue->value."\n"; |
273
|
|
|
|
|
|
|
} |
274
|
|
|
|
|
|
|
} |
275
|
|
|
|
|
|
|
print 'Rank: '.$obj->rank."\n"; |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
# Output: |
278
|
|
|
|
|
|
|
# Id: Q123$00C04D2A-49AF-40C2-9930-C551916887E8 |
279
|
|
|
|
|
|
|
# Claim: P31 -> Q5 |
280
|
|
|
|
|
|
|
# Qualifiers: |
281
|
|
|
|
|
|
|
# P642 -> Q474741 |
282
|
|
|
|
|
|
|
# References: |
283
|
|
|
|
|
|
|
# Reference: |
284
|
|
|
|
|
|
|
# P248 -> Q53919 |
285
|
|
|
|
|
|
|
# P214 -> 113230702 |
286
|
|
|
|
|
|
|
# P813 -> +2013-12-07T00:00:00Z |
287
|
|
|
|
|
|
|
# Rank: normal |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
L<Error::Pure>, |
292
|
|
|
|
|
|
|
L<List::MoreUtils>, |
293
|
|
|
|
|
|
|
L<Mo>, |
294
|
|
|
|
|
|
|
L<Mo::utils>. |
295
|
|
|
|
|
|
|
L<Readonly>. |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
=head1 SEE ALSO |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
=over |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
=item L<Wikibase::Datatype> |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
Wikibase datatypes. |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
=back |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
=head1 REPOSITORY |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
L<https://github.com/michal-josef-spacek/Wikibase-Datatype> |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
=head1 AUTHOR |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
Michal Josef Špaček L<mailto:skim@cpan.org> |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
L<http://skim.cz> |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
© 2020-2023 Michal Josef Špaček |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
BSD 2-Clause License |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
=head1 VERSION |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
0.29 |
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
=cut |