use of org.semanticweb.owlapi.model.OWLAnnotationValue in project stanbol by apache.
the class RegistryManagerImpl method populateOntology.
protected RegistryOntology populateOntology(OWLNamedObject ind, Set<OWLOntology> registries) throws RegistryContentException {
IRI ontId = ind.getIRI();
RegistryItem ront = null;
if (population.containsKey(ontId)) {
// We are not allowing multityping either.
ront = population.get(ontId);
if (!(ront instanceof RegistryOntology))
throw new RegistryContentException("Inconsistent multityping: for item " + ontId + " : {" + RegistryOntology.class + ", " + ront.getClass() + "}");
} else {
ront = riFactory.createRegistryOntology(ind);
try {
population.put(ront.getIRI(), ront);
} catch (Exception e) {
log.error("Invalid identifier for library item " + ront, e);
return null;
}
}
// EXIT nodes.
Set<OWLNamedObject> libs = new HashSet<OWLNamedObject>();
OWLDataFactory df = OWLManager.getOWLDataFactory();
for (OWLOntology o : registries) {
if (ind instanceof OWLIndividual) {
// Get usages of isOntologyOf as an object property
for (OWLIndividual value : ((OWLIndividual) ind).getObjectPropertyValues(isOntologyOf, o)) if (value.isNamed())
libs.add(value.asOWLNamedIndividual());
// Get usages of isOntologyOf as an annotation property
for (OWLAnnotationAssertionAxiom ann : o.getAnnotationAssertionAxioms(ind.getIRI())) if (isOntologyOfAnn.equals(ann.getProperty())) {
OWLAnnotationValue value = ann.getValue();
if (value instanceof OWLNamedObject)
libs.add((OWLNamedObject) value);
else if (value instanceof IRI)
libs.add(df.getOWLNamedIndividual((IRI) value));
}
}
}
for (OWLNamedObject ilib : libs) {
IRI parentId = ilib.getIRI();
// If some populate*() method has created it, it will be there.
RegistryItem rlib = population.get(parentId);
// Otherwise populating it will also put it in population.
if (rlib == null)
rlib = populateLibrary(ilib, registries);
ront.addParent(rlib);
if (ontologyIndex.get(ontId) == null)
ontologyIndex.put(ontId, new HashSet<IRI>());
ontologyIndex.get(ontId).add(parentId);
}
return (RegistryOntology) ront;
}
use of org.semanticweb.owlapi.model.OWLAnnotationValue in project stanbol by apache.
the class RegistryManagerImpl method populateLibrary.
protected Library populateLibrary(OWLNamedObject ind, Set<OWLOntology> registries) throws RegistryContentException {
IRI libId = ind.getIRI();
RegistryItem lib = null;
if (population.containsKey(libId)) {
// We are not allowing multityping either.
lib = population.get(libId);
if (!(lib instanceof Library))
throw new RegistryContentException("Inconsistent multityping: for item " + libId + " : {" + Library.class + ", " + lib.getClass() + "}");
} else {
lib = riFactory.createLibrary(ind);
try {
population.put(lib.getIRI(), lib);
} catch (Exception e) {
log.error("Invalid identifier for library item " + lib, e);
return null;
}
}
// EXIT nodes.
Set<OWLNamedObject> ironts = new HashSet<OWLNamedObject>();
OWLDataFactory df = OWLManager.getOWLDataFactory();
for (OWLOntology o : registries) {
if (ind instanceof OWLIndividual) {
// Get usages of hasOntology as an object property
for (OWLIndividual value : ((OWLIndividual) ind).getObjectPropertyValues(hasOntology, o)) if (value.isNamed())
ironts.add(value.asOWLNamedIndividual());
// Get usages of hasOntology as an annotation property
for (OWLAnnotationAssertionAxiom ann : o.getAnnotationAssertionAxioms(ind.getIRI())) if (hasOntologyAnn.equals(ann.getProperty())) {
OWLAnnotationValue value = ann.getValue();
if (value instanceof OWLNamedObject)
ironts.add((OWLNamedObject) value);
else if (value instanceof IRI)
ironts.add(df.getOWLNamedIndividual((IRI) value));
}
}
}
for (OWLNamedObject iront : ironts) {
IRI childId = iront.getIRI();
// If some populate*() method has created it, it will be there.
RegistryItem ront = population.get(childId);
// Otherwise populating it will also put it in population.
if (ront == null)
ront = populateOntology(iront, registries);
lib.addChild(ront);
if (ontologyIndex.get(childId) == null)
ontologyIndex.put(childId, new HashSet<IRI>());
ontologyIndex.get(childId).add(libId);
}
return (Library) lib;
}
Aggregations