line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ArangoDB2::Graph; |
2
|
|
|
|
|
|
|
|
3
|
20
|
|
|
20
|
|
81
|
use strict; |
|
20
|
|
|
|
|
22
|
|
|
20
|
|
|
|
|
635
|
|
4
|
20
|
|
|
20
|
|
817
|
use warnings; |
|
20
|
|
|
|
|
687
|
|
|
20
|
|
|
|
|
524
|
|
5
|
|
|
|
|
|
|
|
6
|
20
|
|
|
|
|
2227
|
use base qw( |
7
|
|
|
|
|
|
|
ArangoDB2::Base |
8
|
20
|
|
|
20
|
|
1439
|
); |
|
20
|
|
|
|
|
1350
|
|
9
|
|
|
|
|
|
|
|
10
|
20
|
|
|
20
|
|
812
|
use Data::Dumper; |
|
20
|
|
|
|
|
1301
|
|
|
20
|
|
|
|
|
1458
|
|
11
|
20
|
|
|
20
|
|
1332
|
use JSON::XS; |
|
20
|
|
|
|
|
21
|
|
|
20
|
|
|
|
|
2057
|
|
12
|
|
|
|
|
|
|
|
13
|
20
|
|
|
20
|
|
8840
|
use ArangoDB2::Graph::EdgeDefinition; |
|
20
|
|
|
|
|
32
|
|
|
20
|
|
|
|
|
464
|
|
14
|
20
|
|
|
20
|
|
7022
|
use ArangoDB2::Graph::VertexCollection; |
|
20
|
|
|
|
|
33
|
|
|
20
|
|
|
|
|
424
|
|
15
|
20
|
|
|
20
|
|
6627
|
use ArangoDB2::Traversal; |
|
20
|
|
|
|
|
33
|
|
|
20
|
|
|
|
|
11502
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $JSON = JSON::XS->new->utf8; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# create |
22
|
|
|
|
|
|
|
# |
23
|
|
|
|
|
|
|
# POST /_api/gharial |
24
|
|
|
|
|
|
|
sub create |
25
|
|
|
|
|
|
|
{ |
26
|
0
|
|
|
0
|
1
|
0
|
my($self, $args) = @_; |
27
|
|
|
|
|
|
|
# process request args |
28
|
0
|
|
|
|
|
0
|
$args = $self->_build_args($args, ['edgeDefinitions', 'name', 'orphanCollections']); |
29
|
|
|
|
|
|
|
# make request |
30
|
0
|
0
|
|
|
|
0
|
my $res = $self->arango->http->post( |
31
|
|
|
|
|
|
|
$self->api_path('gharial'), |
32
|
|
|
|
|
|
|
undef, |
33
|
|
|
|
|
|
|
$JSON->encode($args), |
34
|
|
|
|
|
|
|
) or return; |
35
|
|
|
|
|
|
|
# copy param data from res to self |
36
|
0
|
|
|
|
|
0
|
$self->_build_self($res, ['edgeDefinitions', 'name', 'orphanCollections']); |
37
|
|
|
|
|
|
|
# register instance |
38
|
0
|
|
|
|
|
0
|
$self->database->graphs->{$self->name} = $self; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
0
|
return $self; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# delete |
44
|
|
|
|
|
|
|
# |
45
|
|
|
|
|
|
|
# DELETE /_api/gharial/graph-name |
46
|
|
|
|
|
|
|
sub delete |
47
|
|
|
|
|
|
|
{ |
48
|
0
|
|
|
0
|
1
|
0
|
my($self, $args) = @_; |
49
|
|
|
|
|
|
|
# process request args |
50
|
0
|
|
|
|
|
0
|
$args = $self->_build_args($args, ['dropCollections', 'name']); |
51
|
|
|
|
|
|
|
# make request |
52
|
0
|
0
|
|
|
|
0
|
my $res = $self->arango->http->delete( |
53
|
|
|
|
|
|
|
$self->api_path('gharial', delete $args->{name}), |
54
|
|
|
|
|
|
|
$args, |
55
|
|
|
|
|
|
|
) or return; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# remove register instance |
58
|
0
|
|
|
|
|
0
|
delete $self->database->graphs->{$self->name}; |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
0
|
return $res; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# dropCollections |
64
|
|
|
|
|
|
|
# |
65
|
|
|
|
|
|
|
# get/set dropCollections |
66
|
0
|
|
|
0
|
1
|
0
|
sub dropCollections { shift->_get_set('dropCollections', @_) } |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# edgeDefinition |
69
|
|
|
|
|
|
|
# |
70
|
|
|
|
|
|
|
# return ArangoDB2::Graph::EdgeDefinition object |
71
|
|
|
|
|
|
|
sub edgeDefinition |
72
|
|
|
|
|
|
|
{ |
73
|
2
|
|
|
2
|
1
|
10
|
my($self, $name) = @_; |
74
|
|
|
|
|
|
|
|
75
|
2
|
50
|
|
|
|
7
|
if (defined $name) { |
76
|
0
|
|
0
|
|
|
0
|
return $self->edgeDefinitionRegister->{name} ||= ArangoDB2::Graph::EdgeDefinition->new( |
77
|
|
|
|
|
|
|
$self->arango, |
78
|
|
|
|
|
|
|
$self->database, |
79
|
|
|
|
|
|
|
$self, |
80
|
|
|
|
|
|
|
$name, |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
else { |
84
|
2
|
|
|
|
|
11
|
return ArangoDB2::Graph::EdgeDefinition->new( |
85
|
|
|
|
|
|
|
$self->arango, |
86
|
|
|
|
|
|
|
$self->database, |
87
|
|
|
|
|
|
|
$self, |
88
|
|
|
|
|
|
|
); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# edgeDefinitionRegister |
93
|
|
|
|
|
|
|
# |
94
|
|
|
|
|
|
|
# index of ArangoDB2::Graph::EdgeDefinition objects by name |
95
|
0
|
|
0
|
0
|
1
|
0
|
sub edgeDefinitionRegister { $_[0]->{edgeDefinitionRegister} ||= {} } |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# edgeDefinitions |
98
|
|
|
|
|
|
|
# |
99
|
|
|
|
|
|
|
# get/set edgeDefinitions |
100
|
0
|
|
|
0
|
1
|
0
|
sub edgeDefinitions { shift->_get_set('edgeDefinitions', @_) } |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# get |
103
|
|
|
|
|
|
|
# |
104
|
|
|
|
|
|
|
# GET /_api/gharial/graph-name |
105
|
|
|
|
|
|
|
sub get |
106
|
|
|
|
|
|
|
{ |
107
|
0
|
|
|
0
|
1
|
0
|
my($self, $args) = @_; |
108
|
|
|
|
|
|
|
# process args |
109
|
0
|
|
|
|
|
0
|
$args = $self->_build_args($args, ['name']); |
110
|
|
|
|
|
|
|
# make request |
111
|
0
|
0
|
|
|
|
0
|
my $res = $self->arango->http->get( |
112
|
|
|
|
|
|
|
$self->api_path('gharial', delete $args->{name}) |
113
|
|
|
|
|
|
|
) or return; |
114
|
|
|
|
|
|
|
# copy param data from res to self |
115
|
0
|
|
|
|
|
0
|
$self->_build_self($res, ['edgeDefinitions', 'name', 'orphanCollections']); |
116
|
|
|
|
|
|
|
# register instance |
117
|
0
|
|
|
|
|
0
|
$self->database->graphs->{$self->name} = $self; |
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
0
|
return $self; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
# list |
123
|
|
|
|
|
|
|
# |
124
|
|
|
|
|
|
|
# GET /_api/gharial |
125
|
|
|
|
|
|
|
sub list |
126
|
|
|
|
|
|
|
{ |
127
|
0
|
|
|
0
|
1
|
0
|
my($self) = @_; |
128
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
0
|
return $self->arango->http->get( |
130
|
|
|
|
|
|
|
$self->api_path('gharial') |
131
|
|
|
|
|
|
|
); |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
# orphanCollections |
135
|
|
|
|
|
|
|
# |
136
|
|
|
|
|
|
|
# get/set orphanCollections |
137
|
0
|
|
|
0
|
1
|
0
|
sub orphanCollections { shift->_get_set('orphanCollections', @_) } |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
# traversal |
140
|
|
|
|
|
|
|
# |
141
|
|
|
|
|
|
|
# get a new ArangoDB2::Traversal object |
142
|
|
|
|
|
|
|
sub traversal |
143
|
|
|
|
|
|
|
{ |
144
|
1
|
|
|
1
|
1
|
6
|
my($self) = @_; |
145
|
|
|
|
|
|
|
|
146
|
1
|
|
|
|
|
6
|
return ArangoDB2::Traversal->new( |
147
|
|
|
|
|
|
|
$self->arango, |
148
|
|
|
|
|
|
|
$self->database, |
149
|
|
|
|
|
|
|
$self, |
150
|
|
|
|
|
|
|
); |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
# vertexCollection |
154
|
|
|
|
|
|
|
# |
155
|
|
|
|
|
|
|
# return ArangoDB2::Graph::VertexCollection object |
156
|
|
|
|
|
|
|
sub vertexCollection |
157
|
|
|
|
|
|
|
{ |
158
|
2
|
|
|
2
|
1
|
11
|
my($self, $name) = @_; |
159
|
|
|
|
|
|
|
|
160
|
2
|
50
|
|
|
|
6
|
if (defined $name) { |
161
|
0
|
|
0
|
|
|
0
|
return $self->vertexCollections->{name} ||= ArangoDB2::Graph::VertexCollection->new( |
162
|
|
|
|
|
|
|
$self->arango, |
163
|
|
|
|
|
|
|
$self->database, |
164
|
|
|
|
|
|
|
$self, |
165
|
|
|
|
|
|
|
$name, |
166
|
|
|
|
|
|
|
); |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
else { |
169
|
2
|
|
|
|
|
12
|
return ArangoDB2::Graph::VertexCollection->new( |
170
|
|
|
|
|
|
|
$self->arango, |
171
|
|
|
|
|
|
|
$self->database, |
172
|
|
|
|
|
|
|
$self, |
173
|
|
|
|
|
|
|
); |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
# vertexCollections |
178
|
|
|
|
|
|
|
# |
179
|
|
|
|
|
|
|
# index of ArangoDB2::Graph::VertexCollection objects by name |
180
|
0
|
|
0
|
0
|
1
|
0
|
sub vertexCollections { $_->{vertexCollections} ||= {} } |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
# _class |
183
|
|
|
|
|
|
|
# |
184
|
|
|
|
|
|
|
# internal name for class |
185
|
7
|
|
|
7
|
|
22
|
sub _class { 'graph' } |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
1; |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
__END__ |