Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions db-server/init-data/forms/example-1.ttl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix doc: <http://onto.fel.cvut.cz/ontologies/documentation/> .
@prefix ex1: <https://example.org/sfc-example-1/> .
@prefix form: <http://onto.fel.cvut.cz/ontologies/form/> .
Expand Down Expand Up @@ -53,7 +53,7 @@ ex1:answerable-section-with-advanced-switch a doc:question ;
form:has-identifying-question "test-5279" ;
form:has-preceding-question ex1:non-answerable-section-with-advanced-switch ;
form:has-question-origin ex1:answerable-section-with-advanced-switch-qo ;
dc:source <https://slovník.gov.cz/generický/množství/pojem/má-jednotku> .
dcterms:source <https://slovník.gov.cz/generický/množství/pojem/má-jednotku> .

ex1:first-name-9402 a doc:question ;
rdfs:label "Jméno" ;
Expand Down Expand Up @@ -174,7 +174,7 @@ ex1:ps-cin-452 a doc:question ;
form-lt:has-layout-class "text" ;
form:has-question-origin ex1:ps-cin-452-qo ;
form:is-relevant-if ex1:provozovatel-pravnicka-osoba-condition ;
dc:description "Company identification number" .
dcterms:description "Company identification number" .

ex1:ps-iq-452 a doc:question ;
rdfs:label "IQ" ;
Expand Down Expand Up @@ -229,13 +229,13 @@ ex1:test-field-3888 a doc:question ;
rdfs:label "Field test" ;
form-lt:has-layout-class "text" ;
form:has-question-origin ex1:test-field-3888-qo ;
dc:source <https://slovník.gov.cz/generický/množství/pojem/má-jednotku> .
dcterms:source <https://slovník.gov.cz/generický/množství/pojem/má-jednotku> .

ex1:test-field-3888-na a doc:question ;
rdfs:label "Field test" ;
form-lt:has-layout-class "text" ;
form:has-question-origin ex1:test-field-3888-na-qo ;
dc:source <https://slovník.gov.cz/generický/množství/pojem/má-jednotku> .
dcterms:source <https://slovník.gov.cz/generický/množství/pojem/má-jednotku> .

ex1:age-1063 a doc:question ;
rdfs:label "Age" ;
Expand All @@ -252,7 +252,7 @@ ex1:cena-6557 a doc:question ;
form:has-preceding-question ex1:age-1063 ;
form:has-question-origin ex1:cena-6557-qo ;
form:has-unit-of-measure-question "mena-8088" ;
dc:description "Tohle je cena s měnou" .
dcterms:description "Tohle je cena s měnou" .

ex1:non-answerable-section-with-advanced-switch a doc:question ;
rdfs:label "Simple section with advanced switch" ;
Expand All @@ -265,7 +265,7 @@ ex1:non-answerable-section-with-advanced-switch a doc:question ;
form:has-identifying-question "test-5279-na" ;
form:has-preceding-question ex1:test-section-666 ;
form:has-question-origin ex1:non-answerable-section-with-advanced-switch-qo ;
dc:source <https://slovník.gov.cz/generický/množství/pojem/má-jednotku> .
dcterms:source <https://slovník.gov.cz/generický/množství/pojem/má-jednotku> .

ex1:parent-section-1590 a doc:question ;
rdfs:label "Vlastník" ;
Expand Down Expand Up @@ -312,7 +312,7 @@ ex1:show-advanced-question-test-advanced-switch a doc:question ;
form:has-timestamp "1636061441831" ] ;
form:has-question-origin ex1:form-show-advanced-question ;
form:show-advanced-question true ;
dc:description "Advanced switch test" .
dcterms:description "Advanced switch test" .

ex1:show-advanced-question-test-advanced-switch-na a doc:question ;
rdfs:label "Advanced switch test" ;
Expand All @@ -327,7 +327,7 @@ ex1:show-advanced-question-test-advanced-switch-na a doc:question ;
form:has-timestamp "1636065441831" ] ;
form:has-question-origin ex1:form-show-advanced-question ;
form:show-advanced-question true ;
dc:description "Advanced switch test" .
dcterms:description "Advanced switch test" .

ex1:test-field-3887 a doc:question ;
rdfs:label "Popis vlastníka" ;
Expand All @@ -343,7 +343,7 @@ ex1:test-section-666 a doc:question ;
form:has-identifying-question "test-5278" ;
form:has-preceding-question ex1:parent-section-1590 ;
form:has-question-origin ex1:test-section-666-qo ;
dc:description "test" .
dcterms:description "test" .

ex1:title-7183 a doc:question ;
rdfs:label "Titul" ;
Expand Down
20 changes: 10 additions & 10 deletions db-server/init-data/forms/example-2.ttl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix doc: <http://onto.fel.cvut.cz/ontologies/documentation/> .
@prefix ex2: <https://example.org/sfc-example-2/> .
@prefix form: <http://onto.fel.cvut.cz/ontologies/form/> .
Expand Down Expand Up @@ -53,7 +53,7 @@ ex2:answerable-section-with-advanced-switch a doc:question ;
form:has-identifying-question "test-5279" ;
form:has-preceding-question ex2:non-answerable-section-with-advanced-switch ;
form:has-question-origin ex2:answerable-section-with-advanced-switch-qo ;
dc:source <https://slovník.gov.cz/generický/množství/pojem/má-jednotku> .
dcterms:source <https://slovník.gov.cz/generický/množství/pojem/má-jednotku> .

ex2:first-name-9402 a doc:question ;
rdfs:label "Jméno" ;
Expand Down Expand Up @@ -174,7 +174,7 @@ ex2:ps-cin-452 a doc:question ;
form-lt:has-layout-class "text" ;
form:has-question-origin ex2:ps-cin-452-qo ;
form:is-relevant-if ex2:provozovatel-pravnicka-osoba-condition ;
dc:description "Company identification number" .
dcterms:description "Company identification number" .

ex2:ps-iq-452 a doc:question ;
rdfs:label "IQ" ;
Expand Down Expand Up @@ -229,13 +229,13 @@ ex2:test-field-3888 a doc:question ;
rdfs:label "Field test" ;
form-lt:has-layout-class "text" ;
form:has-question-origin ex2:test-field-3888-qo ;
dc:source <https://slovník.gov.cz/generický/množství/pojem/má-jednotku> .
dcterms:source <https://slovník.gov.cz/generický/množství/pojem/má-jednotku> .

ex2:test-field-3888-na a doc:question ;
rdfs:label "Field test" ;
form-lt:has-layout-class "text" ;
form:has-question-origin ex2:test-field-3888-na-qo ;
dc:source <https://slovník.gov.cz/generický/množství/pojem/má-jednotku> .
dcterms:source <https://slovník.gov.cz/generický/množství/pojem/má-jednotku> .

ex2:age-1063 a doc:question ;
rdfs:label "Age" ;
Expand All @@ -252,7 +252,7 @@ ex2:cena-6557 a doc:question ;
form:has-preceding-question ex2:age-1063 ;
form:has-question-origin ex2:cena-6557-qo ;
form:has-unit-of-measure-question "mena-8088" ;
dc:description "Tohle je cena s měnou" .
dcterms:description "Tohle je cena s měnou" .

ex2:non-answerable-section-with-advanced-switch a doc:question ;
rdfs:label "Simple section with advanced switch" ;
Expand All @@ -265,7 +265,7 @@ ex2:non-answerable-section-with-advanced-switch a doc:question ;
form:has-identifying-question "test-5279-na" ;
form:has-preceding-question ex2:test-section-666 ;
form:has-question-origin ex2:non-answerable-section-with-advanced-switch-qo ;
dc:source <https://slovník.gov.cz/generický/množství/pojem/má-jednotku> .
dcterms:source <https://slovník.gov.cz/generický/množství/pojem/má-jednotku> .

ex2:parent-section-1590 a doc:question ;
rdfs:label "Vlastník" ;
Expand Down Expand Up @@ -312,7 +312,7 @@ ex2:show-advanced-question-test-advanced-switch a doc:question ;
form:has-timestamp "1636065441831" ] ;
form:has-question-origin ex2:form-show-advanced-question ;
form:show-advanced-question true ;
dc:description "Advanced switch test" .
dcterms:description "Advanced switch test" .

ex2:show-advanced-question-test-advanced-switch-na a doc:question ;
rdfs:label "Advanced switch test" ;
Expand All @@ -327,7 +327,7 @@ ex2:show-advanced-question-test-advanced-switch-na a doc:question ;
form:has-timestamp "1636061441831" ] ;
form:has-question-origin ex2:form-show-advanced-question ;
form:show-advanced-question true ;
dc:description "Advanced switch test" .
dcterms:description "Advanced switch test" .

ex2:test-field-3887 a doc:question ;
rdfs:label "Popis vlastníka" ;
Expand All @@ -343,7 +343,7 @@ ex2:test-section-666 a doc:question ;
form:has-identifying-question "test-5278" ;
form:has-preceding-question ex2:parent-section-1590 ;
form:has-question-origin ex2:test-section-666-qo ;
dc:description "test" .
dcterms:description "test" .

ex2:title-7183 a doc:question ;
rdfs:label "Titul" ;
Expand Down
7 changes: 4 additions & 3 deletions doc/form-template-shape.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# 2. it is typed form:form-template
# (http://onto.fel.cvut.cz/ontologies/form/form-template);
# 3. it has an rdfs:label;
# 4. it has an rdfs:comment.
# 4. it has a dcterms:description.
#
# This shape enforces requirements (2)-(4) — the triple-level pattern.
# Requirement (1), the named-graph constraint, cannot be expressed in core SHACL
Expand All @@ -16,6 +16,7 @@

@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix form: <http://onto.fel.cvut.cz/ontologies/form/> .

form:FormTemplateShape
Expand All @@ -31,7 +32,7 @@ form:FormTemplateShape
sh:message "A form template must have at least one rdfs:label; otherwise it is silently dropped from the form template listing." ;
] ;
sh:property [
sh:path rdfs:comment ;
sh:path dcterms:description ;
sh:minCount 1 ;
sh:message "A form template must have at least one rdfs:comment; otherwise it is silently dropped from the form template listing." ;
sh:message "A form template must have at least one dcterms:description; otherwise it is silently dropped from the form template listing." ;
] .
19 changes: 10 additions & 9 deletions doc/form-templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@ TTL files against it.
## Form template RDF pattern

A valid form template is a named graph whose IRI is the template IRI, containing a
resource (the same IRI) typed `form:form-template` with a label and a comment:
resource (the same IRI) typed `form:form-template` with a label and a description:

```trig
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix form: <http://onto.fel.cvut.cz/ontologies/form/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix form: <http://onto.fel.cvut.cz/ontologies/form/> .

<http://example.org/my-template> {
<http://example.org/my-template> a form:form-template ;
rdfs:label "My template" ;
rdfs:comment "Description of the template" .
rdfs:label "My template" ;
dcterms:description "Description of the template" .
}
```

Expand All @@ -33,10 +34,10 @@ A resource is recognized as a form template only when **all** of the following h
same. Triples in the default graph or in a differently named graph are not seen.
2. **It is typed `form:form-template`** (`http://onto.fel.cvut.cz/ontologies/form/form-template`).
3. **It has an `rdfs:label`** (`http://www.w3.org/2000/01/rdf-schema#label`).
4. **It has an `rdfs:comment`** (`http://www.w3.org/2000/01/rdf-schema#comment`).
4. **It has a `dcterms:description`** (`http://purl.org/dc/terms/description`).

The query's `WHERE` clause requires the type, label, and comment **conjunctively**, so a
candidate **missing either the label or the comment is silently dropped** from the result
The query's `WHERE` clause requires the type, label, and description **conjunctively**, so a
candidate **missing either the label or the description is silently dropped** from the result
— it does not appear even when correctly typed. The form-gen repository must also be a
quad store (it must preserve named graphs) and expose a SPARQL endpoint that accepts a
`query` parameter.
Expand All @@ -51,7 +52,7 @@ pyshacl -s doc/form-template-shape.ttl -f human your-templates.ttl
```

The shape targets `form:form-template` resources and reports a violation when the
`rdfs:label` or `rdfs:comment` is missing. Resources not typed as templates are ignored,
`rdfs:label` or `dcterms:description` is missing. Resources not typed as templates are ignored,
so the shape can be run against arbitrary TTL files.

**Named-graph caveat:** SHACL validates the merged data graph, not graph names, so the
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/query/find-raw-records.sparql
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
PREFIX av: <http://onto.fel.cvut.cz/ontologies/ava/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX doc: <http://onto.fel.cvut.cz/ontologies/documentation/>
PREFIX form: <http://onto.fel.cvut.cz/ontologies/form/>
PREFIX form-lt: <http://onto.fel.cvut.cz/ontologies/form-layout/>
Expand Down
9 changes: 5 additions & 4 deletions src/main/resources/query/findFormTemplates.rq
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix form: <http://onto.fel.cvut.cz/ontologies/form/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dcterms: <http://purl.org/dc/terms/>
prefix form: <http://onto.fel.cvut.cz/ontologies/form/>

CONSTRUCT {
?formTemplate a form:form-template .
?formTemplate rdfs:label ?formTemplateLabel .
?formTemplate rdfs:comment ?formTemplateComment .
?formTemplate dcterms:description ?formTemplateDescription .
} WHERE {
GRAPH ?formTemplate {
?formTemplate a form:form-template .
?formTemplate rdfs:label ?formTemplateLabel .
?formTemplate rdfs:comment ?formTemplateComment .
?formTemplate dcterms:description ?formTemplateDescription .
}
}
Loading