On 30/09/17 18:31, Steve Vestal wrote:
I should have included the stack dump from Jena, which just triggered
that  chain that ended with Eclipse:

     at org.apache.jena.graph.Node.getBlankNodeId(Node.java:86)
     at
org.apache.jena.rdf.model.impl.ResourceImpl.getId(ResourceImpl.java:138)
     at
com.adventiumlabs.aadltools.fhowlquery.plugin.handlers.MyHandler.execute(MyHandler.java:255)

where MyHandler:255 is the createReifiedStatement call.

Don't think so, otherwise the next call in the stack would be createReifiedStatement!

Without seeing your exact code it's hard to tell but it looks like you are getting back a URI resource but then trying to call getId on it. getId returns the internal id of a blank node and so will only work on blank nodes. To get the URI use getURI.

If that's not it then show your actual code and a stack trace that matches it. Or better ...

Your code works
just fine.  Is there something odd about creating a Statement for a
triple from a Model that was returned by a query of the OntModel that
I'm adding the reified statement to?

Not that I'm aware of but you could create a similar complete minimal example for that case and see if it works for you.

Dave


On 9/30/2017 11:52 AM, Dave Reynolds wrote:
On 30/09/17 16:31, Steve Vestal wrote:
When I execute the following org.apache.jena.rdf.model.Model method

ReifiedStatement myReifiedStatement =
myOntology.createReifiedStatement(myNodeName, myStatement);

where myStatement is an org.apache.jena.rdf.model.Statement in a Model
returned by an org.apache.jena.query.Query#execConstruct query of
myOntology, I get the exception

org.eclipse.e4.core.di.InjectionException:
java.lang.UnsupportedOperationException:
http://www.test.com/test#myNodeName is not a blank node

That exception is not from Jena but some other part of your
application or test suite.

The code

ReifiedStatement myReifiedStatement =
myOntology.createReifiedStatement(myStatement);

seems to work OK.  How do I create a ReifiedStatement in myOntology as
an explicitly named resource?

You pass the URI for the ReifiedStatement as the first argument to
createReifiedStatement just as you tried, works fine. E.g. try

     Model m = ModelFactory.createDefaultModel();
     Resource a = m.createResource(NS + "a");
     Statement s = m.createStatement(a, RDFS.label, "a");
     m.add(s);
     ReifiedStatement r = m.createReifiedStatement(NS + "statement", s);
     m.write(System.out, "Turtle");

to see that the created reified statement has the expected URI.

Dave



Reply via email to