On 04/04/13 22:50, Andreas Grünwald wrote:
Hello,
I managed to establish a connection to my MYSQL database via Jena SDB and
inserted some triples.
However, I still feel insecure how OWL constructs are persisted with Jena.
Here is my Java code example:
c.initSdb(OntModelSpec.OWL_MEM_MICRO_RULE_INF); //connect to MYSQL db
Not relevant to your problem here but inference over a database will be
very slow. It is better to perform any inference over in-memory models.
OntModel base = c.getOntologyModel();
String SOURCE = "http://www.eswc2006.org/technologies/ontology";
String NS = SOURCE + "#";
/* Add 2 individuals of the type "paper" linked via an object property */
OntClass paper = base.getOntClass( NS + "Paper" );
I think you mean createClass(NS + "Paper") here.
Individual p1 = base.createIndividual( NS + "paper1", paper );
Individual p2 = base.createIndividual( NS + "paper2", paper );
Property hasLinkTo = base.createObjectProperty(NS + "hasLinkTo"); //
hasName property
base.add(p1,hasLinkTo,p2);
---
In the database 4 nodes, viz.
- http://www.w3.org/1999/02/22-rdf-syntax-ns#type
- http://www.eswc2006.org/technologies/ontology#hasLinkTo
- http://www.w3.org/2002/07/owl#ObjectProperty
- http://www.eswc2006.org/technologies/ontology#paper1
and 2 triples, viz.
- #hasLinkTo - rdf-syntax-ns#type - owl#ObjectProperty
- #paper1 - #hasLinkTo - #paper1
are persisted.
My question is: Shouldn't the OntClass "Paper" result in an additional
node, and an additional triple in the database?
If you mean to create and use a class then you need to use the
createClass method.
The getOntClass method, as it says in the javadoc, returns null if there
is no such class currently defined. So in your code the variable /paper/
is null which in turn means the createIndividual calls cannot assign any
rdf:type to paper1 and paper2.
Dave