Skip to content

Commit 1e7e78b

Browse files
committed
Fix RDFS to SHACL in teh part of sh:order
1 parent aeebe9f commit 1e7e78b

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/main/java/eu/griddigit/cimpal/core/ShaclTools.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -844,14 +844,14 @@ public static Model createShapesModelFromRDFS(Model model, String nsPrefixprofil
844844
//Add node shape and property shape for the presence of the inverse association
845845
String invAssocURI = stmt.getSubject().getURI();
846846
String localNameInvAssoc = stmt.getSubject().getLocalName();
847-
shapeModel = ShaclTools.addNodeShapeProfileClass(shapeModel, nsURIprofile, localNameInvAssoc+"-inverseNodePresent", invAssocURI);
847+
shapeModel = ShaclTools.addNodeShapeProfileClass(shapeModel, nsURIprofile, localNameInvAssoc + "-inverseNodePresent", invAssocURI);
848848
//create the property shape
849-
RDFNode oi = shapeModel.createResource(nsURIprofile + localNameInvAssoc+"-propertyInverse");
850-
Resource nodeShapeResourceClassInv = shapeModel.getResource(nsURIprofile + localNameInvAssoc+"-inverseNodePresent");
849+
RDFNode oi = shapeModel.createResource(nsURIprofile + localNameInvAssoc + "-propertyInverse");
850+
Resource nodeShapeResourceClassInv = shapeModel.getResource(nsURIprofile + localNameInvAssoc + "-inverseNodePresent");
851851
nodeShapeResourceClassInv.addProperty(SH.property, oi);
852852

853853
//adding the properties for the PropertyShape
854-
Resource ri = shapeModel.createResource(nsURIprofile +localNameInvAssoc+"-propertyInverse");
854+
Resource ri = shapeModel.createResource(nsURIprofile + localNameInvAssoc + "-propertyInverse");
855855
ri.addProperty(RDF.type, SH.PropertyShape);
856856
ri.addProperty(SH.name, "InverseAssociationPresent");
857857
ri.addProperty(SH.description, "Inverse associations shall not be instantiated.");
@@ -862,7 +862,9 @@ public static Model createShapesModelFromRDFS(Model model, String nsPrefixprofil
862862
ri.addProperty(path, o5i);
863863
RDFNode o1oi = shapeModel.createTypedLiteral(inverseassocGroupOrder + 1, "http://www.w3.org/2001/XMLSchema#integer");
864864
inverseassocGroupOrder = inverseassocGroupOrder + 1;
865-
ri.addProperty(SH.order, o1oi);
865+
if (!shapeModel.listStatements(ri, SH.order, (RDFNode) null).hasNext()) {
866+
ri.addProperty(SH.order, o1oi);
867+
}
866868
RDFNode o1gi = shapeModel.createResource(nsURIprofile+"InverseAssociationsGroup");
867869
ri.addProperty(SH.group, o1gi);
868870
RDFNode o4i = shapeModel.createTypedLiteral(0, "http://www.w3.org/2001/XMLSchema#integer");
@@ -1187,7 +1189,9 @@ public static Model createShapesModelFromRDFS(Model model, String nsPrefixprofil
11871189
ri.addProperty(path, o5i);
11881190
RDFNode o1oi = shapeModel.createTypedLiteral(inverseassocGroupOrder + 1, "http://www.w3.org/2001/XMLSchema#integer");
11891191
inverseassocGroupOrder = inverseassocGroupOrder + 1;
1190-
ri.addProperty(SH.order, o1oi);
1192+
if (!shapeModel.listStatements(ri, SH.order, (RDFNode) null).hasNext()) {
1193+
ri.addProperty(SH.order, o1oi);
1194+
}
11911195
RDFNode o1gi = shapeModel.createResource(nsURIprofile+"InverseAssociationsGroup");
11921196
ri.addProperty(SH.group, o1gi);
11931197
RDFNode o4i = shapeModel.createTypedLiteral(0, "http://www.w3.org/2001/XMLSchema#integer");
@@ -1505,7 +1509,9 @@ public static Model createShapesModelFromRDFS(Model model, String nsPrefixprofil
15051509
ri.addProperty(path, o5i);
15061510
RDFNode o1oi = shapeModel.createTypedLiteral(inverseassocGroupOrder + 1, "http://www.w3.org/2001/XMLSchema#integer");
15071511
inverseassocGroupOrder = inverseassocGroupOrder + 1;
1508-
ri.addProperty(SH.order, o1oi);
1512+
if (!shapeModel.listStatements(ri, SH.order, (RDFNode) null).hasNext()) {
1513+
ri.addProperty(SH.order, o1oi);
1514+
}
15091515
RDFNode o1gi = shapeModel.createResource(nsURIprofile + "InverseAssociationsGroup");
15101516
ri.addProperty(SH.group, o1gi);
15111517
RDFNode o4i = shapeModel.createTypedLiteral(0, "http://www.w3.org/2001/XMLSchema#integer");
@@ -4141,7 +4147,9 @@ public static Model createShapesModelFromProfile(Model model, String nsPrefixpro
41414147
RDFNode o5i = shapeModel.createResource(invAssocURI);
41424148
ri.addProperty(path, o5i);
41434149
RDFNode o1oi = shapeModel.createTypedLiteral(atas - 1, "http://www.w3.org/2001/XMLSchema#integer");
4144-
ri.addProperty(SH.order, o1oi);
4150+
if (!shapeModel.listStatements(ri, SH.order, (RDFNode) null).hasNext()) {
4151+
ri.addProperty(SH.order, o1oi);
4152+
}
41454153
RDFNode o1gi = shapeModel.createResource(nsURIprofile+"InverseAssociationsGroup");
41464154
ri.addProperty(SH.group, o1gi);
41474155
RDFNode o4i = shapeModel.createTypedLiteral(0, "http://www.w3.org/2001/XMLSchema#integer");

0 commit comments

Comments
 (0)