| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Catmandu::Importer::Zotero; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
53172
|
use Catmandu::Sane; |
|
|
2
|
|
|
|
|
228769
|
|
|
|
2
|
|
|
|
|
13
|
|
|
4
|
2
|
|
|
2
|
|
2575
|
use Catmandu::Util qw(:is); |
|
|
2
|
|
|
|
|
112748
|
|
|
|
2
|
|
|
|
|
860
|
|
|
5
|
2
|
|
|
2
|
|
9737
|
use WWW::Zotero; |
|
|
2
|
|
|
|
|
180662
|
|
|
|
2
|
|
|
|
|
98
|
|
|
6
|
2
|
|
|
2
|
|
18
|
use Moo; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
13
|
|
|
7
|
2
|
|
|
2
|
|
942
|
use feature 'state'; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
1342
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
with 'Catmandu::Importer'; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has userID => (is => 'ro'); |
|
12
|
|
|
|
|
|
|
has groupID => (is => 'ro'); |
|
13
|
|
|
|
|
|
|
has collectionID => (is => 'ro'); |
|
14
|
|
|
|
|
|
|
has apiKey => (is => 'ro'); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# From WWW::Zotero |
|
17
|
|
|
|
|
|
|
has sort => (is => 'ro'); |
|
18
|
|
|
|
|
|
|
has direction => (is => 'ro'); |
|
19
|
|
|
|
|
|
|
has itemKey => (is => 'ro'); |
|
20
|
|
|
|
|
|
|
has itemType => (is => 'ro'); |
|
21
|
|
|
|
|
|
|
has q => (is => 'ro'); |
|
22
|
|
|
|
|
|
|
has qmode => (is => 'ro'); |
|
23
|
|
|
|
|
|
|
has since => (is => 'ro'); |
|
24
|
|
|
|
|
|
|
has tag => (is => 'ro'); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has client => (is => 'lazy'); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _build_client { |
|
29
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
|
30
|
0
|
|
|
|
|
|
WWW::Zotero->new(key => $self->apiKey); |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub generator { |
|
34
|
|
|
|
|
|
|
my ($self) = @_; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub { |
|
37
|
|
|
|
|
|
|
state $generator; |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
unless (defined $generator) { |
|
40
|
|
|
|
|
|
|
my %options = (); |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
$options{user} = $self->userID if $self->userID; |
|
43
|
|
|
|
|
|
|
$options{group} = $self->groupID if $self->groupID; |
|
44
|
|
|
|
|
|
|
$options{sort} = $self->sort if $self->sort; |
|
45
|
|
|
|
|
|
|
$options{direction} = $self->direction if $self->direction; |
|
46
|
|
|
|
|
|
|
$options{itemKey} = $self->itemKey if $self->itemKey; |
|
47
|
|
|
|
|
|
|
$options{itemType} = $self->itemType if $self->itemType; |
|
48
|
|
|
|
|
|
|
$options{q} = $self->q if $self->q(); |
|
49
|
|
|
|
|
|
|
$options{qmode} = $self->qmode if $self->qmode; |
|
50
|
|
|
|
|
|
|
$options{since} = $self->since if $self->since; |
|
51
|
|
|
|
|
|
|
$options{tag} = $self->tag if $self->tag; |
|
52
|
|
|
|
|
|
|
$options{include} = 'data'; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
$options{itemType} .= " -attachment"; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
if ($self->collectionID) { |
|
57
|
|
|
|
|
|
|
$options{collectionKey} = $self->collectionID; |
|
58
|
|
|
|
|
|
|
$generator = $self->client->listCollectionItems(%options, generator => 1); |
|
59
|
|
|
|
|
|
|
} else { |
|
60
|
|
|
|
|
|
|
$generator = $self->client->listItems(%options, generator => 1); |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my $record = $generator->(); |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
if ($record->{meta}->{numChildren} > 0) { |
|
67
|
|
|
|
|
|
|
# Find children |
|
68
|
|
|
|
|
|
|
$record->{children} = $self->client->getItemChildren( |
|
69
|
|
|
|
|
|
|
user => $self->userID, |
|
70
|
|
|
|
|
|
|
group => $self->groupID, |
|
71
|
|
|
|
|
|
|
itemKey => $record->{_id} |
|
72
|
|
|
|
|
|
|
); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
else { |
|
75
|
|
|
|
|
|
|
$record->{children} = []; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
$record; |
|
79
|
|
|
|
|
|
|
}; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__END__ |