Skip to content

Commit

Permalink
add exercises
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-metalinkage committed Oct 20, 2024
1 parent 3247851 commit 9ad8b74
Show file tree
Hide file tree
Showing 54 changed files with 5,802 additions and 36 deletions.
24 changes: 24 additions & 0 deletions _sources/exercise1/bblock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "metaschema.yaml",
"name": "Exercise 1",
"highlighted": true,
"abstract": "Set an example",
"status": "under-development",
"dateTimeAddition": "2023-04-05T00:00:00Z",
"itemClass": "schema",
"register": "ogc-building-block-register",
"version": "0.1",
"dateOfLastChange": "2023-04-05",
"link": "https://github.com/opengeospatial/bblock-template",
"sources": [
{
"title": "Sample source document",
"link": "https://example.com/sources/1"
}
],
"maturity": "mature",
"scope": "unstable",
"tags": [
"templates"
]
}
10 changes: 10 additions & 0 deletions _sources/exercise1/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Exercise 1

Goal: take a simple JSON schema and test with an example

### Steps
- un-comment the reference to a local file in [examples.yaml](examples.yaml)
- run build
- run viewer
- navigate to "Exercise 1"
- view validation results at [build-local/...](/register/build-local/tests/bbr/template/exercise1/_report.json)
13 changes: 13 additions & 0 deletions _sources/exercise1/examples.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$schema: https://raw.githubusercontent.com/opengeospatial/bblocks-postprocess/refs/heads/master/ogc/bblocks/schemas/examples.schema.yaml

## List of examples
examples:
- title: Reference a local file for examples
content: |-
[Example from mySchema](../../mySchema/example.json)
In **Markdown** format.
# snippets:
# - language: json
# ref: ../mySchema/example.json
14 changes: 14 additions & 0 deletions _sources/exercise1/schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
$schema: https://json-schema.org/draft/2020-12/schema
description: My example schema
type: object
properties:
a:
type: string
format: uri
b:
type: number
c:
type: number
required:
- a
- b
24 changes: 24 additions & 0 deletions _sources/exercise2/bblock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "metaschema.yaml",
"name": "Exercise 2",
"highlighted": true,
"abstract": "Add a JSON-LD context",
"status": "under-development",
"dateTimeAddition": "2023-04-05T00:00:00Z",
"itemClass": "schema",
"register": "ogc-building-block-register",
"version": "0.1",
"dateOfLastChange": "2023-04-05",
"link": "https://github.com/opengeospatial/bblock-template",
"sources": [
{
"title": "Sample source document",
"link": "https://example.com/sources/1"
}
],
"maturity": "mature",
"scope": "unstable",
"tags": [
"templates"
]
}
8 changes: 8 additions & 0 deletions _sources/exercise2/context.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"@context": {
"mynamespace": "http://example.com/mythings/",
"a": "@type",
"b": "https://example.org/my-bb-model/b",
"c": "https://example.org/my-bb-model/c"
}
}
12 changes: 12 additions & 0 deletions _sources/exercise2/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## Exercise 2

Goal: Semantically annotate a JSON schema

### Steps
- rename `context.example` to `context.jsonld`
- run build
- run viewer
- navigate to "Exercise 2"/Examples
- choose "RDF/Turtle" to see generated RDF
- view "semantic uplift"
- view validation results at [build-local/...](/register/build-local/tests/bbr/template/exercise2/_report.json)
15 changes: 15 additions & 0 deletions _sources/exercise2/examples.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
$schema: https://raw.githubusercontent.com/opengeospatial/bblocks-postprocess/refs/heads/master/ogc/bblocks/schemas/examples.schema.yaml
## Prefixes for examples
#prefixes:
# mynamespace: http://example.com/mythings/
## List of examples
examples:
- title: Reference a local file for examples
content: |-
[Example from mySchema](../../mySchema/example.json)
In **Markdown** format.
snippets:
- language: json
ref: ../mySchema/example.json
14 changes: 14 additions & 0 deletions _sources/exercise2/schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
$schema: https://json-schema.org/draft/2020-12/schema
description: My example schema
type: object
properties:
a:
type: string
format: uri
b:
type: number
c:
type: number
required:
- a
- b
24 changes: 24 additions & 0 deletions _sources/exercise3/bblock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "metaschema.yaml",
"name": "Exercise 3",
"highlighted": true,
"abstract": "Add logical rules",
"status": "under-development",
"dateTimeAddition": "2023-04-05T00:00:00Z",
"itemClass": "model",
"register": "ogc-building-block-register",
"version": "0.1",
"dateOfLastChange": "2023-04-05",
"link": "https://github.com/opengeospatial/bblock-template",
"sources": [
{
"title": "Sample source document",
"link": "https://example.com/sources/1"
}
],
"maturity": "mature",
"scope": "unstable",
"tags": [
"templates"
]
}
8 changes: 8 additions & 0 deletions _sources/exercise3/context.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"@context": {
"mynamespace": "http://example.org/ns1/",
"a": "@type",
"b": "https://example.org/my-bb-model/b",
"c": "https://example.org/my-bb-model/c"
}
}
10 changes: 10 additions & 0 deletions _sources/exercise3/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Exercise 3

Goal: Validate logical rules

### Steps
- rename `rules.example` to `rules.shacl`
- run build
- run viewer
- navigate to "Exercise 3"/Validation
- view validation results at [Validation Report](../validation) or [build-local/...](/register/build-local/tests/bbr/template/exercise3/_report.json)
15 changes: 15 additions & 0 deletions _sources/exercise3/examples.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
$schema: https://raw.githubusercontent.com/opengeospatial/bblocks-postprocess/refs/heads/master/ogc/bblocks/schemas/examples.schema.yaml
## Prefixes for examples
prefixes:
mynamespace: http://example.org/ns1/
## List of examples
examples:
- title: Reference a local file for examples
content: |-
[Example from mySchema](../../mySchema/example.json)
In **Markdown** format.
snippets:
- language: json
ref: ../mySchema/example.json
15 changes: 15 additions & 0 deletions _sources/exercise3/rules.shacl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix mynamespace: <http://example.org/ns1/> .
@prefix ns1: <https://example.org/my-bb-model/> .
@base <https://www.ogc.org/rules/template/> .

<#testValues>
a sh:NodeShape ;
sh:targetClass mynamespace:aThing ;
sh:message "C must be greater than B" ;
sh:property [ sh:path ns1:c ;
sh:lessThan ns1:b ]
.
14 changes: 14 additions & 0 deletions _sources/exercise3/schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
$schema: https://json-schema.org/draft/2020-12/schema
description: My example schema
type: object
properties:
a:
type: string
format: uri
b:
type: number
c:
type: number
required:
- a
- b
24 changes: 24 additions & 0 deletions _sources/exercise4/bblock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "metaschema.yaml",
"name": "Exercise 4",
"highlighted": true,
"abstract": "Profile with rules",
"status": "under-development",
"dateTimeAddition": "2023-04-05T00:00:00Z",
"itemClass": "model",
"register": "ogc-building-block-register",
"version": "0.1",
"dateOfLastChange": "2023-04-05",
"link": "https://github.com/opengeospatial/bblock-template",
"sources": [
{
"title": "Sample source document",
"link": "https://example.com/sources/1"
}
],
"maturity": "mature",
"scope": "unstable",
"tags": [
"templates"
]
}
16 changes: 16 additions & 0 deletions _sources/exercise4/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## Exercise 3

Goal: Profile a building block with additional rules, with tests

Note this illustrates how to use examples to test rules fail when expected. This is a critical capability for complex systems.

### Steps
- uncomment import from schema.yaml
- run build
- run viewer
- navigate to "Exercise 4"/Validation
- view validation results at [Validation Report](validation) or [build-local/...](/register/build-local/tests/bbr/template/exercise3/_report.json)
- move `examples/*-fail` to `tests`
- run build
- run viewer
- view validation results at [Validation Report](validation) or [build-local/...](/register/build-local/tests/bbr/template/exercise3/_report.json)
12 changes: 12 additions & 0 deletions _sources/exercise4/examples.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
$schema: https://raw.githubusercontent.com/opengeospatial/bblocks-postprocess/refs/heads/master/ogc/bblocks/schemas/examples.schema.yaml
## Prefixes for examples
prefixes:
mynamespace: http://example.org/ns1/
## List of examples
examples:
- title: Valid under new rule

snippets:
- language: json
ref: examples/example_b_lt_5.json

6 changes: 6 additions & 0 deletions _sources/exercise4/examples/example_b_lt_5-fail.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"a": "mynamespace:aThing",
"b": 4,
"c": 1
}

6 changes: 6 additions & 0 deletions _sources/exercise4/examples/example_b_lt_5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"a": "mynamespace:aThing",
"b": 6,
"c": 1
}

6 changes: 6 additions & 0 deletions _sources/exercise4/examples/example_b_lt_c-fail.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"a": "mynamespace:aThing",
"b": 6,
"c": 10
}

15 changes: 15 additions & 0 deletions _sources/exercise4/rules.shacl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix mynamespace: <http://example.org/ns1/> .
@prefix ns1: <https://example.org/my-bb-model/> .
@base <https://www.ogc.org/rules/template/> .

<#testValues>
a sh:NodeShape ;
sh:targetClass mynamespace:aThing ;
sh:message "B must not be less than 5" ;
sh:property [ sh:path ns1:b ;
sh:minInclusive 5 ]
.
2 changes: 2 additions & 0 deletions _sources/exercise4/schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$schema: https://json-schema.org/draft/2020-12/schema
# $ref: bblocks://ogc.bbr.template.exercise3
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Custom Feature",
"abstract": "This examples shows a simple customisation for OGC API Feature schemas",
"name": "Exercise 5",
"abstract": "This example shows a simple customisation for OGC API Feature schemas",
"status": "under-development",
"dateTimeAddition": "2023-05-19T00:00:00Z",
"itemClass": "schema",
Expand Down
17 changes: 17 additions & 0 deletions _sources/exercise5/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Using a standard container

This is an **interoperable** approach to packaging a data model in a standardised structure.

i.e. the attributes (properties) are managed independently of the packaging container (Feature)

In this case we use the schema from the previous examples.

This building block **inherits** reusable semantic annotations from a common library, simplifying implementation.

### Steps
- uncomment the reference to the previous exercise schema in schema.yaml
- run build, view etc
- examine "Semantic Uplift" and note that event though no `context.jsonld` is present the building block inherits and combines the two building blocks semantic annotations.



Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
$schema: https://raw.githubusercontent.com/opengeospatial/bblocks-postprocess/refs/heads/master/ogc/bblocks/schemas/examples.schema.yaml
## Prefixes will be used for all RDF Turtle resources so that they can be omitted from the actual snippets
# prefixes:
# dct: http://purl.org/dc/terms/
prefixes:
mynamespace: http://example.com/mythings/

## List of examples
examples:
Expand Down Expand Up @@ -30,7 +31,9 @@ examples:
type: Feature
geometry: null
properties:
my-prop: my-value
a: mynamespace:aThing
b: 23
c: 0.1
## A snippet can also have its own base-uri, overriding that of the example
# base-uri: http://example.com/features-2/

Expand Down
File renamed without changes.
8 changes: 8 additions & 0 deletions _sources/exercise5/schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
$schema: https://raw.githubusercontent.com/opengeospatial/bblocks-postprocess/refs/heads/master/ogc/bblocks/schemas/examples.schema.yaml
description: Example of a simple GeoJSON Feature specialisation
allOf:
- $ref: bblocks://ogc.geo.features.feature
# - properties:
# properties:
# $ref: ../exercise4/schema.yaml

File renamed without changes.
Loading

0 comments on commit 9ad8b74

Please sign in to comment.