feat(rdf-api): Add a general-purpose SHACL validation utility (DSP-930) #1762
Conversation
This looks great! Thanks for implementing this. |
* Recursively loads graphs of SHACL shapes from a directory and its subdirectories. | ||
* | ||
* @param baseDir the base directory that SHACL graphs are loaded from. | ||
* @param dir the base directory or a subdirectory. |
SepidehAlassi
Dec 1, 2020
Contributor
It seems like the Shacl shapes are actually loaded from dir
directory and its subdirectories, and baseDir
is only used to get its path to make the relativePath
. Can you please change the comments for baseDir
and dir
in scaladocs?
I also wonder, if only the path of the baseDir
is needed here, why not just using its path as the parameter of this function, I mean
private def loadShaclGraphs(baseDirPath: Path, dir: File) : Map[Path, ShaclGraphT] = {...}
two directory parameters are a bit confusing.
It seems like the Shacl shapes are actually loaded from dir
directory and its subdirectories, and baseDir
is only used to get its path to make the relativePath
. Can you please change the comments for baseDir
and dir
in scaladocs?
I also wonder, if only the path of the baseDir
is needed here, why not just using its path as the parameter of this function, I mean
private def loadShaclGraphs(baseDirPath: Path, dir: File) : Map[Path, ShaclGraphT] = {...}
two directory parameters are a bit confusing.
benjamingeer
Dec 1, 2020
Author
Collaborator
It seems like the Shacl shapes are actually loaded from dir
directory and its subdirectories, and baseDir
is only used to get its path to make the relativePath
.... I also wonder, if only the path of the baseDir
is needed here, why not just using its path as the parameter of this function
Actually, the SHACL shapes are loaded from baseDir
and its subdirectories. File
and Path
are basically the same thing, but File
is the old java.io
API which I'm more used to, and Path
is the newer java.nio
API. The consensus in the Java community seems to be that seems that Path
should be used instead of File
for everything nowadays (https://stackoverflow.com/a/26658436). I guess we should do a PR sometime to use java.nio
instead of java.io
everywhere. For now, I've refactored AbstractShaclValidator
to use java.nio
to walk the directory tree, which seems clearer.
It seems like the Shacl shapes are actually loaded from
dir
directory and its subdirectories, andbaseDir
is only used to get its path to make therelativePath
.... I also wonder, if only the path of thebaseDir
is needed here, why not just using its path as the parameter of this function
Actually, the SHACL shapes are loaded from baseDir
and its subdirectories. File
and Path
are basically the same thing, but File
is the old java.io
API which I'm more used to, and Path
is the newer java.nio
API. The consensus in the Java community seems to be that seems that Path
should be used instead of File
for everything nowadays (https://stackoverflow.com/a/26658436). I guess we should do a PR sometime to use java.nio
instead of java.io
everywhere. For now, I've refactored AbstractShaclValidator
to use java.nio
to walk the directory tree, which seems clearer.
val graphToValidate: jena.graph.Graph = rdfModel.asJenaDataset.asDatasetGraph.getDefaultGraph | ||
|
||
// Validate the data and get Jena's validation report. | ||
val validationReport: jena.shacl.ValidationReport = shaclValidator.validate(shaclGraph, graphToValidate) |
SepidehAlassi
Dec 1, 2020
Contributor
Nice! Jena Shacl validate
is like pyShacl getting the same parameters and returning report and conforms in the same way.
Nice! Jena Shacl validate
is like pyShacl getting the same parameters and returning report and conforms in the same way.
benjamingeer
Dec 1, 2020
Author
Collaborator
Standards are nice. :)
Standards are nice. :)
resolves DSP-930.
ShaclValidator.scala
.JenaShaclValidator
RDF4JShaclValidator
RdfFeatureFactory
.