// specific IRI. Create a mapper that maps the Protege ontology IRI to
// the document IRI that points to a copy in the TONES ontology
// repository.
IRI protegeOntologyDocumentIRI = getTONESRepositoryDocumentIRI(
protegeOntologyIri, tonesRepositoryIri);
OWLOntologyIRIMapper iriMapper = new SimpleIRIMapper(
protegeOntologyIri, protegeOntologyDocumentIRI);
// Create a new manager that we will use to load the MGED ontology
OWLOntologyManager manager2 = OWLManager.createOWLOntologyManager();
// Register our mapper with the manager
manager2.getIRIMappers().add(iriMapper);
// Now load our MGED ontology
OWLOntology ontology2 = loadPizza(manager2);
// Print out the details
printOntologyAndImports(manager2, ontology2);
// Notice that the document IRI of the protege ontology is different to
// the document IRI of the ontology when it was loaded the first time.
// This is due to the mapper redirecting the ontology loader. For
// example, AutoIRIMapper: An AutoIRIMapper finds ontologies in a local
// folder and maps their IRIs to their locations in this folder We
// specify a directory/folder where the ontologies are located. In this
// case we've just specified the tmp directory.
@Nonnull
File file = folder.newFolder();
// We can also specify a flag to indicate whether the directory should
// be searched recursively.
OWLOntologyIRIMapper autoIRIMapper = new AutoIRIMapper(file, false);
// We can now use this mapper in the usual way, i.e.
manager2.getIRIMappers().add(autoIRIMapper);
// Of course, applications (such as Protege) usually implement their own
// mappers to deal with specific application requirements.
}