line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ArangoDB2::Graph::Vertex; |
2
|
|
|
|
|
|
|
|
3
|
21
|
|
|
21
|
|
101
|
use strict; |
|
21
|
|
|
|
|
24
|
|
|
21
|
|
|
|
|
646
|
|
4
|
21
|
|
|
21
|
|
78
|
use warnings; |
|
21
|
|
|
|
|
21
|
|
|
21
|
|
|
|
|
462
|
|
5
|
|
|
|
|
|
|
|
6
|
21
|
|
|
|
|
1419
|
use base qw( |
7
|
|
|
|
|
|
|
ArangoDB2::Base |
8
|
21
|
|
|
21
|
|
73
|
); |
|
21
|
|
|
|
|
23
|
|
9
|
|
|
|
|
|
|
|
10
|
21
|
|
|
21
|
|
91
|
use Data::Dumper; |
|
21
|
|
|
|
|
21
|
|
|
21
|
|
|
|
|
807
|
|
11
|
21
|
|
|
21
|
|
78
|
use JSON::XS; |
|
21
|
|
|
|
|
26
|
|
|
21
|
|
|
|
|
16364
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $JSON = JSON::XS->new->utf8; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# create |
18
|
|
|
|
|
|
|
# |
19
|
|
|
|
|
|
|
# POST /_api/gharial/graph-name/vertex/collection-name |
20
|
|
|
|
|
|
|
sub create |
21
|
|
|
|
|
|
|
{ |
22
|
0
|
|
|
0
|
1
|
|
my($self, $data, $args) = @_; |
23
|
|
|
|
|
|
|
# require data |
24
|
0
|
0
|
|
|
|
|
die "Invlalid args" |
25
|
|
|
|
|
|
|
unless ref $data eq 'HASH'; |
26
|
|
|
|
|
|
|
# process args |
27
|
0
|
|
|
|
|
|
$args = $self->_build_args($args, ['waitForSync']); |
28
|
|
|
|
|
|
|
# make request |
29
|
0
|
0
|
|
|
|
|
my $res = $self->arango->http->post( |
30
|
|
|
|
|
|
|
$self->api_path('gharial', $self->graph->name, $self->_class, $self->collection->name), |
31
|
|
|
|
|
|
|
$args, |
32
|
|
|
|
|
|
|
$JSON->encode($data), |
33
|
|
|
|
|
|
|
) or return; |
34
|
|
|
|
|
|
|
# get response data |
35
|
0
|
0
|
|
|
|
|
$res = $res->{$self->_class} |
36
|
|
|
|
|
|
|
or return; |
37
|
|
|
|
|
|
|
# copy response data to instance |
38
|
0
|
|
|
|
|
|
$self->_build_self($res, []); |
39
|
|
|
|
|
|
|
# set data pointer to passed in doc, which will |
40
|
|
|
|
|
|
|
# be updated by future object ops |
41
|
0
|
|
|
|
|
|
$self->{data} = $data; |
42
|
|
|
|
|
|
|
# register object |
43
|
0
|
|
|
|
|
|
my $register = $self->_register; |
44
|
0
|
|
|
|
|
|
$self->collection->$register->{$self->name} = $self; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
return $self; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# delete |
50
|
|
|
|
|
|
|
# |
51
|
|
|
|
|
|
|
# DELETE /system/gharial/graph-name/vertex/collection-name/vertex-key |
52
|
|
|
|
|
|
|
sub delete |
53
|
|
|
|
|
|
|
{ |
54
|
0
|
|
|
0
|
1
|
|
my($self, $args) = @_; |
55
|
|
|
|
|
|
|
# process args |
56
|
0
|
|
|
|
|
|
$args = $self->_build_args($args, ['name', 'waitForSync']); |
57
|
|
|
|
|
|
|
# make request |
58
|
0
|
0
|
|
|
|
|
my $res = $self->arango->http->delete( |
59
|
|
|
|
|
|
|
$self->api_path('gharial', $self->graph->name, $self->_class, $self->collection->name, delete $args->{name}), |
60
|
|
|
|
|
|
|
) or return; |
61
|
|
|
|
|
|
|
# empty data |
62
|
0
|
0
|
|
|
|
|
if (my $data = $self->data) { |
63
|
0
|
|
|
|
|
|
%$data = (); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
# unregister object |
66
|
0
|
|
|
|
|
|
my $register = $self->_register; |
67
|
0
|
|
|
|
|
|
delete $self->collection->$register->{$self->name}; |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
return $res; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# get |
73
|
|
|
|
|
|
|
# |
74
|
|
|
|
|
|
|
# GET /system/gharial/graph-name/vertex/collection-name/vertex-key |
75
|
|
|
|
|
|
|
sub get |
76
|
|
|
|
|
|
|
{ |
77
|
0
|
|
|
0
|
1
|
|
my($self, $args) = @_; |
78
|
|
|
|
|
|
|
# process args |
79
|
0
|
|
|
|
|
|
$args = $self->_build_args($args, ['data', 'name']); |
80
|
|
|
|
|
|
|
# make request |
81
|
0
|
0
|
|
|
|
|
my $res = $self->arango->http->get( |
82
|
|
|
|
|
|
|
$self->api_path('gharial', $self->graph->name, $self->_class, $self->collection->name, delete $args->{name}), |
83
|
|
|
|
|
|
|
) or return; |
84
|
|
|
|
|
|
|
# get response data |
85
|
0
|
0
|
|
|
|
|
$res = $res->{$self->_class} |
86
|
|
|
|
|
|
|
or return; |
87
|
|
|
|
|
|
|
# copy response data to instance |
88
|
0
|
|
|
|
|
|
$self->_build_self($res, []); |
89
|
|
|
|
|
|
|
# if data is defined already then empty and copy data from response |
90
|
0
|
0
|
|
|
|
|
if (my $data = $self->data) { |
91
|
0
|
|
|
|
|
|
%$data = (); |
92
|
0
|
|
|
|
|
|
$data->{$_} = $res->{$_} for keys %$res; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
# otherwise use res for data |
95
|
|
|
|
|
|
|
else { |
96
|
0
|
|
|
|
|
|
$self->data($res); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
# register object |
99
|
0
|
|
|
|
|
|
my $register = $self->_register; |
100
|
0
|
|
|
|
|
|
$self->collection->$register->{$self->name} = $self; |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
return $self; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# keepNull |
106
|
|
|
|
|
|
|
# |
107
|
|
|
|
|
|
|
# get/set keepNull |
108
|
0
|
|
|
0
|
1
|
|
sub keepNull { shift->_get_set_bool('keepNull', @_) } |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# update |
111
|
|
|
|
|
|
|
# |
112
|
|
|
|
|
|
|
# PATCH /system/gharial/graph-name/vertex/collection-name/vertex-key |
113
|
|
|
|
|
|
|
sub update |
114
|
|
|
|
|
|
|
{ |
115
|
0
|
|
|
0
|
1
|
|
my($self, $data, $args) = @_; |
116
|
|
|
|
|
|
|
# require data |
117
|
0
|
0
|
|
|
|
|
die "Invalid args" |
118
|
|
|
|
|
|
|
unless ref $data eq 'HASH'; |
119
|
|
|
|
|
|
|
# process args |
120
|
0
|
|
|
|
|
|
$args = $self->_build_args($args, ['name', 'keepNull', 'waitForSync']); |
121
|
|
|
|
|
|
|
# make request |
122
|
0
|
0
|
|
|
|
|
my $res = $self->arango->http->patch( |
123
|
|
|
|
|
|
|
$self->api_path('gharial', $self->graph->name, $self->_class, $self->collection->name, delete $args->{name}), |
124
|
|
|
|
|
|
|
$args, |
125
|
|
|
|
|
|
|
$JSON->encode($data), |
126
|
|
|
|
|
|
|
) or return; |
127
|
|
|
|
|
|
|
# get response data |
128
|
0
|
0
|
|
|
|
|
$res = $res->{$self->_class} |
129
|
|
|
|
|
|
|
or return; |
130
|
|
|
|
|
|
|
# copy response data to instance |
131
|
0
|
|
|
|
|
|
$self->_build_self($res, []); |
132
|
|
|
|
|
|
|
# if data is defined then copy patched data |
133
|
0
|
0
|
|
|
|
|
if (my $orig_data = $self->data) { |
134
|
0
|
|
|
|
|
|
$orig_data->{$_} = $data->{$_} for keys %$data; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
# otherwise use passed data |
137
|
|
|
|
|
|
|
else { |
138
|
0
|
|
|
|
|
|
$self->data($data); |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
# register object |
141
|
0
|
|
|
|
|
|
my $register = $self->_register; |
142
|
0
|
|
|
|
|
|
$self->collection->$register->{$self->name} = $self; |
143
|
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
return $self; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
# replace |
148
|
|
|
|
|
|
|
# |
149
|
|
|
|
|
|
|
# PUT /system/gharial/graph-name/vertex/collection-name/vertex-key |
150
|
|
|
|
|
|
|
sub replace |
151
|
|
|
|
|
|
|
{ |
152
|
0
|
|
|
0
|
1
|
|
my($self, $data, $args) = @_; |
153
|
|
|
|
|
|
|
# require data |
154
|
0
|
0
|
|
|
|
|
die "Invlalid args" |
155
|
|
|
|
|
|
|
unless ref $data eq 'HASH'; |
156
|
|
|
|
|
|
|
# process args |
157
|
0
|
|
|
|
|
|
$args = $self->_build_args($args, ['name', 'waitForSync']); |
158
|
|
|
|
|
|
|
# make request |
159
|
0
|
0
|
|
|
|
|
my $res = $self->arango->http->put( |
160
|
|
|
|
|
|
|
$self->api_path('gharial', $self->graph->name, $self->_class, $self->collection->name, delete $args->{name}), |
161
|
|
|
|
|
|
|
$args, |
162
|
|
|
|
|
|
|
$JSON->encode($data), |
163
|
|
|
|
|
|
|
) or return; |
164
|
|
|
|
|
|
|
# get response data |
165
|
0
|
0
|
|
|
|
|
$res = $res->{$self->_class} |
166
|
|
|
|
|
|
|
or return; |
167
|
|
|
|
|
|
|
# copy response data to instance |
168
|
0
|
|
|
|
|
|
$self->_build_self($res, []); |
169
|
|
|
|
|
|
|
# if data is defined then replace data |
170
|
0
|
0
|
|
|
|
|
if (my $orig_data = $self->data) { |
171
|
0
|
|
|
|
|
|
%$orig_data = (); |
172
|
0
|
|
|
|
|
|
$orig_data->{$_} = $data->{$_} for keys %$data; |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
# otherwise use passed data |
175
|
|
|
|
|
|
|
else { |
176
|
0
|
|
|
|
|
|
$self->data($data); |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
# register object |
179
|
0
|
|
|
|
|
|
my $register = $self->_register; |
180
|
0
|
|
|
|
|
|
$self->collection->$register->{$self->name} = $self; |
181
|
|
|
|
|
|
|
|
182
|
0
|
|
|
|
|
|
return $self; |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
# waitForSync |
186
|
|
|
|
|
|
|
# |
187
|
|
|
|
|
|
|
# get/set waitForSync |
188
|
0
|
|
|
0
|
1
|
|
sub waitForSync { shift->_get_set_bool('waitForSync', @_) } |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
# _class |
191
|
|
|
|
|
|
|
# |
192
|
|
|
|
|
|
|
# internal name for class |
193
|
0
|
|
|
0
|
|
|
sub _class { 'vertex' } |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
# _register |
196
|
|
|
|
|
|
|
# |
197
|
|
|
|
|
|
|
# internal name for object index |
198
|
0
|
|
|
0
|
|
|
sub _register { 'vertices' } |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
1; |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
__END__ |