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

Commit b551125

Browse files
committed
Merge branch 'master' into feature/validation
2 parents 3dccc85 + e35c677 commit b551125

38 files changed

Lines changed: 4104 additions & 99 deletions

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

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@
1515
*/
1616
package io.adminshell.aas.v3.model.validator;
1717

18-
import io.adminshell.aas.v3.dataformat.rdf.Serializer;
18+
import java.io.ByteArrayInputStream;
19+
import java.io.IOException;
20+
import java.io.InputStream;
21+
import java.nio.charset.StandardCharsets;
22+
import java.util.HashMap;
23+
import java.util.stream.Collectors;
24+
1925
import org.apache.jena.graph.compose.Union;
2026
import org.apache.jena.rdf.model.Model;
2127
import org.apache.jena.rdf.model.ModelFactory;
@@ -27,10 +33,7 @@
2733
import org.apache.jena.util.FileUtils;
2834
import org.slf4j.LoggerFactory;
2935

30-
import java.io.*;
31-
import java.nio.charset.StandardCharsets;
32-
import java.util.HashMap;
33-
import java.util.stream.Collectors;
36+
import io.adminshell.aas.v3.dataformat.rdf.Serializer;
3437

3538

3639
public class ShaclValidator implements Validator{
@@ -124,34 +127,13 @@ private ShaclValidator() {
124127
//Initialize an empty model into which we will be loading the shapes
125128
Model shapesModel = ModelFactory.createDefaultModel();
126129

127-
/*
128-
//Use resources from zip file
129-
//TODO: Will they be compressed?
130-
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("validation.zip");
131-
132-
//Stream this to some temporary file which will be deleted after program exit
133-
if (inputStream == null)
134-
throw new IOException("Failed to retrieve validation.zip from resources.");
135-
136-
File inputStreamToFile = File.createTempFile("validation_zip_file", null);
137-
inputStreamToFile.deleteOnExit();
138-
139-
Files.copy(inputStream, inputStreamToFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
140-
ZipFile zipFile = new ZipFile(inputStreamToFile);
141-
Enumeration<? extends ZipEntry> entries = zipFile.entries();
142-
143-
while (entries.hasMoreElements()) {
144-
shapesModel.read(zipFile.getInputStream(entries.nextElement()), null, FileUtils.langTurtle);
145-
}
146-
*/
147-
//shapesModel.read(Files.readString(Path.of("src/main/resources/shapes.ttl")));
148-
149-
150130
//All loaded, let's parse!
151131
//shapes = Shapes.parse(shapesModel);
152132
InputStream shapesInputStream = getClass().getClassLoader().getResourceAsStream("shapes.ttl");
133+
InputStream constraintShapesInputStream = getClass().getClassLoader().getResourceAsStream("constraint_shapes.ttl");
153134
InputStream ontologyInputStream = getClass().getClassLoader().getResourceAsStream("ontology.ttl");
154135
shapesModel.read(shapesInputStream, null, FileUtils.langTurtle);
136+
shapesModel.read(constraintShapesInputStream, null, FileUtils.langTurtle);
155137
shapes = Shapes.parse(shapesModel);
156138
ontologyModel = ModelFactory.createDefaultModel();
157139

0 commit comments

Comments
 (0)