You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Olivier Rossel <ol...@gmail.com> on 2012/11/26 18:02:58 UTC
Updating a SPARQL endpoint with the content of a Model
Hi folks!
I have a Model full of triples, and I wish I could "inject" these
data into a remote endpoint.
is there a helper class to create a SPARQL/Insert query from the
content of the Model?
Otherwise, what is the best way to create such a query? (Iterating the
triples, removing the blank nodes,
appending SPARQL statements to a StringBuffer. And that's all?
More advanced question: is it possible to monitor the lifecycle of a
Model (add/remove),
and create a SPARQL/Update that mimicks that lifecycle (to be sent on
a remote endpoint)?
What is the best way to do that with Jena? ModelChangedListener (and
string appending)?
Your points of view are highly welcome.
Re: Updating a SPARQL endpoint with the content of a Model
Posted by Dick & Hannah <da...@gmail.com>.
Re: Model Lifecycle.
This might help...
We have customised the QueryEngineWorker to provide what we call a journal. The journal intercepts all updates and makes entries into a separate dataset. This allows us to provide point in time reasoning across the original data. Ie what was the o for a given s and p over a time period. Also allows us to ship to another data store for load balancing and resiliency.
Regards
Dick Murray
Technology Specialist
UNIT4 Business Software
www.unit4.com
+44 1275 377359
+44 7884 111729
On 26 Nov 2012, at 17:02, Olivier Rossel <ol...@gmail.com> wrote:
> Hi folks!
>
> I have a Model full of triples, and I wish I could "inject" these
> data into a remote endpoint.
> is there a helper class to create a SPARQL/Insert query from the
> content of the Model?
> Otherwise, what is the best way to create such a query? (Iterating the
> triples, removing the blank nodes,
> appending SPARQL statements to a StringBuffer. And that's all?
>
> More advanced question: is it possible to monitor the lifecycle of a
> Model (add/remove),
> and create a SPARQL/Update that mimicks that lifecycle (to be sent on
> a remote endpoint)?
> What is the best way to do that with Jena? ModelChangedListener (and
> string appending)?
>
> Your points of view are highly welcome.
Re: Updating a SPARQL endpoint with the content of a Model
Posted by Stephen Allen <sa...@apache.org>.
Yes! It conforms to SPARQL 1.1 Update, so it should work with any endpoint
that implements the spec.
-Steve
On Tuesday, November 27, 2012, Olivier Rossel wrote:
> Is it generic for any SPARQL endpoint (4store, fuseki, virtuoso, ...)?
>
> On Tue, Nov 27, 2012 at 11:42 PM, Stephen Allen <sallen@apache.org<javascript:;>>
> wrote:
> > Also, you can try the experimental "jena-client" project. It is a
> > work-in-progress for interacting with SPARQL endpoints (both local and
> > remote).
> >
> > Instructions for building:
> > svn co
> https://svn.apache.org/repos/asf/jena/Experimental/jena-client/
> > jena-client
> > cd jena-client
> > mvn clean install
> >
> > Then include "target/jena-client-0.0.8-SNAPSHOT.jar" in your project's
> > classpath. Quick user guide:
> >
> > Model m = ... // Your Model with the statements you want to add to
> > the remote store
> > Repository repo =
> > RepositoryFactory.createRemote("http://localhost:3030/ds/query",
> > "http://localhost:3030/ds/update");
> > Connection conn = repo.getConnection();
> > try {
> > Updater up = conn.createStreamingUpdater();
> > try {
> > // The first parameter is the named graph to insert the
> > Triples into, null == default graph
> > up.insert(null, m.getGraph());
> > }
> > finally {
> > up.close();
> > }
> > }
> > finally {
> > conn.close();
> > }
> >
> >
> > Among the benefits of this: 1) it generates the SPARQL Update request
> > for you, and 2) it is fully streaming on the client side, so Model can
> > be large (streaming isn't supported on the server yet, see JENA-330).
> > 3) A single update request is transactional (a future goal would be
> > transactions across remote queries / requests)
> >
> > If you do use it, or even play around with it for a while, I would
> > love to get your feedback.
> >
> > -Stephen
> >
> > On Tue, Nov 27, 2012 at 6:16 AM, Andy Seaborne <andy@apache.org<javascript:;>>
> wrote:
> >> On 26/11/12 17:02, Olivier Rossel wrote:
> >>>
> >>> Hi folks!
> >>>
> >>> I have a Model full of triples, and I wish I could "inject" these
> >>> data into a remote endpoint. is there a helper class to create a
> >>> SPARQL/Insert query from the content of the Model? Otherwise, what is
> >>> the best way to create such a query? (Iterating the triples, removing
> >>> the blank nodes, appending SPARQL statements to a StringBuffer. And
> >>> that's all?
> >>
> >>
> >> DatasetAccessor (which for silly histroical reasons is in Fuseki) may
> help.
> >> It is the GSP protocol for Jena. You can POST a model.
> >>
> >> And also no need to mess with bNodes in a INSERT DATA operation.
> >>
> >>
> >>> More advanced question: is it possible to monitor the lifecycle of a
> >>> Model (add/remove), and create a SPARQL/Update that mimicks that
> >>> lifecycle (to be sent on a remote endpoint)? What is the best way to
> >>> do that with Jena? ModelChangedListener (and string appending)?
> >>
> >>
> >> Yes, probably.
> >>
> >> We have been discussing simplifying this to just have one "add" and one
> >> "remove" call.
> >>
> >>
> >>>
> >>> Your points of view are highly welcome.
> >>>
> >>
> >> Andy
>
Re: Updating a SPARQL endpoint with the content of a Model
Posted by Olivier Rossel <ol...@gmail.com>.
Is it generic for any SPARQL endpoint (4store, fuseki, virtuoso, ...)?
On Tue, Nov 27, 2012 at 11:42 PM, Stephen Allen <sa...@apache.org> wrote:
> Also, you can try the experimental "jena-client" project. It is a
> work-in-progress for interacting with SPARQL endpoints (both local and
> remote).
>
> Instructions for building:
> svn co https://svn.apache.org/repos/asf/jena/Experimental/jena-client/
> jena-client
> cd jena-client
> mvn clean install
>
> Then include "target/jena-client-0.0.8-SNAPSHOT.jar" in your project's
> classpath. Quick user guide:
>
> Model m = ... // Your Model with the statements you want to add to
> the remote store
> Repository repo =
> RepositoryFactory.createRemote("http://localhost:3030/ds/query",
> "http://localhost:3030/ds/update");
> Connection conn = repo.getConnection();
> try {
> Updater up = conn.createStreamingUpdater();
> try {
> // The first parameter is the named graph to insert the
> Triples into, null == default graph
> up.insert(null, m.getGraph());
> }
> finally {
> up.close();
> }
> }
> finally {
> conn.close();
> }
>
>
> Among the benefits of this: 1) it generates the SPARQL Update request
> for you, and 2) it is fully streaming on the client side, so Model can
> be large (streaming isn't supported on the server yet, see JENA-330).
> 3) A single update request is transactional (a future goal would be
> transactions across remote queries / requests)
>
> If you do use it, or even play around with it for a while, I would
> love to get your feedback.
>
> -Stephen
>
> On Tue, Nov 27, 2012 at 6:16 AM, Andy Seaborne <an...@apache.org> wrote:
>> On 26/11/12 17:02, Olivier Rossel wrote:
>>>
>>> Hi folks!
>>>
>>> I have a Model full of triples, and I wish I could "inject" these
>>> data into a remote endpoint. is there a helper class to create a
>>> SPARQL/Insert query from the content of the Model? Otherwise, what is
>>> the best way to create such a query? (Iterating the triples, removing
>>> the blank nodes, appending SPARQL statements to a StringBuffer. And
>>> that's all?
>>
>>
>> DatasetAccessor (which for silly histroical reasons is in Fuseki) may help.
>> It is the GSP protocol for Jena. You can POST a model.
>>
>> And also no need to mess with bNodes in a INSERT DATA operation.
>>
>>
>>> More advanced question: is it possible to monitor the lifecycle of a
>>> Model (add/remove), and create a SPARQL/Update that mimicks that
>>> lifecycle (to be sent on a remote endpoint)? What is the best way to
>>> do that with Jena? ModelChangedListener (and string appending)?
>>
>>
>> Yes, probably.
>>
>> We have been discussing simplifying this to just have one "add" and one
>> "remove" call.
>>
>>
>>>
>>> Your points of view are highly welcome.
>>>
>>
>> Andy
Re: Updating a SPARQL endpoint with the content of a Model
Posted by Stephen Allen <sa...@apache.org>.
Also, you can try the experimental "jena-client" project. It is a
work-in-progress for interacting with SPARQL endpoints (both local and
remote).
Instructions for building:
svn co https://svn.apache.org/repos/asf/jena/Experimental/jena-client/
jena-client
cd jena-client
mvn clean install
Then include "target/jena-client-0.0.8-SNAPSHOT.jar" in your project's
classpath. Quick user guide:
Model m = ... // Your Model with the statements you want to add to
the remote store
Repository repo =
RepositoryFactory.createRemote("http://localhost:3030/ds/query",
"http://localhost:3030/ds/update");
Connection conn = repo.getConnection();
try {
Updater up = conn.createStreamingUpdater();
try {
// The first parameter is the named graph to insert the
Triples into, null == default graph
up.insert(null, m.getGraph());
}
finally {
up.close();
}
}
finally {
conn.close();
}
Among the benefits of this: 1) it generates the SPARQL Update request
for you, and 2) it is fully streaming on the client side, so Model can
be large (streaming isn't supported on the server yet, see JENA-330).
3) A single update request is transactional (a future goal would be
transactions across remote queries / requests)
If you do use it, or even play around with it for a while, I would
love to get your feedback.
-Stephen
On Tue, Nov 27, 2012 at 6:16 AM, Andy Seaborne <an...@apache.org> wrote:
> On 26/11/12 17:02, Olivier Rossel wrote:
>>
>> Hi folks!
>>
>> I have a Model full of triples, and I wish I could "inject" these
>> data into a remote endpoint. is there a helper class to create a
>> SPARQL/Insert query from the content of the Model? Otherwise, what is
>> the best way to create such a query? (Iterating the triples, removing
>> the blank nodes, appending SPARQL statements to a StringBuffer. And
>> that's all?
>
>
> DatasetAccessor (which for silly histroical reasons is in Fuseki) may help.
> It is the GSP protocol for Jena. You can POST a model.
>
> And also no need to mess with bNodes in a INSERT DATA operation.
>
>
>> More advanced question: is it possible to monitor the lifecycle of a
>> Model (add/remove), and create a SPARQL/Update that mimicks that
>> lifecycle (to be sent on a remote endpoint)? What is the best way to
>> do that with Jena? ModelChangedListener (and string appending)?
>
>
> Yes, probably.
>
> We have been discussing simplifying this to just have one "add" and one
> "remove" call.
>
>
>>
>> Your points of view are highly welcome.
>>
>
> Andy
Re: Updating a SPARQL endpoint with the content of a Model
Posted by Andy Seaborne <an...@apache.org>.
On 26/11/12 17:02, Olivier Rossel wrote:
> Hi folks!
>
> I have a Model full of triples, and I wish I could "inject" these
> data into a remote endpoint. is there a helper class to create a
> SPARQL/Insert query from the content of the Model? Otherwise, what is
> the best way to create such a query? (Iterating the triples, removing
> the blank nodes, appending SPARQL statements to a StringBuffer. And
> that's all?
DatasetAccessor (which for silly histroical reasons is in Fuseki) may
help. It is the GSP protocol for Jena. You can POST a model.
And also no need to mess with bNodes in a INSERT DATA operation.
> More advanced question: is it possible to monitor the lifecycle of a
> Model (add/remove), and create a SPARQL/Update that mimicks that
> lifecycle (to be sent on a remote endpoint)? What is the best way to
> do that with Jena? ModelChangedListener (and string appending)?
Yes, probably.
We have been discussing simplifying this to just have one "add" and one
"remove" call.
>
> Your points of view are highly welcome.
>
Andy