if (merge) {
log.warn("Merging of Clerezza triple collections is only implemented one level down. Import statements will be preserved for further levels.");
Iterator<Triple> it;
Set<Resource> importTargets = new HashSet<Resource>();
for (OWLOntologyID ontologyId : managedOntologies) {
Graph g = getOntology(ontologyId, Graph.class, false);
root.addAll(g);
it = g.filter(null, OWL.imports, null);
while (it.hasNext()) {
IRI tgt;
Resource r = it.next().getObject();
try {
if (r instanceof UriRef) tgt = IRI.create(((UriRef) r).getUnicodeString());
else if (r instanceof Literal) tgt = IRI.create(((Literal) r).getLexicalForm());
else tgt = IRI.create(r.toString());
tgt = URIUtils.sanitize(tgt);
importTargets.add(new UriRef(tgt.toString()));
} catch (Exception ex) {
log.error("FAILED to obtain import target from resource {}", r);
continue;
}
}
it = g.filter(null, RDF.type, OWL.Ontology);
while (it.hasNext()) {
NonLiteral ontology = it.next().getSubject();
log.debug("Removing all triples related to {} from {}", ontology, iri);
Iterator<Triple> it2 = g.filter(ontology, null, null);
while (it2.hasNext())
root.remove(it2.next());
}
/*