Skip to content

Commit 5d425ee

Browse files
author
David Bold
committed
Try to avoid crash when Ontology has no IRI
1 parent b8685c8 commit 5d425ee

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

src/main/java/org/visualdataweb/vowl/graphModifier/TransformOWLtoGraph.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,12 @@ private void transformDataTypeProperty(Set<OWLDataProperty> OWLDataPropertiesSet
175175
isGenericLiteral = true;
176176
}
177177

178-
IRI ontoIRI = onto.getOntologyID().getOntologyIRI().get();
178+
IRI ontoIRI = onto.getOntologyID().getOntologyIRI().orNull();
179179
if (ontoIRI == null && rdfsIsDefinedBy != null) {
180180
ontoIRI = IRI.create(rdfsIsDefinedBy);
181181
}
182182

183-
// add non generic literal node
183+
// add non generic literal node
184184
mod.addPropertyNode(targetNodeID, rdfsRessourceType, rdfsRange, null, null, null, null, null, isGenericLiteral);
185185

186186
if (sourceNodeID != -1 && targetNodeID != -1) {
@@ -340,7 +340,7 @@ private void transformObjectProperty(Set<OWLObjectProperty> OWLObjectPropertiesS
340340
targetNodeID = -1;
341341
}
342342

343-
IRI ontoIRI = onto.getOntologyID().getOntologyIRI().get();
343+
IRI ontoIRI = onto.getOntologyID().getOntologyIRI().orNull();
344344
if (ontoIRI == null && rdfsIsDefinedBy != null) {
345345
ontoIRI = IRI.create(rdfsIsDefinedBy);
346346
}
@@ -464,7 +464,7 @@ private void transformClasses(Set<OWLClass> OWLClassSet, OWLOntology onto, Graph
464464
mod.addClassThingWithDetails(0, classID, className, classIRI, classComment, definedBy, owlVersion);
465465
} else {
466466
// check the namespace of the class if the class is imported or not
467-
IRI ontoIRI = onto.getOntologyID().getOntologyIRI().get();
467+
IRI ontoIRI = onto.getOntologyID().getOntologyIRI().orNull();
468468
if (ontoIRI == null && definedBy != null) {
469469
ontoIRI = IRI.create(definedBy);
470470
}

src/main/java/org/visualdataweb/vowl/graphModifier/TransformOWLtoGraphUtilities.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ public String helperExtractLabelNameFromIRIIfLabelHasNoName(String name, String
120120
* @return boolean true, if the namespace is different
121121
*/
122122
public boolean hasDifferentNamespace(String elementNamespace, OWLOntology onto) {
123-
return hasDifferentNamespace(elementNamespace, onto.getOntologyID().getOntologyIRI().get());
123+
IRI ontoIRI = onto.getOntologyID().getOntologyIRI().orNull();
124+
if (ontoIRI == null) {
125+
return true;
126+
}
127+
return hasDifferentNamespace(elementNamespace, ontoIRI);
124128
}
125129

126130
/**

0 commit comments

Comments
 (0)