I don't think what I'm trying to do is covered by the example because the
example starts out with the string version of the query and from that creates a
Query version of it:
String query = "...";
Query arqQuery = ARQFactory.get().createQuery(model, query);
what I think I need is a utility something like:
Select spinSelect = ARQSelectResourceToSPINSelect(Resource query);
To add a little more detail, in my code I only have a reference to the query as
a com.hp.hpl.jena.rdf.model.Resource that was previously saved into a model
using TopBraid Composer. e.g. in one case I use the following code to get a
select query Resource:
Resource resourceWithSpinQueryAttached = ...;
Property spinQueryProp =
ResourceFactory.createProperty("http://spinrdf.org/spin#query");
NodeIterator queryIter =
destModel.listObjectsOfProperty(resourceWithSpinQueryAttached, spinQueryProp,
false, true);
if (queryIter.hasNext()) {
Resource query = queryIter.next().asResource();
So what I need is a way to get from the Jena Resource that represents the
retrieved SPIN Select Query, to the SPIN Select query class, e.g :
From: com.hp.hpl.jena.rdf.model.Resource
To: org.topbraid.spin.model.Select
Then from there I can use the code in the example to get the String version of
the Select query. Any (simple) way to do that using the API? Actually, I'm
sure there must be some way since you must do the same thing when executing
spin rule Construct queries, but I haven't taken the time to wade through that
code to try to apply it to my situation, and was holding out hope for that
simple:
Select spinSelect = ARQSelectResourceToSPINSelect(Resource query) utility :)
Thanks,
Jeff
From: [email protected] [mailto:[email protected]]
On Behalf Of Holger Knublauch
Sent: Friday, November 05, 2010 6:36 PM
To: [email protected]
Subject: Re: [topbraid-users] Minor SPIN related bug report
Hi Jeff,
the SPIN API contains an example that shows how to parse and unparse a SPARQL
SPIN RDF query in the src-examples folder. Once you have a Construct or Select
object, you can call toString on it (but it needs to be cast into a SPIN Query
object first). Use SPINFactory.asCommand(resource) to get a Select instance. On
that you will also see the print method that can be used to create a string
rendering with various options (e.g. prefixes on or off).
Let me know if you have further questions,
Holger
On Nov 6, 2010, at 1:38 AM, Schmitz, Jeffrey A wrote:
Thanks Holger,
Regarding the requested API function, I currently use the sp:text version of
queries I've stored in a model for execution by our run-time using java/jena.
Retrieving the queries as they are stored in the spin format (IOW using
sp:first, sp:rest) and constituting them into a string isn't something I've
figured out how to do. Are you saying this is possible using the API toString
and print functions? If so, I'll have to take a closer look.
Thanks,
Jeff
From: [email protected]<mailto:[email protected]>
[mailto:[email protected]]<mailto:[mailto:[email protected]]>
On Behalf Of Holger Knublauch
Sent: Tuesday, November 02, 2010 5:21 PM
To: [email protected]<mailto:[email protected]>
Subject: Re: [topbraid-users] Minor SPIN related bug report
Hi Jeff,
this is a known limitation (aka: feature) of sp:text - the sp:text is used if
present, and by default sp:text is switched off (see TBC SPIN preferences). The
main use case for sp:text is if you want to store the verbatim syntax "as
entered", e.g. including comments in arbitrary places. If you don't need this,
just ensure the corresponding option is switched off, and then you won't run
into this issue.
It is difficult to keep the sp:text in synch after changes to the model, and
this logic is not implemented. I am not sure what API function you request to
regenerate the sp:text - this would be the toString or print methods.
Regards,
Holger
On Nov 3, 2010, at 6:32 AM, Schmitz, Jeffrey A wrote:
I noticed that for an sp:Construct (and probably for all the spin query
classes) when I change the name of a property that is used in the stored query,
the property name displayed in the main area of the query gets updated
accordingly, but the textual version of the query stored as the object of the
sp:text property doesn't get updated. At that point, the text version of the
query is out of sync with the "main line" query. Had me scratching my head for
a bit since what I was seeing in TBC looked right, but what was getting
executed (the text version) wasn't working. Any way the textual version of the
query could get regenerated whenever anything changes in the main stored query?
Or perhaps could an API function be added (or maybe it already has?) that will
allow the text version to be generated at runtime so that only one copy of the
query is ever stored?
Btw, still haven't had a chance to test using the spin:command property for
storing DELETE queries. Hopefully will soon.
Thanks,
Jeff
--
You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include TopBraid Composer,
TopBraid Live, TopBraid Ensemble, SPARQLMotion and SPIN.
To post to this group, send email to
[email protected]<mailto:[email protected]>
To unsubscribe from this group, send email to
[email protected]<mailto:[email protected]>
For more options, visit this group at
http://groups.google.com/group/topbraid-users?hl=en
--
You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include TopBraid Composer,
TopBraid Live, TopBraid Ensemble, SPARQLMotion and SPIN.
To post to this group, send email to
[email protected]<mailto:[email protected]>
To unsubscribe from this group, send email to
[email protected]<mailto:[email protected]>
For more options, visit this group at
http://groups.google.com/group/topbraid-users?hl=en
--
You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include TopBraid Composer,
TopBraid Live, TopBraid Ensemble, SPARQLMotion and SPIN.
To post to this group, send email to
[email protected]<mailto:[email protected]>
To unsubscribe from this group, send email to
[email protected]<mailto:[email protected]>
For more options, visit this group at
http://groups.google.com/group/topbraid-users?hl=en
--
You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include TopBraid Composer,
TopBraid Live, TopBraid Ensemble, SPARQLMotion and SPIN.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/topbraid-users?hl=en
--
You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include TopBraid Composer,
TopBraid Live, TopBraid Ensemble, SPARQLMotion and SPIN.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/topbraid-users?hl=en