use of org.semanticweb.owlapi.util.OWLOntologyMerger in project stanbol by apache.
the class SessionImpl method exportToOWLOntology.
/**
* TODO support merging for attached scopes as well?
*/
@Override
protected OWLOntology exportToOWLOntology(boolean merge, org.semanticweb.owlapi.model.IRI universalPrefix) {
OWLOntology o = super.exportToOWLOntology(merge, universalPrefix);
org.semanticweb.owlapi.model.IRI iri = o.getOntologyID().getOntologyIRI();
if (merge) {
// Re-merge
// FIXME try to avoid this.
ScopeManager onm = ScopeManagerImpl.get();
final Set<OWLOntology> set = new HashSet<OWLOntology>();
set.add(o);
for (String scopeID : attachedScopes) {
log.debug(" ... Merging with attached scope {}.", scopeID);
Scope sc = onm.getScope(scopeID);
if (sc != null)
set.add(sc.export(OWLOntology.class, merge));
for (OWLOntologyID ontologyId : managedOntologies) {
set.add(getOntology(ontologyId, OWLOntology.class, true));
}
OWLOntologySetProvider provider = new OWLOntologySetProvider() {
@Override
public Set<OWLOntology> getOntologies() {
return set;
}
};
OWLOntologyMerger merger = new OWLOntologyMerger(provider);
try {
o = merger.createMergedOntology(OWLManager.createOWLOntologyManager(), iri);
} catch (OWLOntologyCreationException e) {
log.error("Failed to merge imports for ontology " + iri, e);
o = null;
}
}
} else
attachScopeImportsOwlApi(o, universalPrefix);
return o;
}
Aggregations