Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed ontology iri parsing (version5) when annotation imports same iri #1129

Open
wants to merge 1 commit into
base: version5
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ public class OWLRDFConsumer
* IRIs that had a type triple to owl:Ontology
*/
private final Set<IRI> ontologyIRIs = createSet();
/** IRIs that represent a subject for predicate owl:imports */
private final Set<IRI> ontologySubImportIRIs = createSet();
/**
* IRIs that had a type triple to owl:Restriction
*/
Expand Down Expand Up @@ -1467,7 +1469,8 @@ private void chooseAndSetOntologyIRI() {
// Choose one that isn't the object of an annotation assertion
Set<IRI> candidateIRIs = createSet(ontologyIRIs);
ontology.annotations().forEach(a -> a.getValue().asIRI().ifPresent(iri -> {
if (ontologyIRIs.contains(iri)) {
if (ontologyIRIs.contains(iri)
&& !ontologySubImportIRIs.contains(iri)) {
candidateIRIs.remove(iri);
}
}));
Expand Down Expand Up @@ -2212,14 +2215,29 @@ protected void addFirst(IRI subject, OWLLiteral object) {
* Adds the ontology.
*
* @param iri the iri
* @param owlImportSubject Is the iri used as subject for predicate
* owl:imports
*/
protected void addOntology(IRI iri) {
protected void addOntology(IRI iri, boolean owlImportSubject) {
if (ontologyIRIs.isEmpty()) {
firstOntologyIRI = iri;
}
if (owlImportSubject) {
ontologySubImportIRIs.add(iri);
}
ontologyIRIs.add(iri);
}

/**
* Overload method of addOntology with
* no owl:import subject iri
*
* @param iri the iri
*/
protected void addOntology(IRI iri) {
addOntology(iri, false);
}

/**
* Adds the ontology version.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1546,7 +1546,7 @@ public boolean canHandleStreaming(IRI s, IRI p, IRI o) {
@Override
public void handleTriple(IRI s, IRI p, IRI o) {
consume(s, p, o);
consumer.addOntology(s);
consumer.addOntology(s, true);
consumer.addOntology(o);
OWLImportsDeclaration id = df.getOWLImportsDeclaration(o);
consumer.addImport(id);
Expand Down