Skip to content

Commit

Permalink
copy the ontology IRI after the creation of the target ontology
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Jul 29, 2022
1 parent 450ffd1 commit cd1db00
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/main/java/org/stanford/ncbo/owlapi/wrapper/OntologyParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,22 @@ private boolean isOBO(OWLOntology ontology) {
return isOBO;
}

/**
* Get the source ontology IRI and add it to the target ontology
*
* @param fact
* @param sourceOnt
*/
private void addOntologyIRI(OWLDataFactory fact, OWLOntology sourceOnt) {
Optional<IRI> ontologyIRI = sourceOnt.getOntologyID().getOntologyIRI();
Optional<IRI> versionIRI = sourceOnt.getOntologyID().getVersionIRI();
if (ontologyIRI.isPresent()) {
OWLOntologyID newOntologyID = new OWLOntologyID(ontologyIRI, versionIRI);
SetOntologyID setOntologyID = new SetOntologyID(targetOwlOntology, newOntologyID);
this.targetOwlManager.applyChange(setOntologyID);
}
}

/**
* Copies ontology-level annotation axioms from the source ontology to the target ontology.
* <p>
Expand Down Expand Up @@ -177,13 +193,14 @@ private void addGroundMetadata(IRI documentIRI, OWLDataFactory factory, OWLOntol
}
}

private boolean buildOWLOntology(boolean isOBO) {
private boolean buildOWLOntology(OWLOntology masterOntology, boolean isOBO) {

Set<OWLAxiom> allAxioms = new HashSet<OWLAxiom>();

OWLDataFactory fact = sourceOwlManager.getOWLDataFactory();
try {
targetOwlOntology = targetOwlManager.createOntology();
addOntologyIRI(fact, masterOntology);
} catch (OWLOntologyCreationException e) {
log.error(e.getMessage());
parserLog.addError(ParserError.OWL_CREATE_ONTOLOGY_EXCEPTION, "Error buildOWLOntology" + e.getMessage());
Expand Down Expand Up @@ -532,7 +549,7 @@ private boolean internalParse() {

boolean isOBO = isOBO(ontology);

if (!buildOWLOntology(isOBO)) return false;
if (!buildOWLOntology(ontology, isOBO)) return false;

if (!serializeOntology()) return false;

Expand Down

0 comments on commit cd1db00

Please sign in to comment.