[Mulgara-general] CRUD Operations in Java

Paul Gearon gearon at ieee.org
Wed Jul 22 18:23:09 UTC 2009


On Wed, Jul 22, 2009 at 11:48 AM, Chuck Borromeo<cborromeo3 at yahoo.com> wrote:
> David, Alex, and Paul-
>  Thanks for the information.  I have some followup questions:
>
> 1.  If I use the TQL REST interface, can I load an entire RDF file in one command or do I
> need to split the file up into separate triple statements?  If I can, can someone provide
> an example of how the URI would look?

You have 2 options here, depending on where the data is coming from.

First, you can POST the data to a graph. The graph is specified with a
parameter of "default-graph-uri", or an alias of just "graph". You can
provide this either in the URI or the body of the message. The file(s)
to upload are then passed in the body (these can use any parameter
name).  You *should* use content negotiation to specify the file
types, but if you don't it will try to fall back to a filename
extension (if you provide a file name).

Look at the bottom of this email for an example request with an
RDF/XML file to be loaded.

The second option is to do an INSERT/SELECT. This requires that the
file be available via URL from somewhere. The command then is
something like:

create <http://mydomain.com/mygraph>;
insert
  select $s $p $o
  from <http://somehost.com/the_file.rdf>
  where $s $p $o
into <http://mydomain.com/mygraph>;

In this case, the destination graph is: http://mydomain.com/mygraph
and the source is: http://somehost.com/the_file.rdf

You can also use other valid URLs. For instance, if the source is on
the same host as the Mulgara database, then you can use a file URL
like:
  file:/path/to/the_file.rdf

> 2.  Can someone supply me an example of the URI used to execute the following TQL delete on the TQL REST endpoint.  Do I need to pass the semicolon into the URI:
>
> delete (select $s $p 'University of Sinatra'
>        from <graphXYZ>
>        where $s $p 'University of Sinatra')
> from <graphXYZ>;

http://hostname.com:8080/tql/?query=delete+%28select+%24s+%24p+%27University+of+Sinatra%27+from+%3CgraphXYZ%3E+where+%24s+%24p+%27University+of+Sinatra%27%29+from+%3CgraphXYZ%3E

However, you MUST post this, since a GET cannot effect a change on the server.

> 3.  Will the SPARQL/Update specifications allow users to load an RDF (or n-triples, etc)
> file?

Yes.

> What is the rough timeline for the SPARQL/Update specification to be adopted?

Within the next few months. It's not too hard, but it's a matter of
time. I have priorities I have to meet, and I'm pretty sure I'll be
the one doing it.  :-(

> Is Mulgara definitely adopting SPARQL/Update?

Definitely.

> Thanks for a great product and support,
> Chuck

No problems. Thanks for using it.  :-)

Here is the example POST. This uses that file extension fallback that
I mentioned (handy when uploading from a web form)...

POST /sparql/ HTTP/1.1
Content-Length: 659
Content-Type: multipart/form-data; boundary=3KxptU9DXG-nRmAQO7e2W-FJFQhR7F
Host: localhost:8080
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.0-beta2 (java 1.5)

--3KxptU9DXG-nRmAQO7e2W-FJFQhR7F
Content-Disposition: form-data; name="default-graph-uri"
Content-Type: text/plain; charset=MacRoman
Content-Transfer-Encoding: 8bit

sparql:data
--3KxptU9DXG-nRmAQO7e2W-FJFQhR7F
Content-Disposition: form-data; name="data"; filename="data.rdf"
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:testdb="test:">
<rdf:Description rdf:about = "test:s01" >
  <testdb:p01 rdf:resource="test:o01"/>
  <testdb:p01 rdf:resource="test:o04"/>
</rdf:Description>
</rdf:RDF>

--3KxptU9DXG-nRmAQO7e2W-FJFQhR7F--


Regards,
Paul



More information about the Mulgara-general mailing list