|
15 | 15 | */
|
16 | 16 | package io.adminshell.aas.v3.model.validator;
|
17 | 17 |
|
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 | + |
19 | 25 | import org.apache.jena.graph.compose.Union;
|
20 | 26 | import org.apache.jena.rdf.model.Model;
|
21 | 27 | import org.apache.jena.rdf.model.ModelFactory;
|
|
27 | 33 | import org.apache.jena.util.FileUtils;
|
28 | 34 | import org.slf4j.LoggerFactory;
|
29 | 35 |
|
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; |
34 | 37 |
|
35 | 38 |
|
36 | 39 | public class ShaclValidator implements Validator{
|
@@ -124,34 +127,13 @@ private ShaclValidator() {
|
124 | 127 | //Initialize an empty model into which we will be loading the shapes
|
125 | 128 | Model shapesModel = ModelFactory.createDefaultModel();
|
126 | 129 |
|
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 |
| - |
150 | 130 | //All loaded, let's parse!
|
151 | 131 | //shapes = Shapes.parse(shapesModel);
|
152 | 132 | InputStream shapesInputStream = getClass().getClassLoader().getResourceAsStream("shapes.ttl");
|
| 133 | + InputStream constraintShapesInputStream = getClass().getClassLoader().getResourceAsStream("constraint_shapes.ttl"); |
153 | 134 | InputStream ontologyInputStream = getClass().getClassLoader().getResourceAsStream("ontology.ttl");
|
154 | 135 | shapesModel.read(shapesInputStream, null, FileUtils.langTurtle);
|
| 136 | + shapesModel.read(constraintShapesInputStream, null, FileUtils.langTurtle); |
155 | 137 | shapes = Shapes.parse(shapesModel);
|
156 | 138 | ontologyModel = ModelFactory.createDefaultModel();
|
157 | 139 |
|
|
0 commit comments