Skip to content

Commit 39c2bdb

Browse files
committed
fix for #245
1 parent d9c13f8 commit 39c2bdb

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

src/main/java/n10s/onto/OntologyImporter.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ public void handleStatement(Statement st) {
157157
addStatement(st);
158158
} else if (st.getObject() instanceof BNode){
159159
//object is a blank node, probably a restriction
160+
instantiate(vf.createIRI(parserConfig.getGraphConf().getBaseSchemaNamespace(), parserConfig.getGraphConf().getClassLabelName()),
161+
(IRI) st.getSubject());
162+
mappedTripleCounter++;
160163
addLinkToClass((IRI)st.getSubject(), (BNode) st.getObject(), openSubClassRestrictions);
161164
}
162165
mappedTripleCounter++;
@@ -167,6 +170,9 @@ public void handleStatement(Statement st) {
167170
addStatement(st);
168171
} else if (st.getObject() instanceof BNode){
169172
//object is a blank node, probably a restriction
173+
instantiate(vf.createIRI(parserConfig.getGraphConf().getBaseSchemaNamespace(), parserConfig.getGraphConf().getClassLabelName()),
174+
(IRI) st.getSubject());
175+
mappedTripleCounter++;
170176
addLinkToClass((IRI)st.getSubject(), (BNode) st.getObject(),openEquivRestrictions);
171177
}
172178
mappedTripleCounter++;

src/test/java/n10s/onto/OntoProceduresTest.java

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,22 @@ public class OntoProceduresTest {
236236
" owl:allValuesFrom :Animal\n" +
237237
" ] .";
238238

239+
String restrictionsOnResourcesImplicitClassTurtle = "" +
240+
"@prefix : <http://www.semanticweb.org/jb/ontologies/2021/5/untitled-ontology-2#> .\n" +
241+
"@prefix owl: <http://www.w3.org/2002/07/owl#> .\n" +
242+
"@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n" +
243+
"@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n" +
244+
"@base <http://www.semanticweb.org/jb/ontologies/2021/5/untitled-ontology-2> .\n" +
245+
"\n" +
246+
"\n" +
247+
":Parent owl:equivalentClass [ rdf:type owl:Restriction ;\n" +
248+
" owl:onProperty :hasChild ;\n" +
249+
" owl:someValuesFrom :Person\n" +
250+
" ] ;\n" +
251+
" rdfs:subClassOf [ rdf:type owl:Restriction ;\n" +
252+
" owl:onProperty :hasPet ;\n" +
253+
" owl:allValuesFrom :Animal\n" +
254+
" ] .";
239255

240256
String restrictionsWithDomAndRange = "" +
241257
"@prefix : <http://www.semanticweb.org/jb/ontologies/2021/5/untitled-ontology-2#> .\n" +
@@ -1143,7 +1159,7 @@ public void ontoSnippetImportRestrictions() throws Exception {
11431159

11441160
Record next = importResults.next();
11451161

1146-
assertEquals(7L, next.get("triplesLoaded").asLong());
1162+
assertEquals(9L, next.get("triplesLoaded").asLong());
11471163

11481164
assertEquals(9L, next.get("triplesParsed").asLong());
11491165

@@ -1183,7 +1199,7 @@ public void ontoSnippetImportRestrictions() throws Exception {
11831199

11841200
next = importResults.next();
11851201

1186-
assertEquals(7L, next.get("triplesLoaded").asLong());
1202+
assertEquals(9L, next.get("triplesLoaded").asLong());
11871203

11881204
assertEquals(9L, next.get("triplesParsed").asLong());
11891205

@@ -1217,6 +1233,29 @@ public void ontoSnippetImportRestrictions() throws Exception {
12171233

12181234
}
12191235

1236+
@Test
1237+
public void ontoSnippetImportRestrictionsImplicitClass() throws Exception {
1238+
try (Driver driver = GraphDatabase.driver(neo4j.boltURI(),
1239+
Config.builder().withoutEncryption().build())) {
1240+
1241+
initialiseGraphDB(neo4j.defaultDatabaseService(),
1242+
"{ handleVocabUris: 'IGNORE' }");
1243+
Session session = driver.session();
1244+
1245+
Map<String, Object> params = new HashMap<>();
1246+
params.put("rdf", this.restrictionsOnResourcesImplicitClassTurtle);
1247+
1248+
Result importResults = session
1249+
.run("CALL n10s.onto.import.inline($rdf,'Turtle')", params);
1250+
1251+
Record next = importResults.next();
1252+
1253+
assertEquals(8L, next.get("triplesLoaded").asLong());
1254+
1255+
assertEquals(8L, next.get("triplesParsed").asLong());
1256+
}
1257+
}
1258+
12201259
private void initialiseGraphDB(GraphDatabaseService db, String graphConfigParams) {
12211260
db.executeTransactionally("CREATE CONSTRAINT n10s_unique_uri "
12221261
+ "ON (r:Resource) ASSERT r.uri IS UNIQUE");

0 commit comments

Comments
 (0)