line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Store::Resolver::Bag; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
3
|
use Moo; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
4
|
1
|
|
|
1
|
|
167
|
use JSON; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
88
|
use Catmandu::Sane; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
7
|
1
|
|
|
1
|
|
487
|
use Catmandu::Store::Resolver::API; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
427
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
with 'Catmandu::Bag'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has api => (is => 'lazy'); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has pid => (is => 'rw'); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub _build_api { |
16
|
0
|
|
|
0
|
|
|
my $self = shift; |
17
|
0
|
|
|
|
|
|
my $api = Catmandu::Store::Resolver::API->new( |
18
|
|
|
|
|
|
|
url => $self->store->url, |
19
|
|
|
|
|
|
|
username => $self->store->username, |
20
|
|
|
|
|
|
|
password => $self->store->password |
21
|
|
|
|
|
|
|
); |
22
|
0
|
|
|
|
|
|
return $api; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
around add => sub { |
26
|
|
|
|
|
|
|
my ($orig, $self, $data) = @_; |
27
|
|
|
|
|
|
|
$self->$orig($data); |
28
|
|
|
|
|
|
|
$data->{'_id'} = $self->pid; |
29
|
|
|
|
|
|
|
return $data; |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
around update => sub { |
33
|
|
|
|
|
|
|
my ($orig, $self, $data) = @_; |
34
|
|
|
|
|
|
|
$self->$orig($data); |
35
|
|
|
|
|
|
|
$data->{'_id'} = $self->pid; |
36
|
|
|
|
|
|
|
return $data; |
37
|
|
|
|
|
|
|
}; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub generator { |
40
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub get { |
44
|
|
|
|
|
|
|
my ($self, $id) = @_; |
45
|
|
|
|
|
|
|
return $self->api->get($id); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub add { |
49
|
|
|
|
|
|
|
my ($self, $data) = @_; |
50
|
|
|
|
|
|
|
my $response = $self->api->post($data); |
51
|
|
|
|
|
|
|
if (defined($response->{'data'}->{'work_pid'})) { |
52
|
|
|
|
|
|
|
$self->pid($response->{'data'}->{'work_pid'}); |
53
|
|
|
|
|
|
|
} else { |
54
|
|
|
|
|
|
|
$self->pid($response->{'data'}->{'persistentURIs'}->[0]); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub update { |
59
|
|
|
|
|
|
|
my ($self, $id, $data) = @_; |
60
|
|
|
|
|
|
|
my $response = $self->api->put($id, $data); |
61
|
|
|
|
|
|
|
if (defined($response->{'data'}->{'work_pid'})) { |
62
|
|
|
|
|
|
|
$self->pid($response->{'data'}->{'work_pid'}); |
63
|
|
|
|
|
|
|
} else { |
64
|
|
|
|
|
|
|
$self->pid($response->{'data'}->{'persistentURIs'}->[0]); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub delete { |
69
|
|
|
|
|
|
|
my ($self, $id) = @_; |
70
|
|
|
|
|
|
|
return $self->api->delete($id); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub delete_all { |
74
|
|
|
|
|
|
|
my $self = shift; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |