Ejemplo n.º 1
0
  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);
    }
  }