From 4dc801aa9c64082240cbbc24933e905c8ddfb8e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ha=CC=8Avard=20Ottestad?= Date: Tue, 7 Nov 2023 12:27:46 +0100 Subject: [PATCH] GH-4834 remove code used for debugging --- .../Rdf4jShaclShapeGraphShapeSource.java | 50 +++++++------------ .../sail/shacl/wrapper/shape/ShapeSource.java | 7 --- 2 files changed, 19 insertions(+), 38 deletions(-) diff --git a/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/wrapper/shape/Rdf4jShaclShapeGraphShapeSource.java b/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/wrapper/shape/Rdf4jShaclShapeGraphShapeSource.java index 86456ee0a12..c0e4f32487d 100644 --- a/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/wrapper/shape/Rdf4jShaclShapeGraphShapeSource.java +++ b/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/wrapper/shape/Rdf4jShaclShapeGraphShapeSource.java @@ -18,6 +18,8 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import org.eclipse.rdf4j.common.exception.RDF4JException; +import org.eclipse.rdf4j.common.iteration.CloseableIteration; import org.eclipse.rdf4j.common.transaction.IsolationLevels; import org.eclipse.rdf4j.model.IRI; import org.eclipse.rdf4j.model.Model; @@ -82,48 +84,34 @@ private Rdf4jShaclShapeGraphShapeSource(Repository repository, RepositoryConnect private SailRepository forwardChain(RepositoryConnection shapesRepoConnection) { try (var statements = shapesRepoConnection.getStatements(null, null, null, false, RDF4J.SHACL_SHAPE_GRAPH)) { - if (!statements.hasNext()) { - return new SailRepository(new MemoryStore()); - } - - SailRepository shapesRepoWithReasoning = new SailRepository( - SchemaCachingRDFSInferencer.fastInstantiateFrom(shaclVocabulary, new MemoryStore(), false)); - - try (var shapesRepoWithReasoningConnection = shapesRepoWithReasoning.getConnection()) { - shapesRepoWithReasoningConnection.begin(IsolationLevels.NONE); - - shapesRepoWithReasoningConnection.add(statements); - enrichShapes(shapesRepoWithReasoningConnection); - - shapesRepoWithReasoningConnection.commit(); - } - - return shapesRepoWithReasoning; - + return forwardChain(statements); } } private SailRepository forwardChain(SailConnection shapesSailConnection) { try (var statements = shapesSailConnection.getStatements(null, null, null, false, RDF4J.SHACL_SHAPE_GRAPH)) { - if (!statements.hasNext()) { - return new SailRepository(new MemoryStore()); - } - - SailRepository shapesRepoWithReasoning = new SailRepository( - SchemaCachingRDFSInferencer.fastInstantiateFrom(shaclVocabulary, new MemoryStore(), false)); + return forwardChain(statements); + } + } - try (var shapesRepoWithReasoningConnection = shapesRepoWithReasoning.getConnection()) { - shapesRepoWithReasoningConnection.begin(IsolationLevels.NONE); + private SailRepository forwardChain(CloseableIteration statements) { + if (!statements.hasNext()) { + return new SailRepository(new MemoryStore()); + } - shapesRepoWithReasoningConnection.add(statements); - enrichShapes(shapesRepoWithReasoningConnection); + SailRepository shapesRepoWithReasoning = new SailRepository( + SchemaCachingRDFSInferencer.fastInstantiateFrom(shaclVocabulary, new MemoryStore(), false)); - shapesRepoWithReasoningConnection.commit(); - } + try (var shapesRepoWithReasoningConnection = shapesRepoWithReasoning.getConnection()) { + shapesRepoWithReasoningConnection.begin(IsolationLevels.NONE); - return shapesRepoWithReasoning; + shapesRepoWithReasoningConnection.add(statements); + enrichShapes(shapesRepoWithReasoningConnection); + shapesRepoWithReasoningConnection.commit(); } + + return shapesRepoWithReasoning; } private static SchemaCachingRDFSInferencer createShaclVocabulary() { diff --git a/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/wrapper/shape/ShapeSource.java b/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/wrapper/shape/ShapeSource.java index 5d4caed49b3..b4c0f61dfef 100644 --- a/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/wrapper/shape/ShapeSource.java +++ b/core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/wrapper/shape/ShapeSource.java @@ -47,10 +47,6 @@ private static Model resourceAsModel(String filename) { static Stream getRsxDataAndShapesGraphLink(SailConnection connection, Resource[] context) { Stream rsxDataAndShapesGraphLink; - List collect1 = connection.getStatements(null, null, null, false) - .stream() - .collect(Collectors.toList()); - try (var stream = connection.getStatements(null, RDF.TYPE, RSX.DataAndShapesGraphLink, false, context) .stream()) { @@ -108,9 +104,6 @@ static Stream getRsxDataAndShapesGraphLink(SailConnection connectio } static Stream getRsxDataAndShapesGraphLink(RepositoryConnection connection, Resource[] context) { - List collect1 = connection.getStatements(null, null, null, false) - .stream() - .collect(Collectors.toList()); Stream rsxDataAndShapesGraphLink; try (var stream = connection.getStatements(null, RDF.TYPE, RSX.DataAndShapesGraphLink, false, context)