line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package RDF::Sesame; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
262942
|
use strict; |
|
8
|
|
|
|
|
20
|
|
|
8
|
|
|
|
|
364
|
|
4
|
8
|
|
|
8
|
|
47
|
use warnings; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
243
|
|
5
|
|
|
|
|
|
|
|
6
|
8
|
|
|
8
|
|
4969
|
use RDF::Sesame::Connection; |
|
8
|
|
|
|
|
24
|
|
|
8
|
|
|
|
|
254
|
|
7
|
8
|
|
|
8
|
|
10874
|
use RDF::Sesame::Response; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use RDF::Sesame::TableResult; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = "0.17"; |
11
|
|
|
|
|
|
|
our $errstr; # holds the error string from a failed connect |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
RDF::Sesame - Interact with Sesame RDF servers |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use RDF::Sesame; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Connect anonymously to Sesame on localhost port 80 |
22
|
|
|
|
|
|
|
my $sesame = RDF::Sesame->connect; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# or anonymously on a remote Sesame server |
25
|
|
|
|
|
|
|
$sesame = RDF::Sesame->connect('openrdf.org'); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# or explicitly specify the options |
28
|
|
|
|
|
|
|
$sesame = RDF::Sesame->connect( |
29
|
|
|
|
|
|
|
host => "openrdf.org", |
30
|
|
|
|
|
|
|
port => 80 |
31
|
|
|
|
|
|
|
directory => "sesame", |
32
|
|
|
|
|
|
|
username => "testuser", |
33
|
|
|
|
|
|
|
password => "opensesame" |
34
|
|
|
|
|
|
|
) or die "Couldn't connect to Sesame : $RDF::Sesame::errstr\n"; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# or explicitly specify using a single URI |
37
|
|
|
|
|
|
|
$sesame = RDF::Sesame->connect( |
38
|
|
|
|
|
|
|
uri => 'http://testuser:opensesame@openrdf.org:80/sesame' |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my @repos = $sesame->repositories; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# open a repository the easy way |
44
|
|
|
|
|
|
|
my $vcard = $sesame->open("vcard"); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# or the more flexible way (allowing other named options) |
47
|
|
|
|
|
|
|
my $museum = $sesame->open(id => "museum"); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my $serql = <
|
50
|
|
|
|
|
|
|
select x, given, family |
51
|
|
|
|
|
|
|
from |
52
|
|
|
|
|
|
|
{x} vCard:N {n}, |
53
|
|
|
|
|
|
|
{n} vCard:Given {given}; |
54
|
|
|
|
|
|
|
vCard:Family {family} |
55
|
|
|
|
|
|
|
using namespace |
56
|
|
|
|
|
|
|
vCard = |
57
|
|
|
|
|
|
|
END |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
my $results = $vcard->select( |
60
|
|
|
|
|
|
|
query => $serql, |
61
|
|
|
|
|
|
|
language => "SeRQL" |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
$vcard->query_language("SeRQL"); |
65
|
|
|
|
|
|
|
$results = $vcard->select($serql); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# $results is a Data::Table object (via RDF::Sesame::TableResults) |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 DESCRIPTION |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
The RDF::Sesame module implements a wrapper around the RESTful API |
72
|
|
|
|
|
|
|
(HTTP protocol) provided by Sesame L. It facilitates |
73
|
|
|
|
|
|
|
connecting, adding data and querying a Sesame server from Perl. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
RDF::Sesame itself only provides a method for creating a Connection |
76
|
|
|
|
|
|
|
object. See the documentation for L, |
77
|
|
|
|
|
|
|
L, and L. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 STATUS |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This module is in beta testing. The algorithms have been tested |
82
|
|
|
|
|
|
|
thoroughly and are stable. The API might change in a few particulars, |
83
|
|
|
|
|
|
|
hopefully in a backwards-compatible manner. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 METHODS |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 connect ( %opts ) |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Connects to a Sesame server and creates an instance of an |
90
|
|
|
|
|
|
|
RDF::Sesame::Connection object. This object can be used to create |
91
|
|
|
|
|
|
|
an RDF::Sesame::Repository object or (less likely) to execute commands |
92
|
|
|
|
|
|
|
against a Sesame server. Creating an RDF::Sesame::Repository object is |
93
|
|
|
|
|
|
|
the preferred way, so do that. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
The HTTP connection to the server is created with Keep-Alive enabled in |
96
|
|
|
|
|
|
|
an attempt to make consecutive requests speedier. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
The C<%opts> parameter is a hash of options to use when creating the |
99
|
|
|
|
|
|
|
connection. Below is a list of the currently understood options. If a single |
100
|
|
|
|
|
|
|
scalar is provided to connect(), it will be treated as the host and |
101
|
|
|
|
|
|
|
all other options will use the default values. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head3 host |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
The host name or address of the sesame server. For example 'openrdf.org' |
106
|
|
|
|
|
|
|
or 'openrdf.org:8080'. It's B a URI. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Default: localhost |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head3 port |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
The port number on which the Sesame server is listening. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Default: 80 |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head3 directory |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
The sesame directory on the host. The directory should be specified without |
119
|
|
|
|
|
|
|
leading or trailing '/' characters. However, if those characters are provided, |
120
|
|
|
|
|
|
|
they will be stripped before further processing. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Default: sesame |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head3 username |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
The username to use for logging in to the server. If this option is not |
127
|
|
|
|
|
|
|
specified (or C), no login will be attempted and only publicly available |
128
|
|
|
|
|
|
|
repositories will be visible. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head3 password |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
The password to use for logging in to the server. If this option is not |
133
|
|
|
|
|
|
|
supplied but the 'username' option is specified, a password consisting of |
134
|
|
|
|
|
|
|
the empty string will be used to log in. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head3 uri |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
A URI specifying how to connect to the Sesame server. All of the above |
139
|
|
|
|
|
|
|
options may be specified at once by providing them in the URI in standard |
140
|
|
|
|
|
|
|
format. Here is an example URI |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
http://username:password@host:port/directory |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
If any of the parts are not specified, the defaults explained above will be |
145
|
|
|
|
|
|
|
used instead. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head3 timeout |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
When communicating with the Sesame server, RDF::Sesame usually waits 10 |
150
|
|
|
|
|
|
|
seconds for the server to respond. If there is no response within that |
151
|
|
|
|
|
|
|
time, the server is considered unreachable. This option allows you |
152
|
|
|
|
|
|
|
to change this behavior. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub connect { |
157
|
|
|
|
|
|
|
shift @_; # remove the class name |
158
|
|
|
|
|
|
|
RDF::Sesame::Connection->new(@_); |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 CONFIGURATION AND ENVIRONMENT |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
RDF::Sesame can generate very limited debugging/profiling output. By setting |
164
|
|
|
|
|
|
|
the environment variable C to a true value, each request to |
165
|
|
|
|
|
|
|
the Sesame server will generate a message on STDERR. Here is a short sample: |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Command 0 : Ran login in 30 ms |
168
|
|
|
|
|
|
|
Command 1 : Ran evaluateTableQuery in 45 ms |
169
|
|
|
|
|
|
|
Command 2 : Ran evaluateTableQuery in 120 ms |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
The time value generated with each message is the number of milliseconds it |
172
|
|
|
|
|
|
|
took to process the command including network time, database processing time |
173
|
|
|
|
|
|
|
and response processing time. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head1 COMPATIBILITY |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
The following table indicates RDF::Sesame's compatibility with different |
178
|
|
|
|
|
|
|
versions of Sesame and different sail implementations. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Sesame 1.2.6 : native - OK |
181
|
|
|
|
|
|
|
memory - OK |
182
|
|
|
|
|
|
|
Sesame 1.2.4 : native - OK |
183
|
|
|
|
|
|
|
memory - OK |
184
|
|
|
|
|
|
|
Sesame 1.2.3 : native - OK |
185
|
|
|
|
|
|
|
memory - OK |
186
|
|
|
|
|
|
|
Sesame 1.2.2 : native - OK |
187
|
|
|
|
|
|
|
memory - OK |
188
|
|
|
|
|
|
|
Sesame 1.2.1 : native - OK |
189
|
|
|
|
|
|
|
memory - OK |
190
|
|
|
|
|
|
|
Sesame 1.2 : native - FAIL (known bug) |
191
|
|
|
|
|
|
|
memory - OK |
192
|
|
|
|
|
|
|
Sesame 1.1.3 : native - OK |
193
|
|
|
|
|
|
|
memory - OK |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
I've not personally tested Sesame versions earlier than 1.1.3 but they may work. |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 COVERAGE |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Test coverage results provided by L |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
----------------------------------- ------ ------ ------ ------ ------ ------ |
202
|
|
|
|
|
|
|
File stmt bran cond sub time total |
203
|
|
|
|
|
|
|
----------------------------------- ------ ------ ------ ------ ------ ------ |
204
|
|
|
|
|
|
|
lib/RDF/Sesame.pm 100.0 n/a n/a 100.0 1.1 100.0 |
205
|
|
|
|
|
|
|
lib/RDF/Sesame/Connection.pm 100.0 100.0 100.0 100.0 20.5 100.0 |
206
|
|
|
|
|
|
|
lib/RDF/Sesame/Repository.pm 96.7 95.9 n/a 100.0 9.0 96.7 |
207
|
|
|
|
|
|
|
lib/RDF/Sesame/Response.pm 100.0 100.0 n/a 100.0 46.4 100.0 |
208
|
|
|
|
|
|
|
lib/RDF/Sesame/TableResult.pm 91.2 82.4 n/a 100.0 23.0 88.7 |
209
|
|
|
|
|
|
|
Total 96.2 92.2 100.0 100.0 100.0 95.4 |
210
|
|
|
|
|
|
|
----------------------------------- ------ ------ ------ ------ ------ ------ |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head1 HELPING OUT |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
The latest source code for RDF-Sesame is available with git from |
215
|
|
|
|
|
|
|
L. You may also browse the repository |
216
|
|
|
|
|
|
|
at L. |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
Please email patches to the author. |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head1 SEE ALSO |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=over 4 |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=item L |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=item L |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=item L |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=back |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
Southwest Counseling Service for sponsoring the initial development |
235
|
|
|
|
|
|
|
L. |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=head1 AUTHOR |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
Michael Hendricks |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
Copyright (c) 2005-2006 Michael Hendricks (). All rights |
244
|
|
|
|
|
|
|
reserved. |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
247
|
|
|
|
|
|
|
under the same terms as Perl itself. |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=cut |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
1; |