Hello,
Still on the subject of retrieving stored SPIN queries, I'm getting a
strange exception when retrieving certain (but not all) ASK queries that I have
stored in my query model. For example, the following query stored as the range
of a spin:query property works fine:
ASK WHERE {
?project a ModelManagement:Project .
?project Common:name ?projName .
FILTER (?projName = ?str1) .
?project ModelManagement:hasUser ?user .
{
?user a ModelManagement:User .
}
UNION
{
?user a ModelManagement:Root .
} .
?user Common:name ?userName .
FILTER (?userName = ?str2) .
?user ModelManagement:password ?password .
FILTER (?password = ?str3) .
}
But the following query stored in the same way causes an exception to be raised
in the code shown below. It's also interesting that the debugger can display
the org.topbraid.spin.model.Query construct for the query above, but it can't
for the query below. When selected in the debugger I get:
com.sun.jdi.InvocationException occurred invoking method. I've tried deleting
and recreating the query in my model, but get the same result.
This query, stored as the object of a spin:query property....
ASK WHERE {
?uri2 a ModelManagement:ExportType .
?uri2 Common:name ?name .
FILTER (?name = "CAFTA")
}
...causes the below exception on the spinQuery.print(printCntxt) line:
org.topbraid.spin.model.Query spinQuery = SPINFactory
.asQuery(spinQueryRes);
StringBuilder queryBldr = new StringBuilder();
StringPrintContext printCntxt = new
StringPrintContext(queryBldr);
printCntxt.setPrintPrefixes(false);
spinQuery.print(printCntxt);
this.sparql = ResourceFactory.createTypedLiteral(queryBldr
.toString(), XSDDatatype.XSDstring);
Exception Trace:
java.lang.NullPointerException
at
com.hp.hpl.jena.tdb.store.GraphTDBBase.graphBaseFindWorker(GraphTDBBase.java:144)
at
com.hp.hpl.jena.tdb.store.GraphNamedTDB.graphBaseFind(GraphNamedTDB.java:107)
at
com.hp.hpl.jena.tdb.migrate.GraphBase2.find(GraphBase2.java:230)
at
com.hp.hpl.jena.tdb.migrate.Reifier2.findExposed(Reifier2.java:192)
at
com.hp.hpl.jena.graph.impl.GraphBase.reifierTriples(GraphBase.java:318)
at com.hp.hpl.jena.graph.impl.GraphBase.find(GraphBase.java:240)
at
com.hp.hpl.jena.graph.impl.GraphBase.graphBaseFind(GraphBase.java:260)
at com.hp.hpl.jena.graph.impl.GraphBase.find(GraphBase.java:257)
at
com.hp.hpl.jena.rdf.model.impl.ModelCom.listStatements(ModelCom.java:378)
at
com.hp.hpl.jena.rdf.model.impl.ModelCom.listStatements(ModelCom.java:383)
at
com.hp.hpl.jena.rdf.model.impl.ModelCom.getProperty(ModelCom.java:1003)
at
com.hp.hpl.jena.rdf.model.impl.ResourceImpl.getProperty(ResourceImpl.java:154)
at
org.topbraid.spin.model.impl.FunctionCallImpl.getSymbol(FunctionCallImpl.java:127)
at
org.topbraid.spin.model.impl.FunctionCallImpl.print(FunctionCallImpl.java:140)
at
org.topbraid.spin.util.SPINExpressions.printExpressionString(SPINExpressions.java:163)
at
org.topbraid.spin.model.impl.AbstractSPINResourceImpl.printNestedExpressionString(AbstractSPINResourceImpl.java:146)
at
org.topbraid.spin.model.impl.FilterImpl.print(FilterImpl.java:46)
at
org.topbraid.spin.model.impl.ElementListImpl.print(ElementListImpl.java:139)
at
org.topbraid.spin.model.impl.AbstractSPINResourceImpl.printNestedElementList(AbstractSPINResourceImpl.java:132)
at
org.topbraid.spin.model.impl.QueryImpl.printWhere(QueryImpl.java:177)
at org.topbraid.spin.model.impl.AskImpl.print(AskImpl.java:27)
at
com.boeing.sparqlflow.QueryInfo.setQueryInfo(QueryInfo.java:69)
From: [email protected] [mailto:[email protected]]
On Behalf Of Schmitz, Jeffrey A
Sent: Monday, January 17, 2011 8:47 AM
To: [email protected]
Subject: RE: [topbraid-users] Getting prefixes stored with a
...spin.model.Query?
You speculate correctly.
Thanks!
From: [email protected] [mailto:[email protected]]
On Behalf Of Holger Knublauch
Sent: Saturday, January 15, 2011 3:04 AM
To: [email protected]
Subject: Re: [topbraid-users] Getting prefixes stored with a
...spin.model.Query?
Jeff,
I also speculate that you simply want to create a Jena Query object from the
SPIN API Query instance. In that case, you can use
PrintContext.setPrintPrefixes(false) to ensure that the generated query string
will only consist of absolute URIs (without prefixes). This will make parsing
it with ARQ far simpler.
Holger
On Jan 15, 2011, at 1:46 PM, Schmitz, Jeffrey A wrote:
Hello,
I'm using org.topbraid.spin.model.SPINFactory to retrieve a stored
org.topbraid.spin.model.Query in one of my models, and then using the print
function to get the string version of the query, e.g.:
org.topbraid.spin.model.Query spinQuery = SPINFactory
.asQuery(spinQueryRes);
StringBuilder queryBldr = new StringBuilder();
StringPrintContext printCntxt = new
StringPrintContext(queryBldr);
spinQuery.print(printCntxt);
String sparqlStr = queryBldr.toString();
but I don't see an obvious way to get the prefixes associated with the Query.
Is there a way to retrieve them in the api?
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]
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
--
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