private void importFile( InputStream in, IRI documentIRI, File inDir, Authorizations authorizations) throws Exception { byte[] inFileData = IOUtils.toByteArray(in); Reader inFileReader = new InputStreamReader(new ByteArrayInputStream(inFileData)); OWLOntologyLoaderConfiguration config = new OWLOntologyLoaderConfiguration(); OWLOntologyManager m = createOwlOntologyManager(config, documentIRI); OWLOntologyDocumentSource documentSource = new ReaderDocumentSource(inFileReader, documentIRI); OWLOntology o = m.loadOntologyFromOntologyDocument(documentSource, config); storeOntologyFile(new ByteArrayInputStream(inFileData), documentIRI); for (OWLClass ontologyClass : o.getClassesInSignature()) { if (!o.isDeclared(ontologyClass, false)) { continue; } importOntologyClass(o, ontologyClass, inDir, authorizations); } for (OWLDataProperty dataTypeProperty : o.getDataPropertiesInSignature()) { if (!o.isDeclared(dataTypeProperty, false)) { continue; } importDataProperty(o, dataTypeProperty); } for (OWLObjectProperty objectProperty : o.getObjectPropertiesInSignature()) { if (!o.isDeclared(objectProperty, false)) { continue; } importObjectProperty(o, objectProperty); } for (OWLObjectProperty objectProperty : o.getObjectPropertiesInSignature()) { if (!o.isDeclared(objectProperty, false)) { continue; } importInverseOf(o, objectProperty); } }
@Override protected final OWLOntology createOntology() { OWLOntology ont = getOWLOntology("Ont"); axioms.clear(); axioms.addAll(createAxioms()); getManager().addAxioms(ont, axioms); for (OWLEntity entity : ont.getSignature()) { if (!entity.isBuiltIn()) { if (!ont.isDeclared(entity, true)) { getManager().addAxiom(ont, getFactory().getOWLDeclarationAxiom(entity)); } } } return ont; }