I am trying to link two individuals A and B using
B.setSameAs(A) OR A.setSameAs(B)
A has properties hasOne, hasTwo
B has a property hasThree
and I'm hoping that the property of B can be inferred as a property of A. Unfortunately, when I list A's properties, hasThree doesn't appear
This is my setup:
OntModel onto = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF, null);
String NAMESPACE1 = "http://mynamespace.one#";
String NAMESPACE2 = "http://mynamespace.two#";
OntClass myClass = onto.createClass(NAMESPACE1 + "MyClass");
Individual a = onto.createIndividual(NAMESPACE1 + "A", myClass);
Individual b = onto.createIndividual(NAMESPACE2 + "B", myClass);
NOTE: I used a different namespace for B to simulate a different address, but in this setup it is using the same class type
OntProperty one = onto.createOntProperty(NAMESPACE1 + "hasOne");
OntProperty two = onto.createOntProperty(NAMESPACE1 + "hasTwo");
OntProperty three = onto.createOntProperty(NAMESPACE2 + "hasThree");
NOTE: the hasThree property is located in the same address of B
a.setLiteral(one, true);
a.setLiteral(two, true);
b.setLiteral(three, true);
a.setSameAs(b); //THIS results in the RDF entry for A to have a line <owl:sameAs rdf:resource:"http://mynamespace.two#B" />
//b.setSameAs(a); //I TRIED using this too, but it didn't work either
// IN HERE I JUST SET AN ITERATOR TO SHOW ALL OF THE PROPERTIES OF A
// UNFORTUNATELY, hasThree DOESN'T SHOW UP UNDER THE PROPERTIES OF A
I have itemized the things that are troubling me.
You aren't using a reasoning profile that supports owl:sameAs
In the OWL Reasoning of the Jena documentation there is a table which lists the OWL coverage of the different reasoner profiles.
The row for owl:sameAs
states the following:
owl:sameAs, owl:differentFrom, owl:distinctMembers | full, mini | owl:distinctMembers is currently translated into a quadratic set of owl:differentFrom assertions.
So in order to get the behaviour you desire you must be using a Full/Mini OWL reasoner, your code shows you are using the Micro reasoner.
Changing your code to use OntModelSpec.OWL_MEM_MINI_RULE_INF
instead should solve your problem.