New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(rdf-api): Add a general-purpose SHACL validation utility (DSP-930) #1762
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Jena Shacl validate
is like pyShacl getting the same parameters and returning report and conforms in the same way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Standards are nice. :)
resolves DSP-930.
ShaclValidator.scala
.JenaShaclValidator
RDF4JShaclValidator
RdfFeatureFactory
.