This is an automated email from the ASF dual-hosted git repository.

andy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/jena.git


The following commit(s) were added to refs/heads/main by this push:
     new e8cc4c17bd Tidy up in jena-shacl
     new f6d1f0862b Merge pull request #1963 from afs/shacl-tidy
e8cc4c17bd is described below

commit e8cc4c17bd2d6d39d5e45b2c5f30184bf3f5a97a
Author: Andy Seaborne <[email protected]>
AuthorDate: Thu Jul 13 21:10:24 2023 +0100

    Tidy up in jena-shacl
---
 .../src/main/java/org/apache/jena/shacl/Shapes.java  | 12 ++++++++++--
 .../jena/shacl/compact/writer/CompactWriter.java     |  2 +-
 .../org/apache/jena/shacl/parser/ShapesParser.java   | 20 +++++++++++++++-----
 3 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/jena-shacl/src/main/java/org/apache/jena/shacl/Shapes.java 
b/jena-shacl/src/main/java/org/apache/jena/shacl/Shapes.java
index 28850aa95a..667450cf71 100644
--- a/jena-shacl/src/main/java/org/apache/jena/shacl/Shapes.java
+++ b/jena-shacl/src/main/java/org/apache/jena/shacl/Shapes.java
@@ -57,6 +57,10 @@ public class Shapes implements Iterable<Shape> {
     private final Collection<Shape> rootShapes;
     // Declared shapes, not in targetShapes.
     private final Collection<Shape> declShapes;
+    // Shapes that are not declared shapes (by type), and not accessible from 
in targets.
+    // This is placeholder.
+    // It should be disjoint with rootShapes and declShapes.
+    private final Collection<Shape> otherShapes;
     private final Targets targets;
 
     // Imports in the graph.
@@ -120,6 +124,7 @@ public class Shapes implements Iterable<Shape> {
         this.shapes = x.shapesMap;
         this.rootShapes = x.rootShapes;
         this.declShapes = x.declaredShapes;
+        this.otherShapes = x.otherShapes;
         this.shapesBase = x.shapesBase;
         this.imports = x.imports;
         //x.sparqlConstraintComponents
@@ -202,7 +207,10 @@ public class Shapes implements Iterable<Shape> {
      * PropertyShape.
      */
     public Iterator<Shape> iteratorAll() {
-        // rootsShapes and declShaes are disjoint so no duplicates in the 
iterator.
-        return Iter.concat(rootShapes.iterator(), declShapes.iterator());
+        // rootsShapes and declShapes are disjoint so no duplicates in the 
iterator.
+        return
+            Iter.iter(rootShapes.iterator())
+                .append(declShapes.iterator())
+                .append(otherShapes.iterator());
     }
 }
diff --git 
a/jena-shacl/src/main/java/org/apache/jena/shacl/compact/writer/CompactWriter.java
 
b/jena-shacl/src/main/java/org/apache/jena/shacl/compact/writer/CompactWriter.java
index 8dd79719a7..7e99b966cb 100644
--- 
a/jena-shacl/src/main/java/org/apache/jena/shacl/compact/writer/CompactWriter.java
+++ 
b/jena-shacl/src/main/java/org/apache/jena/shacl/compact/writer/CompactWriter.java
@@ -49,7 +49,7 @@ public class CompactWriter {
 
         // Formatter PrefixMap - with the std prefixes if not overridden.
         PrefixMap pmapWithStd = SHACLC.withStandardPrefixes();
-        // Add to copy of standrard so it can override any standard settings.
+        // Add to copy of the prefixes standard so we can later override any 
standard settings.
         pmapWithStd.putAll(graphPrefixMap);
         NodeFormatter nodeFmt = new NodeFormatterTTL(null, pmapWithStd);
 
diff --git 
a/jena-shacl/src/main/java/org/apache/jena/shacl/parser/ShapesParser.java 
b/jena-shacl/src/main/java/org/apache/jena/shacl/parser/ShapesParser.java
index c18e1999b7..4078360911 100644
--- a/jena-shacl/src/main/java/org/apache/jena/shacl/parser/ShapesParser.java
+++ b/jena-shacl/src/main/java/org/apache/jena/shacl/parser/ShapesParser.java
@@ -86,7 +86,6 @@ public class ShapesParser {
         return declared;
     }
 
-
     /* The parsing process.
      * <p>
      * Applications should call functions in {@link Shapes} rather than call 
the parser directly.
@@ -105,8 +104,9 @@ public class ShapesParser {
                                   .filter(sh->sh.hasTarget())
                                   .collect(Collectors.toUnmodifiableList());
 
-        // Parse other shapes - i.e. addressable node and property shapes 
without
-        // target if they were not reached when parsing form the targets.
+        // Parse non-target shapes - i.e. addressable node and property shapes 
without
+        // target, with type of sh:NodeShape or sh:PropertyShape
+        // if they were not reached when parsing from the targets.
         // This skips declared+targets because the shapesMap is in common.
         Collection<Shape> declShapes = new ArrayList<>();
         declaredNodes.forEach(shapeNode -> {
@@ -116,6 +116,12 @@ public class ShapesParser {
             }
         });
 
+        // Implicit shapes.
+        // Ones not declared with rdf:type sh:NodeShape or sh:PropertyShape
+        // and not reachable from a target.
+        // Placeholder for a possible feature.
+        Set<Shape> otherShapes = Set.of();
+
         // Check.
         // rootShapes and declShapes are disjoint.
         if ( true ) {
@@ -135,8 +141,9 @@ public class ShapesParser {
         Pair<Node, List<Node>> pair = Imports.baseAndImports(shapesGraph);
         Node shapesBase = pair.getLeft();
         List<Node> imports = pair.getRight();
-
-        ParserResult x = new ParserResult(shapesBase, imports, shapesMap, 
targets, rootShapes, declShapes, sparqlConstraintComponents, targetExtensions);
+        ParserResult x = new ParserResult(shapesBase, imports, shapesMap, 
targets,
+                                          rootShapes, declShapes, otherShapes,
+                                          sparqlConstraintComponents, 
targetExtensions);
         return x;
     }
 
@@ -478,6 +485,7 @@ public class ShapesParser {
         public final Targets targets;
         public final Collection<Shape> rootShapes;
         public final Collection<Shape> declaredShapes;
+        public final Collection<Shape> otherShapes;
         public final ConstraintComponents sparqlConstraintComponents;
         public final TargetExtensions targetExtensions;
 
@@ -487,6 +495,7 @@ public class ShapesParser {
                      Targets targets,
                      Collection<Shape> rootShapes,
                      Collection<Shape> declaredShapes,
+                     Collection<Shape> otherShapes,
                      ConstraintComponents sparqlConstraintComponents,
                      TargetExtensions targetExtensions) {
             this.shapesBase = shapesBase;
@@ -495,6 +504,7 @@ public class ShapesParser {
             this.targets = targets;
             this.rootShapes = rootShapes;
             this.declaredShapes = declaredShapes;
+            this.otherShapes = otherShapes;
             this.sparqlConstraintComponents = sparqlConstraintComponents;
             this.targetExtensions = targetExtensions;
         }

Reply via email to