From 2556ba07c8708bedea8c86096aac59817722eecf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20K=C5=99emen?= Date: Fri, 23 Apr 2021 10:54:20 +0200 Subject: [PATCH] [#6] A concept must be declared before being used in a model. Bump version to 1.6.1 --- build.gradle | 2 +- src/main/resources/rules/s3.ttl | 30 +++++++++++++++++++ .../concept-without-declaration-used.ttl | 8 +++++ src/test/resources/test-cases.csv | 1 + 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/rules/s3.ttl create mode 100644 src/test/resources/rule-test-cases/concept-without-declaration-used.ttl diff --git a/build.gradle b/build.gradle index cce8ebb..a8802f9 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,7 @@ compileJava { } group 'com.github.sgov' -version = '1.6.0' +version = '1.6.1' test { useJUnitPlatform() diff --git a/src/main/resources/rules/s3.ttl b/src/main/resources/rules/s3.ttl new file mode 100644 index 0000000..518dc62 --- /dev/null +++ b/src/main/resources/rules/s3.ttl @@ -0,0 +1,30 @@ +@prefix skos: . +@prefix sh: . +@prefix j-sgov-obecný: . + +j-sgov-obecný:s2 + a sh:NodeShape ; + sh:severity sh:Warning ; + sh:message "Nedeklarovaný pojem je použit ve slovníku."@cs, + "Non-declared concept is used in a vocabulary."@en ; + sh:targetClass skos:Concept ; + sh:sparql [ a sh:SPARQLConstraint ; + sh:select """ + PREFIX skos: + PREFIX z-sgov-pojem: + PREFIX owl: + select $this (?g AS ?value) where { + GRAPH ?g { + { + ?s ?p ?o . + } UNION { + ?o ?p ?s . + } + FILTER(regex(str(?s),"https://slovník.gov.cz/.*/pojem/.*")) + FILTER(!strstarts(str(?s),"https://slovník.gov.cz/základní")) + FILTER NOT EXISTS { + ?s skos:inScheme ?g2 + } + } + } GROUP BY ?g $this""" ; ] +. diff --git a/src/test/resources/rule-test-cases/concept-without-declaration-used.ttl b/src/test/resources/rule-test-cases/concept-without-declaration-used.ttl new file mode 100644 index 0000000..ec4d434 --- /dev/null +++ b/src/test/resources/rule-test-cases/concept-without-declaration-used.ttl @@ -0,0 +1,8 @@ +@prefix : . +@prefix rdf: . +@prefix rdfs: . +@prefix skos: . +@prefix dc: . + +:volby-do-poslanecké-sněmovny-parlamentu-české-republiky + a skos:Concept ; diff --git a/src/test/resources/test-cases.csv b/src/test/resources/test-cases.csv index 02d836c..bedde59 100644 --- a/src/test/resources/test-cases.csv +++ b/src/test/resources/test-cases.csv @@ -84,3 +84,4 @@ m7.ttl ,rule-test-cases/category-specializing-kind.ttl ,Violation s2.ttl,rule-test-cases/concept-with-invalid-iri.ttl ,Violation s2.ttl,rule-test-cases/concept-with-valid-iri.ttl ,Pass s2.ttl,rule-test-cases/concept-with-comma-in-iri.ttl ,Pass +s3.ttl,rule-test-cases/concept-without-declaration-used.ttl ,Warning