Skip to content
This repository was archived by the owner on Feb 15, 2024. It is now read-only.

Commit 7f26694

Browse files
committed
Fixes errors in Constraints AASd-074 & AASd-076
Signed-off-by: Frank Schnicke <frank.schnicke@iese.fraunhofer.de>
1 parent 7587eda commit 7f26694

3 files changed

Lines changed: 62 additions & 77 deletions

File tree

validator/src/main/resources/constraint_shapes.ttl

Lines changed: 44 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -898,89 +898,56 @@ aas:ConceptDescriptionWithCategoryDocumentAndIEC61360CorrectDataType a sh:NodeSh
898898
# AASd-074
899899
aas:ConceptDescriptionDefinitionInEnglishIfNotValueCategory a sh:NodeShape ;
900900
sh:targetClass aas:ConceptDescription ;
901-
sh:message "For all ConceptDescriptions except for ConceptDescriptions of category VALUE using data specification template IEC61360 (http://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/2/0) - DataSpecificationIEC61360/definition is mandatory and shall be defined at least in English." ^^xsd:string ;
902-
sh:or(
903-
[
904-
sh:or(
905-
[
906-
sh:property [
907-
a sh:PropertyShape ;
908-
sh:path <https://admin-shell.io/aas/3/0/RC01/HasDataSpecification/embeddedDataSpecification> ;
909-
sh:class aas:EmbeddedDataSpecification ;
910-
sh:minCount 1 ;
911-
sh:property [
912-
a sh:PropertyShape ;
913-
sh:path <https://admin-shell.io/aas/3/0/RC01/EmbeddedDataSpecification/dataSpecificationContent> ;
914-
sh:class aas:DataSpecificationContent ;
915-
sh:minCount 1 ;
916-
sh:property [
917-
a sh:PropertyShape ;
918-
sh:path <https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC01/DataSpecificationIEC61360/definition> ;
919-
sh:minCount 1 ;
920-
sh:languageIn ("en");
921-
] ;
922-
] ;
923-
];
924-
]
925-
[
926-
sh:property [
927-
a sh:PropertyShape ;
928-
sh:path <https://admin-shell.io/aas/3/0/RC01/HasDataSpecification/embeddedDataSpecification> ;
929-
sh:class aas:EmbeddedDataSpecification ;
930-
sh:maxCount 0 ;
931-
]
932-
]
933-
)
934-
]
935-
[
936-
sh:property [
937-
a sh:PropertyShape ;
938-
sh:path <https://admin-shell.io/aas/3/0/RC01/Referable/category> ;
939-
sh:datatype xsd:string ;
940-
sh:maxCount 1 ;
941-
sh:minCount 1 ;
942-
sh:pattern "^VALUE";
943-
];
944-
]
945-
)
946-
.
901+
902+
sh:sparql [
903+
a sh:SPARQLConstraint ;
904+
sh:message "For all ConceptDescriptions except for ConceptDescriptions of category VALUE using data specification template IEC61360 (http://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/2/0) - DataSpecificationIEC61360/definition is mandatory and shall be defined at least in English." ;
905+
sh:prefixes rdf: ;
906+
sh:select """
907+
SELECT ?dataSpecification
908+
WHERE {
909+
?conceptDescription a <https://admin-shell.io/aas/3/0/RC01/ConceptDescription> .
910+
MINUS {
911+
?conceptDescription a <https://admin-shell.io/aas/3/0/RC01/ConceptDescription> .
912+
?conceptDescription <https://admin-shell.io/aas/3/0/RC01/HasDataSpecification/embeddedDataSpecification> ?embeddedDataSpecificationEn .
913+
?embeddedDataSpecificationEn <https://admin-shell.io/aas/3/0/RC01/EmbeddedDataSpecification/dataSpecificationContent> ?dataSpecificationEn .
914+
?dataSpecificationEn <https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC01/DataSpecificationIEC61360/definition> ?preferredNameEn .
915+
FILTER(LANGMATCHES(LANG(?preferredNameEn), "en"))
916+
}
917+
?conceptDescription <https://admin-shell.io/aas/3/0/RC01/Referable/category> ?category .
918+
FILTER (?category != "VALUE")
919+
?conceptDescription <https://admin-shell.io/aas/3/0/RC01/HasDataSpecification/embeddedDataSpecification> ?embeddedDataSpecification .
920+
?embeddedDataSpecification <https://admin-shell.io/aas/3/0/RC01/EmbeddedDataSpecification/dataSpecificationContent> ?dataSpecification .
921+
}
922+
""" ;
923+
] .
947924

948925

949926
# AASd-076
950927
aas:ConceptDescriptionPreferredNameInEnglish a sh:NodeShape ;
951928
sh:targetClass aas:ConceptDescription ;
929+
930+
sh:sparql [
931+
a sh:SPARQLConstraint ;
952932
sh:message "For all ConceptDescriptions using data specification template IEC61360 (http://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/2/0) at least a preferred name in English shall be defined." ^^xsd:string ;
953-
sh:or(
954-
[
955-
sh:property [
956-
a sh:PropertyShape ;
957-
sh:path <https://admin-shell.io/aas/3/0/RC01/HasDataSpecification/embeddedDataSpecification> ;
958-
sh:class aas:EmbeddedDataSpecification ;
959-
sh:minCount 1 ;
960-
sh:property [
961-
a sh:PropertyShape ;
962-
sh:path <https://admin-shell.io/aas/3/0/RC01/EmbeddedDataSpecification/dataSpecificationContent> ;
963-
sh:class aas:DataSpecificationContent ;
964-
sh:minCount 1 ;
965-
sh:property [
966-
a sh:PropertyShape ;
967-
sh:path <https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC01/DataSpecificationIEC61360/preferredName> ;
968-
sh:minCount 1 ;
969-
sh:languageIn ("en");
970-
] ;
971-
] ;
972-
]
973-
]
974-
[
975-
sh:property [
976-
a sh:PropertyShape ;
977-
sh:path <https://admin-shell.io/aas/3/0/RC01/HasDataSpecification/embeddedDataSpecification> ;
978-
sh:class aas:EmbeddedDataSpecification ;
979-
sh:maxCount 0 ;
980-
];
981-
]
982-
) .
983-
933+
sh:prefixes rdf: ;
934+
sh:select """
935+
SELECT ?dataSpecification
936+
WHERE {
937+
?conceptDescription a <https://admin-shell.io/aas/3/0/RC01/ConceptDescription> .
938+
MINUS {
939+
?conceptDescription a <https://admin-shell.io/aas/3/0/RC01/ConceptDescription> .
940+
?conceptDescription <https://admin-shell.io/aas/3/0/RC01/HasDataSpecification/embeddedDataSpecification> ?embeddedDataSpecificationEn .
941+
?embeddedDataSpecificationEn <https://admin-shell.io/aas/3/0/RC01/EmbeddedDataSpecification/dataSpecificationContent> ?dataSpecificationEn .
942+
?dataSpecificationEn <https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC01/DataSpecificationIEC61360/preferredName> ?preferredNameEn .
943+
FILTER(LANGMATCHES(LANG(?preferredNameEn), "en"))
944+
}
945+
946+
?conceptDescription <https://admin-shell.io/aas/3/0/RC01/HasDataSpecification/embeddedDataSpecification> ?embeddedDataSpecification .
947+
?embeddedDataSpecification <https://admin-shell.io/aas/3/0/RC01/EmbeddedDataSpecification/dataSpecificationContent> ?dataSpecification .
948+
}
949+
""" ;
950+
] .
984951

985952
# AASd-077
986953
aas:UniqueExtensionNames a sh:NodeShape ;

validator/src/test/java/io/adminshell/aas/v3/model/validator/TestAASd_074.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,21 @@ public void conceptDescriptionValueCategoryGermanDefinition() throws ValidationE
8181
ShaclValidator.getInstance().validate(cd);
8282
}
8383

84+
@Test
85+
public void noIEC61360DataSpecification() throws ValidationException {
86+
ConceptDescription description = ConstraintTestHelper.createConceptDescription("testIdShort", "testId",
87+
"PROPERTY");
88+
89+
ShaclValidator.getInstance().validate(description);
90+
}
8491
private ConceptDescription createConceptDescription(LangString definition) {
8592
ConceptDescription cd = ConstraintTestHelper.createConceptDescription("idShort1", "id",
8693
"QUALIFIER");
8794

8895
DataSpecificationIEC61360 urlDataTypeDS = new DefaultDataSpecificationIEC61360.Builder()
8996
.preferredName(new LangString("ds", "en"))
9097
.definition(definition)
98+
.definition(new LangString("test", "de"))
9199
.dataType(DataTypeIEC61360.URL)
92100
.build();
93101

validator/src/test/java/io/adminshell/aas/v3/model/validator/TestAASd_076.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ public void englishPreferredName() throws ValidationException {
5555
ShaclValidator.getInstance().validate(cd);
5656
}
5757

58+
@Test
59+
public void noIEC61360DataSpecification() throws ValidationException {
60+
ConceptDescription description = ConstraintTestHelper.createConceptDescription("testIdShort", "testId",
61+
"PROPERTY");
62+
63+
ShaclValidator.getInstance().validate(description);
64+
}
65+
66+
5867
@Test
5968
public void noEnglishPreferredName() {
6069
LangString preferredName = new LangString("deutsch", "DE");
@@ -76,6 +85,7 @@ private ConceptDescription createConceptDescription(LangString preferredName) {
7685

7786
DataSpecificationIEC61360 urlDataTypeDS = new DefaultDataSpecificationIEC61360.Builder()
7887
.preferredName(preferredName)
88+
.preferredName(new LangString("test", "de"))
7989
.definition(new LangString("definition", "en"))
8090
.dataType(DataTypeIEC61360.URL)
8191
.build();

0 commit comments

Comments
 (0)