Class LintService
Every property used must be declared in the ontology, and every rdf:type object must
be a class declared in the ontology. The only terms permitted beyond the ontology are
rdf:type, rdfs:label, and rdfs:comment. Assertions that pass are returned
re-serialized in Turtle syntax, ready for ingestion.
-
Constructor Summary
ConstructorsConstructorDescriptionLintService(org.apache.jena.ontapi.model.OntModel ontModel, org.apache.jena.shacl.ShaclValidator shaclValidator, org.apache.jena.shacl.Shapes shapes) Creates the service, indexing the classes and properties declared in the ontology. -
Method Summary
Modifier and TypeMethodDescriptiongetErrors(org.apache.jena.shacl.ValidationReport validationReport) Renders the violations of a validation report.getViolations(org.apache.jena.rdf.model.Model model) Reports the ways the given statements depart from the ontology: a property the ontology does not declare (other thanrdf:type,rdfs:label, orrdfs:comment), or anrdf:typenaming anything but an ontology class.ai.chatur.cortex.LintResultLints the given assertions against the ontology.org.apache.jena.shacl.ValidationReportvalidate(org.apache.jena.rdf.model.Model model) Validates the given model against the configured SHACL shapes.
-
Constructor Details
-
LintService
public LintService(org.apache.jena.ontapi.model.OntModel ontModel, org.apache.jena.shacl.ShaclValidator shaclValidator, org.apache.jena.shacl.Shapes shapes) Creates the service, indexing the classes and properties declared in the ontology.- Parameters:
ontModel- the ontology modelshaclValidator- the validator applied to incoming assertionsshapes- the SHACL shapes incoming assertions must conform to
-
-
Method Details
-
validate
public org.apache.jena.shacl.ValidationReport validate(org.apache.jena.rdf.model.Model model) Validates the given model against the configured SHACL shapes.- Parameters:
model- the model to validate- Returns:
- the validation report
-
getErrors
Renders the violations of a validation report.- Parameters:
validationReport- the report to render- Returns:
- the printed report, or
nullif the report conforms
-
lint
Lints the given assertions against the ontology.Assertions that cannot be parsed, use a property not declared in the ontology (other than
rdf:type,rdfs:label, orrdfs:comment), or type a resource with anything but an ontology class are rejected; the violations are reported in the result instead.- Parameters:
ttl- RDF assertions in Turtle syntax- Returns:
- the outcome, carrying either the validated assertions in Turtle syntax or the lint violations
-
getViolations
Reports the ways the given statements depart from the ontology: a property the ontology does not declare (other thanrdf:type,rdfs:label, orrdfs:comment), or anrdf:typenaming anything but an ontology class.Separate from
lint(String)so the same check applies to statements that never arrived as Turtle — an edit proposed against already-approved assertions is assembled as a model, not parsed from a document.- Parameters:
model- the statements to check- Returns:
- the violations, empty if the statements conform to the ontology
-