@@ -77,6 +77,8 @@ class ImportConfig(OswBaseModel):
7777 """the name of the ontology"""
7878 ontologies : List [model .OwlOntology ]
7979 """Ontology metadata, including imported ontologies"""
80+ additional_imports : Optional [List [model .OwlOntology ]] = []
81+ """Ontologies to import additionally to the imported main ontology"""
8082 import_mapping : Optional [Dict [str , str ]] = {}
8183 """Mapping of imported ontologies iri to their resolveable file url in case both
8284 are not identical"""
@@ -138,6 +140,7 @@ def _recursive_ontology_import(
138140 format_ : str = "turtle" ,
139141 imported_ontologies : list = None ,
140142 import_mapping = None ,
143+ rdf_graph = None ,
141144 ):
142145 """Recursively import ontologies from owl:imports statements in the given
143146 ontology file.
@@ -158,7 +161,8 @@ def _recursive_ontology_import(
158161 imported_ontologies = []
159162 if import_mapping is None :
160163 import_mapping = {}
161- rdf_graph = Graph ()
164+ if rdf_graph is None :
165+ rdf_graph = Graph ()
162166 rdf_graph .parse (file , format = format_ )
163167
164168 # load the graph into a dict
@@ -220,13 +224,27 @@ def import_ontology(
220224
221225 self .import_config = config
222226
227+ # import
228+ rdf_graph = Graph ()
229+ if self .import_config .additional_imports is not None :
230+ for onto in self .import_config .additional_imports :
231+ iri = onto .iri
232+ if (
233+ self .import_config .import_mapping
234+ and iri in self .import_config .import_mapping
235+ ):
236+ iri = self .import_config .import_mapping [iri ]
237+ print (f"Importing { iri } " )
238+ rdf_graph .parse (iri )
239+
223240 # load the ontology file
224241 self ._imported_ontologies = []
225242 rdf_graph = self ._recursive_ontology_import (
226243 self .import_config .file ,
227244 self .import_config .file_format ,
228245 self ._imported_ontologies ,
229246 self .import_config .import_mapping ,
247+ rdf_graph ,
230248 )
231249
232250 if self .import_config .dump_files :
0 commit comments