You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Martynas Jusevicius <ma...@graphity.org> on 2012/02/12 18:02:43 UTC

Adding named Model to a remote graph store via SPARQL Update

Hey,

lets suppose I have a
1. Model m
2. graph name http://host/graph
3. remote SPARQL 1.1 endpoint URI http://host/sparql

I want to use Jena to do a SPARQL Update to insert the Model as a
named graph on the endpoint.
In other words, I want to save the Model on http://host/sparql so that
it later would be accessible in SPARQL via GRAPH <http://host/graph>.

Is there a way to do this? The only example I've found that comes
close to what I need is the following:
http://linuxsoftwareblog.com/?p=843
It involves NG4J however, I would rather avoid that.
In any case, the API workflow seems to be quite complicated to do
something as simple. Why not allow smth like this?

  GraphstoreFactory.create("http://host/sparql").addNamedModel("http://host/graph",
m);

Martynas
graphity.org

Re: Adding named Model to a remote graph store via SPARQL Update

Posted by Andy Seaborne <an...@apache.org>.
On 13/02/12 13:41, Martynas Jusevicius wrote:
> I see. The problem is that Update is so far more widely supported than
> the Graph Store protocol.
>
> But what is the shortest way of turning Model into SPARQL Update
> (INSERT DATA I guess?) request?

Yes.

To get a string:

INSERT DATA {
--- n-triples output ---
}

This streams.

Prefix handling makes Turtle a little bit more complicated.  To get 
that, maybe create syntax programmatically via UpdateDataInsert, add the 
data as quads and serialize.

	Andy

>
> Martynas
>
> On Mon, Feb 13, 2012 at 1:00 PM, Andy Seaborne<an...@apache.org>  wrote:
>> On 12/02/12 17:44, Martynas Jusevicius wrote:
>>>
>>> I've now come across Fuseki's DatasetAccessor
>>>
>>> http://incubator.apache.org/jena/documentation/javadoc/fuseki/org/openjena/fuseki/DatasetAccessor.html
>>> which seems to be the kind of interface I was thinking about.
>>> But it doesn't look like there is an implementation over SPARQL Update?
>>
>>
>> It works over SPARQL 1.1 Graph Store Protocol.
>>
>> That happens to have a mapping to SPARQL Update as given in the spec but the
>> whole graph protocol is more efficient.
>>
>> It also works for non-SPARQL environments.
>>
>> A third implementation of DatasetGraphAccessor could be added which used
>> SPARQL Update. Fuseki makes good use of the Graph Store Protocol already.
>>
>>         Andy
>>
>>
>>> On Sun, Feb 12, 2012 at 6:02 PM, Martynas Jusevicius
>>> <ma...@graphity.org>    wrote:
>>>>
>>>> Hey,
>>>>
>>>> lets suppose I have a
>>>> 1. Model m
>>>> 2. graph name http://host/graph
>>>> 3. remote SPARQL 1.1 endpoint URI http://host/sparql
>>>>
>>>> I want to use Jena to do a SPARQL Update to insert the Model as a
>>>> named graph on the endpoint.
>>>> In other words, I want to save the Model on http://host/sparql so that
>>>> it later would be accessible in SPARQL via GRAPH<http://host/graph>.
>>>>
>>>> Is there a way to do this? The only example I've found that comes
>>>> close to what I need is the following:
>>>> http://linuxsoftwareblog.com/?p=843
>>>> It involves NG4J however, I would rather avoid that.
>>>> In any case, the API workflow seems to be quite complicated to do
>>>> something as simple. Why not allow smth like this?
>>>>
>>>>
>>>>   GraphstoreFactory.create("http://host/sparql").addNamedModel("http://host/graph",
>>>> m);
>>>>
>>>> Martynas
>>>> graphity.org
>>
>>


Re: Adding named Model to a remote graph store via SPARQL Update

Posted by Damian Steer <d....@bristol.ac.uk>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 13/02/12 13:41, Martynas Jusevicius wrote:
> I see. The problem is that Update is so far more widely supported
> than the Graph Store protocol.
> 
> But what is the shortest way of turning Model into SPARQL Update 
> (INSERT DATA I guess?) request?

I did this a while ago using INSERT DATA and the N-Triples writer.

Verbose, of course, but simple to code.

Damian

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk85FlUACgkQAyLCB+mTtyk85wCeOr1CqZpneZAzNz5gNZBMwzJS
6ucAn1hxWugpZH/BzKEZnhT5w9JYnptK
=SHo1
-----END PGP SIGNATURE-----

Re: Adding named Model to a remote graph store via SPARQL Update

Posted by Martynas Jusevicius <ma...@graphity.org>.
I see. The problem is that Update is so far more widely supported than
the Graph Store protocol.

But what is the shortest way of turning Model into SPARQL Update
(INSERT DATA I guess?) request?

Martynas

On Mon, Feb 13, 2012 at 1:00 PM, Andy Seaborne <an...@apache.org> wrote:
> On 12/02/12 17:44, Martynas Jusevicius wrote:
>>
>> I've now come across Fuseki's DatasetAccessor
>>
>> http://incubator.apache.org/jena/documentation/javadoc/fuseki/org/openjena/fuseki/DatasetAccessor.html
>> which seems to be the kind of interface I was thinking about.
>> But it doesn't look like there is an implementation over SPARQL Update?
>
>
> It works over SPARQL 1.1 Graph Store Protocol.
>
> That happens to have a mapping to SPARQL Update as given in the spec but the
> whole graph protocol is more efficient.
>
> It also works for non-SPARQL environments.
>
> A third implementation of DatasetGraphAccessor could be added which used
> SPARQL Update. Fuseki makes good use of the Graph Store Protocol already.
>
>        Andy
>
>
>> On Sun, Feb 12, 2012 at 6:02 PM, Martynas Jusevicius
>> <ma...@graphity.org>  wrote:
>>>
>>> Hey,
>>>
>>> lets suppose I have a
>>> 1. Model m
>>> 2. graph name http://host/graph
>>> 3. remote SPARQL 1.1 endpoint URI http://host/sparql
>>>
>>> I want to use Jena to do a SPARQL Update to insert the Model as a
>>> named graph on the endpoint.
>>> In other words, I want to save the Model on http://host/sparql so that
>>> it later would be accessible in SPARQL via GRAPH<http://host/graph>.
>>>
>>> Is there a way to do this? The only example I've found that comes
>>> close to what I need is the following:
>>> http://linuxsoftwareblog.com/?p=843
>>> It involves NG4J however, I would rather avoid that.
>>> In any case, the API workflow seems to be quite complicated to do
>>> something as simple. Why not allow smth like this?
>>>
>>>
>>>  GraphstoreFactory.create("http://host/sparql").addNamedModel("http://host/graph",
>>> m);
>>>
>>> Martynas
>>> graphity.org
>
>

Re: Adding named Model to a remote graph store via SPARQL Update

Posted by Andy Seaborne <an...@apache.org>.
On 12/02/12 17:44, Martynas Jusevicius wrote:
> I've now come across Fuseki's DatasetAccessor
> http://incubator.apache.org/jena/documentation/javadoc/fuseki/org/openjena/fuseki/DatasetAccessor.html
> which seems to be the kind of interface I was thinking about.
> But it doesn't look like there is an implementation over SPARQL Update?

It works over SPARQL 1.1 Graph Store Protocol.

That happens to have a mapping to SPARQL Update as given in the spec but 
the whole graph protocol is more efficient.

It also works for non-SPARQL environments.

A third implementation of DatasetGraphAccessor could be added which used 
SPARQL Update. Fuseki makes good use of the Graph Store Protocol already.

	Andy

> On Sun, Feb 12, 2012 at 6:02 PM, Martynas Jusevicius
> <ma...@graphity.org>  wrote:
>> Hey,
>>
>> lets suppose I have a
>> 1. Model m
>> 2. graph name http://host/graph
>> 3. remote SPARQL 1.1 endpoint URI http://host/sparql
>>
>> I want to use Jena to do a SPARQL Update to insert the Model as a
>> named graph on the endpoint.
>> In other words, I want to save the Model on http://host/sparql so that
>> it later would be accessible in SPARQL via GRAPH<http://host/graph>.
>>
>> Is there a way to do this? The only example I've found that comes
>> close to what I need is the following:
>> http://linuxsoftwareblog.com/?p=843
>> It involves NG4J however, I would rather avoid that.
>> In any case, the API workflow seems to be quite complicated to do
>> something as simple. Why not allow smth like this?
>>
>>   GraphstoreFactory.create("http://host/sparql").addNamedModel("http://host/graph",
>> m);
>>
>> Martynas
>> graphity.org


Re: Adding named Model to a remote graph store via SPARQL Update

Posted by Martynas Jusevicius <ma...@graphity.org>.
I've now come across Fuseki's DatasetAccessor
http://incubator.apache.org/jena/documentation/javadoc/fuseki/org/openjena/fuseki/DatasetAccessor.html
which seems to be the kind of interface I was thinking about.
But it doesn't look like there is an implementation over SPARQL Update?

On Sun, Feb 12, 2012 at 6:02 PM, Martynas Jusevicius
<ma...@graphity.org> wrote:
> Hey,
>
> lets suppose I have a
> 1. Model m
> 2. graph name http://host/graph
> 3. remote SPARQL 1.1 endpoint URI http://host/sparql
>
> I want to use Jena to do a SPARQL Update to insert the Model as a
> named graph on the endpoint.
> In other words, I want to save the Model on http://host/sparql so that
> it later would be accessible in SPARQL via GRAPH <http://host/graph>.
>
> Is there a way to do this? The only example I've found that comes
> close to what I need is the following:
> http://linuxsoftwareblog.com/?p=843
> It involves NG4J however, I would rather avoid that.
> In any case, the API workflow seems to be quite complicated to do
> something as simple. Why not allow smth like this?
>
>  GraphstoreFactory.create("http://host/sparql").addNamedModel("http://host/graph",
> m);
>
> Martynas
> graphity.org

Re: Adding named Model to a remote graph store via SPARQL Update

Posted by Andy Seaborne <an...@apache.org>.
On 22/02/12 20:31, Paolo Castagna wrote:
> Hi
>
> Martynas Jusevicius wrote:
>> Hey again,
>>
>> I can't use Jena newer than 2.6.4 since SPIN API 1.2.0 is built on that...
>>
>> Can I reuse something from the Fuseki package?

Things to try:

1/ Summon Holger from the murky depths and ask nicely for an updated build.

2/ Drop in the latest jars (Jena and ARQ and TDB) and see if things 
still work.

It only says:
"""
The library [SPIN API] has been tested with Jena 2.6.4 and ARQ 2.8.7. 
Release date: 2011-05-31
"""

3/ Try Fuseki 0.2.0 from 
http://openjena.org/repo/org/openjena/fuseki/0.2.0/ and see if things 
work for you.

     <ver.jena>2.6.4</ver.jena>
     <ver.arq>2.8.8</ver.arq>
     <ver.tdb>0.8.10</ver.tdb>

but lots of things have moved on since.  It serves one dataset which is 
either in memory of TDB ... so it and SPIN aren't going to be in the 
same JVM => no problem.

4/ Rebuild Fuseki from source, using old jars.

If Fuseki and SPIN in the same JVM, how are they combined?

	Andy

>
> I don't see how that would help in your case, but I am not sure.
> I do not know much about SPIN.
>
>> Can't find it on Maven though.
>
> Fuseki has not been released yet in Apache.
>
> SNAPSHOTS are here if you want to test it out and see if it can help you:
> https://repository.apache.org/content/repositories/snapshots/org/apache/jena/jena-fuseki/
> But, please, remember: they are SNAPSHOTS.
>
> Paolo
>
>>
>> Martynas
>>
>> On Mon, Feb 13, 2012 at 9:31 AM, Paolo Castagna
>> <ca...@googlemail.com>  wrote:
>>> Paolo Castagna wrote:
>>>>   - UpdateExecutionFactory.createRemote(Update update, String remoteEndpoint) to create an UpdateProcessor that send the update request to a remote SPARQL Update service. --
>>>> https://svn.apache.org/repos/asf/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/update/UpdateExecutionFactory.java
>>>>   - https://svn.apache.org/repos/asf/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/modify/UpdateProcessRemote.java
>>> Andy added this in trunk and it will be released with ARQ 2.9.1, as per ChangeLog.txt:
>>> https://svn.apache.org/repos/asf/incubator/jena/Jena2/ARQ/trunk/ChangeLog.txt
>>> https://issues.apache.org/jira/browse/JENA-197
>>>
>>> Paolo
>


Re: Adding named Model to a remote graph store via SPARQL Update

Posted by Paolo Castagna <ca...@googlemail.com>.
Hi

Martynas Jusevicius wrote:
> Hey again,
> 
> I can't use Jena newer than 2.6.4 since SPIN API 1.2.0 is built on that...
> 
> Can I reuse something from the Fuseki package? 

I don't see how that would help in your case, but I am not sure.
I do not know much about SPIN.

> Can't find it on Maven though.

Fuseki has not been released yet in Apache.

SNAPSHOTS are here if you want to test it out and see if it can help you:
https://repository.apache.org/content/repositories/snapshots/org/apache/jena/jena-fuseki/
But, please, remember: they are SNAPSHOTS.

Paolo

> 
> Martynas
> 
> On Mon, Feb 13, 2012 at 9:31 AM, Paolo Castagna
> <ca...@googlemail.com> wrote:
>> Paolo Castagna wrote:
>>>  - UpdateExecutionFactory.createRemote(Update update, String remoteEndpoint) to create an UpdateProcessor that send the update request to a remote SPARQL Update service. --
>>> https://svn.apache.org/repos/asf/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/update/UpdateExecutionFactory.java
>>>  - https://svn.apache.org/repos/asf/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/modify/UpdateProcessRemote.java
>> Andy added this in trunk and it will be released with ARQ 2.9.1, as per ChangeLog.txt:
>> https://svn.apache.org/repos/asf/incubator/jena/Jena2/ARQ/trunk/ChangeLog.txt
>> https://issues.apache.org/jira/browse/JENA-197
>>
>> Paolo


Re: Adding named Model to a remote graph store via SPARQL Update

Posted by Martynas Jusevicius <ma...@graphity.org>.
Hey again,

I can't use Jena newer than 2.6.4 since SPIN API 1.2.0 is built on that...

Can I reuse something from the Fuseki package? Can't find it on Maven though.

Martynas

On Mon, Feb 13, 2012 at 9:31 AM, Paolo Castagna
<ca...@googlemail.com> wrote:
> Paolo Castagna wrote:
>>  - UpdateExecutionFactory.createRemote(Update update, String remoteEndpoint) to create an UpdateProcessor that send the update request to a remote SPARQL Update service. --
>> https://svn.apache.org/repos/asf/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/update/UpdateExecutionFactory.java
>>  - https://svn.apache.org/repos/asf/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/modify/UpdateProcessRemote.java
>
> Andy added this in trunk and it will be released with ARQ 2.9.1, as per ChangeLog.txt:
> https://svn.apache.org/repos/asf/incubator/jena/Jena2/ARQ/trunk/ChangeLog.txt
> https://issues.apache.org/jira/browse/JENA-197
>
> Paolo

Re: Adding named Model to a remote graph store via SPARQL Update

Posted by Paolo Castagna <ca...@googlemail.com>.
Paolo Castagna wrote:
>  - UpdateExecutionFactory.createRemote(Update update, String remoteEndpoint) to create an UpdateProcessor that send the update request to a remote SPARQL Update service. --
> https://svn.apache.org/repos/asf/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/update/UpdateExecutionFactory.java
>  - https://svn.apache.org/repos/asf/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/modify/UpdateProcessRemote.java

Andy added this in trunk and it will be released with ARQ 2.9.1, as per ChangeLog.txt:
https://svn.apache.org/repos/asf/incubator/jena/Jena2/ARQ/trunk/ChangeLog.txt
https://issues.apache.org/jira/browse/JENA-197

Paolo

Re: Adding named Model to a remote graph store via SPARQL Update

Posted by Paolo Castagna <ca...@googlemail.com>.
Hi Martynas,
see Example 2 of section 3.1.1 INSERT DATA of the spec: "As opposed to the previous example, which affected the default graph, the requested change happens in the named graph identified by the IRI
http://example/bookStore." -- http://www.w3.org/TR/sparql11-update/#insertData

See also:

 - http://incubator.apache.org/jena/documentation/query/update.html
 - http://www.w3.org/TR/sparql11-http-rdf-update/#http-post
 - UpdateExecutionFactory.createRemote(Update update, String remoteEndpoint) to create an UpdateProcessor that send the update request to a remote SPARQL Update service. --
https://svn.apache.org/repos/asf/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/update/UpdateExecutionFactory.java
 - https://svn.apache.org/repos/asf/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/modify/UpdateProcessRemote.java

Paolo


Martynas Jusevicius wrote:
> Hey,
> 
> lets suppose I have a
> 1. Model m
> 2. graph name http://host/graph
> 3. remote SPARQL 1.1 endpoint URI http://host/sparql
> 
> I want to use Jena to do a SPARQL Update to insert the Model as a
> named graph on the endpoint.
> In other words, I want to save the Model on http://host/sparql so that
> it later would be accessible in SPARQL via GRAPH <http://host/graph>.
> 
> Is there a way to do this? The only example I've found that comes
> close to what I need is the following:
> http://linuxsoftwareblog.com/?p=843
> It involves NG4J however, I would rather avoid that.
> In any case, the API workflow seems to be quite complicated to do
> something as simple. Why not allow smth like this?
> 
>   GraphstoreFactory.create("http://host/sparql").addNamedModel("http://host/graph",
> m);
> 
> Martynas
> graphity.org