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

Commit 606880b

Browse files
author
Subash Kannoth
committed
Adds AAS constraints validation tests
1 parent 40ec29c commit 606880b

3 files changed

Lines changed: 803 additions & 4 deletions

File tree

validator/src/main/java/io/adminshell/aas/v3/model/validator/ShaclValidator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,10 @@ private ShaclValidator() {
150150
//All loaded, let's parse!
151151
//shapes = Shapes.parse(shapesModel);
152152
InputStream shapesInputStream = getClass().getClassLoader().getResourceAsStream("shapes.ttl");
153+
InputStream constraintShapesInputStream = getClass().getClassLoader().getResourceAsStream("constraint_shapes.ttl");
153154
InputStream ontologyInputStream = getClass().getClassLoader().getResourceAsStream("ontology.ttl");
154155
shapesModel.read(shapesInputStream, null, FileUtils.langTurtle);
156+
shapesModel.read(constraintShapesInputStream, null, FileUtils.langTurtle);
155157
shapes = Shapes.parse(shapesModel);
156158
ontologyModel = ModelFactory.createDefaultModel();
157159

Lines changed: 386 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,386 @@
1+
#@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
2+
#@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
3+
#@prefix xs: <http://www.w3.org/2001/XMLSchema#> .
4+
5+
@prefix phys_unit: <https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC01/> .
6+
@prefix dash: <http://datashapes.org/dash#> .
7+
@prefix dc: <http://purl.org/dc/elements/1.1/> .
8+
@prefix dcterms: <http://purl.org/dc/terms/> .
9+
@prefix owl: <http://www.w3.org/2002/07/owl#> .
10+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
11+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
12+
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
13+
@prefix vann: <http://purl.org/vocab/vann/> .
14+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
15+
@prefix sh: <http://www.w3.org/ns/shacl#> .
16+
@prefix aas: <https://admin-shell.io/aas/3/0/RC01/> .
17+
@prefix iec61360: <https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC01/> .
18+
@prefix iecType: <https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC01/DataTypeIEC61360/> .
19+
@base <https://admin-shell.io/aas/3/0/RC01/> .
20+
21+
22+
aas:AdministrativeInformationShape a sh:NodeShape ;
23+
sh:targetClass aas:AdministrativeInformation ;
24+
rdfs:subClassOf aas:HasDataSpecificationShape ;
25+
sh:property [
26+
a sh:PropertyShape ;
27+
sh:path <https://admin-shell.io/aas/3/0/RC01/AdministrativeInformation/revision> ;
28+
sh:datatype xsd:string ;
29+
sh:maxCount 1 ;
30+
sh:minCount 0 ;
31+
sh:message "(AdministrativeInformation.revision):<i>AdministrativeInformationShape</i>: Only one value for <i>revision</i> is allowed."^^xsd:string ;
32+
] ;
33+
sh:property [
34+
a sh:PropertyShape ;
35+
sh:path <https://admin-shell.io/aas/3/0/RC01/AdministrativeInformation/revision> ;
36+
sh:datatype xsd:string ;
37+
sh:pattern "^(\\w+\\S+)$" ;
38+
sh:message "(AdministrativeInformation.revision):<i>AdministrativeInformationShape</i>: The value of <i>revision</i> is not allowed to be empty."^^xsd:string ;
39+
sh:nodeKind sh:Literal ;
40+
] ;
41+
sh:property [
42+
a sh:PropertyShape ;
43+
sh:path <https://admin-shell.io/aas/3/0/RC01/AdministrativeInformation/version> ;
44+
sh:datatype xsd:string ;
45+
sh:maxCount 1 ;
46+
sh:minCount 0 ;
47+
sh:message "(AdministrativeInformation.version):Only one value for <i>version</i> is allowed."^^xsd:string ;
48+
] ;
49+
sh:property [
50+
a sh:PropertyShape ;
51+
sh:path <https://admin-shell.io/aas/3/0/RC01/AdministrativeInformation/version> ;
52+
sh:datatype xsd:string ;
53+
sh:pattern "^(\\w+\\S+)$" ;
54+
sh:message "(AdministrativeInformation.version):The value of <i>version</i> is not allowed to be empty."^^xsd:string ;
55+
sh:nodeKind sh:Literal ;
56+
] ;
57+
.
58+
59+
# AASd-005
60+
aas:RevisionRequiresVersionShape
61+
a sh:NodeShape ;
62+
sh:targetClass aas:AdministrativeInformation ;
63+
sh:message "(RevisionRequiresVersionShape): AASd-005 - A revision requires a version." ^^xsd:string ;
64+
sh:or (
65+
[
66+
sh:property [
67+
sh:path <https://admin-shell.io/aas/3/0/RC01/AdministrativeInformation/revision> ;
68+
sh:minCount 0 ;
69+
sh:maxCount 0 ;
70+
]
71+
]
72+
[
73+
sh:and (
74+
sh:property [
75+
sh:path <https://admin-shell.io/aas/3/0/RC01/AdministrativeInformation/revision> ;
76+
sh:minCount 1 ;
77+
sh:maxCount 1 ;
78+
]
79+
sh:property [
80+
sh:path <https://admin-shell.io/aas/3/0/RC01/AdministrativeInformation/version> ;
81+
sh:minCount 1 ;
82+
sh:maxCount 1 ;
83+
]
84+
)
85+
]
86+
)
87+
.
88+
89+
# AASd-014
90+
aas:SelfManagedEntityRequiresAssetIdShape a sh:NodeShape ;
91+
rdfs:subClassOf aas:SubmodelElementShape ;
92+
sh:targetClass aas:Entity ;
93+
sh:message "(SelfManagedEntityRequiresAssetIdShape): AASd-014 - Either the attribute globalAssetId or specificAssetId of an Entity must be set if Entity/entityType is set to “SelfManagedEntity”. They are not existing otherwise. " ^^xsd:string ;
94+
95+
sh:xone(
96+
[
97+
sh:and([
98+
sh:property [
99+
a sh:PropertyShape ;
100+
sh:path <https://admin-shell.io/aas/3/0/RC01/Entity/entityType> ;
101+
sh:minCount 1;
102+
sh:maxCount 1;
103+
sh:pattern "SELF_MANAGED_ENTITY";
104+
];
105+
]
106+
[
107+
sh:or(
108+
[
109+
sh:property [
110+
sh:path <https://admin-shell.io/aas/3/0/RC01/Entity/globalAssetId>;
111+
sh:minCount 1;
112+
sh:maxCount 1;
113+
];
114+
]
115+
[
116+
sh:property [
117+
sh:path <https://admin-shell.io/aas/3/0/RC01/Entity/specificAssetId>;
118+
sh:minCount 1;
119+
sh:maxCount 1;
120+
];
121+
]
122+
)
123+
]
124+
)
125+
]
126+
[
127+
sh:and(
128+
[
129+
sh:property [
130+
a sh:PropertyShape ;
131+
sh:path <https://admin-shell.io/aas/3/0/RC01/Entity/entityType> ;
132+
sh:minCount 1;
133+
sh:maxCount 1;
134+
sh:pattern "CO_MANAGED_ENTITY";
135+
];
136+
]
137+
[
138+
sh:property [
139+
sh:path <https://admin-shell.io/aas/3/0/RC01/Entity/globalAssetId>;
140+
sh:minCount 0;
141+
sh:maxCount 0;
142+
];
143+
]
144+
[
145+
sh:property [
146+
sh:path <https://admin-shell.io/aas/3/0/RC01/Entity/specificAssetId>;
147+
sh:minCount 0;
148+
sh:maxCount 0;
149+
];
150+
]
151+
)
152+
]
153+
)
154+
.
155+
156+
# AASd-051
157+
aas:ConceptDescriptionAllowedCategories a sh:NodeShape ;
158+
sh:targetClass aas:ConceptDescription ;
159+
rdfs:subClassOf aas:HasDataSpecificationShape ;
160+
rdfs:subClassOf aas:IdentifiableShape ;
161+
162+
sh:property [
163+
a sh:PropertyShape ;
164+
sh:path <https://admin-shell.io/aas/3/0/RC01/Referable/category> ;
165+
sh:datatype xsd:string ;
166+
sh:maxCount 1 ;
167+
sh:minCount 0 ;
168+
sh:pattern "^VALUE|^PROPERTY|^REFERENCE|^DOCUMENT|^CAPABILITY|^RELATIONSHIP|^COLLECTION|^FUNCTION|^EVENT|^ENTITY|^APPLICATION_CLASS|^QUALIFIER|^VIEW";
169+
sh:message "(ConceptDescriptionAllowedCategories) : AASd-051 - A ConceptDescription shall have one of the following categories: VALUE, PROPERTY, REFERENCE, DOCUMENT, CAPABILITY, RELATIONSHIP, COLLECTION, FUNCTION, EVENT, ENTITY, APPLICATION_CLASS, QUALIFIER, VIEW " ^^xsd:string ;
170+
] ;
171+
.
172+
173+
# AASd-070 # AASd-073
174+
aas:ConceptDataSpecificationIEC61360PropertyQaulifierValue a sh:NodeShape ;
175+
sh:targetClass aas:ConceptDescription ;
176+
rdfs:subClassOf aas:HasDataSpecificationShape ;
177+
rdfs:subClassOf aas:IdentifiableShape ;
178+
sh:message "(ConceptDataSpecificationIEC61360PropertyQualifierValue) : AASd-073 - For a ConceptDescription with category PROPERTY or VALUE using data specification template IEC61360 (http://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/2/0) - DataSpecificationIEC61360/dataType is mandatory and shall be defined." ^^xsd:string ;
179+
sh:or(
180+
sh:not[
181+
sh:property [
182+
a sh:PropertyShape ;
183+
sh:path <https://admin-shell.io/aas/3/0/RC01/Referable/category> ;
184+
sh:datatype xsd:string ;
185+
sh:maxCount 1 ;
186+
sh:minCount 0 ;
187+
sh:pattern "^VALUE|^PROPERTY|^QUALIFIER";
188+
];
189+
]
190+
[
191+
sh:property [
192+
a sh:PropertyShape ;
193+
sh:path <https://admin-shell.io/aas/3/0/RC01/HasDataSpecification/embeddedDataSpecification> ;
194+
sh:class aas:EmbeddedDataSpecification ;
195+
sh:minCount 1 ;
196+
sh:property [
197+
a sh:PropertyShape ;
198+
sh:path <https://admin-shell.io/aas/3/0/RC01/EmbeddedDataSpecification/dataSpecificationContent> ;
199+
sh:class aas:DataSpecificationContent ;
200+
sh:minCount 1 ;
201+
sh:property [
202+
a sh:PropertyShape ;
203+
sh:path <https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC01/DataSpecificationIEC61360/dataType> ;
204+
sh:minCount 1 ;
205+
] ;
206+
] ;
207+
];
208+
]
209+
)
210+
.
211+
212+
# AASd-071
213+
aas:ConceptDataSpecificationIEC61360Reference a sh:NodeShape ;
214+
sh:targetClass aas:ConceptDescription ;
215+
rdfs:subClassOf aas:HasDataSpecificationShape ;
216+
rdfs:subClassOf aas:IdentifiableShape ;
217+
sh:message "(ConceptDataSpecificationIEC61360Reference) : AASd-071 - For a ConceptDescription with category REFERENCE using data specification template IEC61360 (http://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/2/0) - DataSpecificationIEC61360/dataType is STRING by default." ^^xsd:string ;
218+
sh:or(
219+
sh:not[
220+
sh:property [
221+
a sh:PropertyShape ;
222+
sh:path <https://admin-shell.io/aas/3/0/RC01/Referable/category> ;
223+
sh:datatype xsd:string ;
224+
sh:maxCount 1 ;
225+
sh:minCount 0 ;
226+
sh:pattern "^REFERENCE";
227+
];
228+
]
229+
[
230+
sh:property [
231+
a sh:PropertyShape ;
232+
sh:path <https://admin-shell.io/aas/3/0/RC01/HasDataSpecification/embeddedDataSpecification> ;
233+
sh:class aas:EmbeddedDataSpecification ;
234+
sh:minCount 1 ;
235+
sh:property [
236+
a sh:PropertyShape ;
237+
sh:path <https://admin-shell.io/aas/3/0/RC01/EmbeddedDataSpecification/dataSpecificationContent> ;
238+
sh:class aas:DataSpecificationContent ;
239+
sh:minCount 1 ;
240+
sh:property [
241+
a sh:PropertyShape ;
242+
sh:path <https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC01/DataSpecificationIEC61360/dataType> ;
243+
sh:minCount 1 ;
244+
sh:in (iecType:STRING);
245+
#sh: iec61360:String;
246+
] ;
247+
] ;
248+
];
249+
]
250+
)
251+
.
252+
# AASd-072
253+
aas:ConceptDataSpecificationIEC61360Document a sh:NodeShape ;
254+
sh:targetClass aas:ConceptDescription ;
255+
rdfs:subClassOf aas:HasDataSpecificationShape ;
256+
rdfs:subClassOf aas:IdentifiableShape ;
257+
sh:message "(ConceptDataSpecificationIEC61360Document) : AASd-072 - For a ConceptDescription with category DOCUMENT using data specification template IEC61360 (http://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/2/0) - DataSpecificationIEC61360/dataType shall be one of the following values: STRING or URL." ^^xsd:string ;
258+
sh:or(
259+
sh:not[
260+
sh:property [
261+
a sh:PropertyShape ;
262+
sh:path <https://admin-shell.io/aas/3/0/RC01/Referable/category> ;
263+
sh:datatype xsd:string ;
264+
sh:maxCount 1 ;
265+
sh:minCount 0 ;
266+
sh:pattern "^DOCUMENT";
267+
];
268+
]
269+
[
270+
sh:property [
271+
a sh:PropertyShape ;
272+
sh:path <https://admin-shell.io/aas/3/0/RC01/HasDataSpecification/embeddedDataSpecification> ;
273+
sh:class aas:EmbeddedDataSpecification ;
274+
sh:minCount 1 ;
275+
sh:property [
276+
a sh:PropertyShape ;
277+
sh:path <https://admin-shell.io/aas/3/0/RC01/EmbeddedDataSpecification/dataSpecificationContent> ;
278+
sh:class aas:DataSpecificationContent ;
279+
sh:minCount 1 ;
280+
sh:property [
281+
a sh:PropertyShape ;
282+
sh:path <https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC01/DataSpecificationIEC61360/dataType> ;
283+
sh:maxCount 1 ;
284+
sh:pattern "STRING|URL";
285+
] ;
286+
] ;
287+
];
288+
]
289+
)
290+
.
291+
292+
# AASd-074 AASd-076
293+
aas:ConceptDataSpecificationIEC61360Value2 a sh:NodeShape ;
294+
sh:targetClass aas:ConceptDescription ;
295+
rdfs:subClassOf aas:HasDataSpecificationShape ;
296+
rdfs:subClassOf aas:IdentifiableShape ;
297+
sh:message "(ConceptDataSpecificationIEC61360Value2) : AASd-074 AASd-076 - 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 ;
298+
299+
sh:or(
300+
[
301+
sh:and(
302+
[
303+
sh:property [
304+
a sh:PropertyShape ;
305+
sh:path <https://admin-shell.io/aas/3/0/RC01/Referable/category> ;
306+
sh:datatype xsd:string ;
307+
sh:maxCount 1 ;
308+
sh:minCount 0 ;
309+
];
310+
]
311+
[
312+
sh:property [
313+
a sh:PropertyShape ;
314+
sh:path <https://admin-shell.io/aas/3/0/RC01/HasDataSpecification/embeddedDataSpecification> ;
315+
sh:class aas:EmbeddedDataSpecification ;
316+
sh:minCount 1 ;
317+
sh:property [
318+
a sh:PropertyShape ;
319+
sh:path <https://admin-shell.io/aas/3/0/RC01/EmbeddedDataSpecification/dataSpecificationContent> ;
320+
sh:class aas:DataSpecificationContent ;
321+
sh:minCount 1 ;
322+
sh:property [
323+
a sh:PropertyShape ;
324+
sh:path <https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC01/DataSpecificationIEC61360/definition> ;
325+
sh:minCount 1 ;
326+
sh:languageIn ("en");
327+
sh:pattern "(.*?)"
328+
] ;
329+
] ;
330+
];
331+
]
332+
)
333+
]
334+
[
335+
sh:property [
336+
a sh:PropertyShape ;
337+
sh:path <https://admin-shell.io/aas/3/0/RC01/Referable/category> ;
338+
sh:datatype xsd:string ;
339+
sh:maxCount 0 ;
340+
sh:minCount 0 ;
341+
#sh:pattern "^VALUE";
342+
];
343+
]
344+
)
345+
.
346+
347+
#AASd-071
348+
aas:ConceptDataSpecificationIEC61360ReferenceDataType a sh:NodeShape ;
349+
sh:targetClass aas:ConceptDescription ;
350+
rdfs:subClassOf aas:HasDataSpecificationShape ;
351+
rdfs:subClassOf aas:IdentifiableShape ;
352+
sh:message "(ConceptDataSpecificationIEC61360ReferenceDataType) : For a ConceptDescription with category REFERENCE using data specification template IEC61360 (http://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/2/0) - DataSpecificationIEC61360/dataType is STRING by default." ^^xsd:string ;
353+
sh:or(
354+
sh:not[
355+
sh:property [
356+
a sh:PropertyShape ;
357+
sh:path <https://admin-shell.io/aas/3/0/RC01/Referable/category> ;
358+
sh:datatype xsd:string ;
359+
sh:maxCount 1 ;
360+
sh:minCount 1 ;
361+
sh:pattern "^REFERENCE";
362+
363+
];
364+
]
365+
[
366+
sh:property [
367+
a sh:PropertyShape ;
368+
sh:path <https://admin-shell.io/aas/3/0/RC01/HasDataSpecification/embeddedDataSpecification> ;
369+
sh:class aas:EmbeddedDataSpecification ;
370+
sh:minCount 1 ;
371+
sh:property [
372+
a sh:PropertyShape ;
373+
sh:path <https://admin-shell.io/aas/3/0/RC01/EmbeddedDataSpecification/dataSpecificationContent> ;
374+
sh:class aas:DataSpecificationContent ;
375+
sh:minCount 1 ;
376+
sh:property [
377+
a sh:PropertyShape ;
378+
sh:path <https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0/RC01/DataSpecificationIEC61360/dataType> ;
379+
sh:minCount 1 ;
380+
sh:pattern "STRING$";
381+
] ;
382+
] ;
383+
];
384+
]
385+
)
386+
.

0 commit comments

Comments
 (0)