Reference code as a whole: https://github.com/jottinger/ontology
I'm creating an ontology and populating it (correctly, I think). The structure is there, but I'm not validating it yet.
However, I still keep expecting declarations to show up and I don't know why they're missing. I think it's got something to do with the prefix manager (because every element is fully qualified by the namespace) but I don't know how to instantiate a new prefix manager such that i can register namespaces.
Here's the code to add a subclass relationship:
val clazz = getOntClass(node.name)
val parent = getOntClass(data(node.p).name)
val hasClazz = getOntObjectProperty("has" + node.name)
val hasClazzSomeClazz = df.getOWLObjectSomeValuesFrom(hasClazz, clazz)
val hasParent = getOntObjectProperty("has" + data(node.p).name)
val hasParentSomeParent = df.getOWLObjectSomeValuesFrom(hasParent, parent)
m.applyChanges(List(
new AddAxiom(o, df.getOWLDeclarationAxiom(clazz)),
new AddAxiom(o, df.getOWLDeclarationAxiom(clazz)),
new AddAxiom(o, df.getOWLDeclarationAxiom(parent)),
new AddAxiom(o, df.getOWLSubClassOfAxiom(clazz, parent)),
new AddAxiom(o, df.getOWLDeclarationAxiom(hasClazz)),
new AddAxiom(o, df.getOWLSubClassOfAxiom(parent, hasClazzSomeClazz)),
new AddAxiom(o, df.getOWLDeclarationAxiom(parent)),
new AddAxiom(o, df.getOWLDeclarationAxiom(hasParent)),
new AddAxiom(o, df.getOWLSubObjectPropertyOfAxiom(hasClazz, hasParent))
))
I'm assuming that this is a valid structure. (Part of this project is to learn how ontologies work.) But I don't know how to get the declarations to appear, and this ontology is used as input for another process that wants that information.
You don't need to declare things more than once; those declarations are just identical. Besides that it seems that you code is correct (I'm speaking in terms of OWL API here; I don't know Scala enough to judge the correctness of Scala code)