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
101 changes: 101 additions & 0 deletions .github/workflows/demo-queries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Demo queries

# Validates the demo queries in demo-queries/, runs them against their public
# endpoints, and (on main) uploads them to the matgui-demo Jena dataset that
# backs the "MatGUI demo queries" workspace on https://matgui.matdata.eu.
#
# Required repository secrets for publishing:
# JENA_USERNAME / JENA_PASSWORD - credentials allowed to write to the dataset
# Optional repository variable:
# JENA_DATASET_URL - defaults to https://jena.matdata.eu/matgui-demo

on:
push:
branches: ["**"]
paths:
- "demo-queries/**"
- "scripts/demo_queries.py"
- ".github/workflows/demo-queries.yml"
pull_request:
paths:
- "demo-queries/**"
- "scripts/demo_queries.py"
- ".github/workflows/demo-queries.yml"
workflow_dispatch:
inputs:
smoke_test:
description: "Run every query against its endpoint"
type: boolean
default: true

permissions:
contents: read

concurrency:
group: demo-queries-${{ github.ref }}
cancel-in-progress: true

jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # git history is used for the dcterms:created timestamps

- uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install dependencies
run: pip install "rdflib>=7,<8"

- name: Validate query syntax and metadata
run: python scripts/demo_queries.py validate

- name: Build workspace RDF
run: python scripts/demo_queries.py build --out build/matgui-demo.ttl

- uses: actions/upload-artifact@v4
with:
name: matgui-demo-workspace
path: build/matgui-demo.ttl

smoke-test:
# Public endpoints are sometimes slow or down, so failures are reported in the
# job summary but do not block publishing.
if: github.event_name != 'schedule' && (github.event_name != 'workflow_dispatch' || inputs.smoke_test)
needs: validate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Run every query against its endpoint
run: python scripts/demo_queries.py smoke-test --timeout 90

publish:
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
needs: validate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.12"

- uses: actions/download-artifact@v4
with:
name: matgui-demo-workspace
path: build

- name: Upload to Jena
env:
JENA_DATASET_URL: ${{ vars.JENA_DATASET_URL || 'https://jena.matdata.eu/matgui-demo' }}
JENA_USERNAME: ${{ secrets.JENA_USERNAME }}
JENA_PASSWORD: ${{ secrets.JENA_PASSWORD }}
run: python scripts/demo_queries.py publish --file build/matgui-demo.ttl
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,31 @@ Modify `src/main.css` to customize the appearance of the interface.

The MatGUI instance can be configured in `src/main.js`. See the [MatGUI documentation](https://matgui-doc.matdata.eu) for available options.

## Demo Queries

The site ships with a read-only **"MatGUI demo queries"** workspace: over 100 ready-to-run queries for ERA RINF, the EU Publications Office (authority tables, EuroVoc, Cellar), data.europa.eu, GeoSPARQL on Apache Jena, Wikidata, DBpedia, OpenStreetMap (QLever), UniProt, Getty and AGROVOC, plus CONSTRUCT queries that show off the Graph plugin (icons, images, compact mode, node expansion) and federated queries that combine several endpoints with `SERVICE`. Open them with the **Demo queries** link in the footer or from the query browser.

The queries are plain `.rq` files in [`demo-queries/`](demo-queries). Each sub-directory is a workspace folder; folder labels, default endpoints and endpoint aliases are defined in [`demo-queries/workspace.json`](demo-queries/workspace.json). Every file starts with a small header:

```sparql
#+ name: Operational points per country
#+ description: Counts operational points per member state.
#+ endpoint: era # optional when the folder has a default; alias or full URL
PREFIX era: <http://data.europa.eu/949/>
SELECT ...
```

[`scripts/demo_queries.py`](scripts/demo_queries.py) converts the files into the RDF model of MatGUI's SPARQL workspaces (`yasgui:Workspace`, `yasgui:WorkspaceFolder`, `yasgui:ManagedQuery`, `yasgui:ManagedQueryVersion`):

```bash
pip install rdflib
python scripts/demo_queries.py validate # syntax + metadata checks
python scripts/demo_queries.py build # writes build/matgui-demo.ttl
python scripts/demo_queries.py smoke-test # runs every query against its endpoint
```

The [Demo queries workflow](.github/workflows/demo-queries.yml) validates and smoke-tests the queries on every change, and on `main` (plus nightly) replaces the default graph of the `matgui-demo` dataset on [jena.matdata.eu](https://jena.matdata.eu) using the Graph Store Protocol. It needs the `JENA_USERNAME` and `JENA_PASSWORD` repository secrets; the dataset URL can be overridden with the `JENA_DATASET_URL` repository variable.

## Credits

- Original YASGUI by [Zazuko](https://github.com/zazuko/yasgui) and [TriplyDB](https://github.com/triplydb/Yasgui)
Expand Down
13 changes: 13 additions & 0 deletions demo-queries/agriculture/agrovoc-narrower-concepts.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#+ name: Narrower concepts of 'cereals'
#+ description: Walks down the SKOS hierarchy from 'cereals' (c_1474) and returns the English labels.
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX skosxl: <http://www.w3.org/2008/05/skos-xl#>

SELECT ?concept ?label ?parentLabel WHERE {
?concept skos:broader+ <http://aims.fao.org/aos/agrovoc/c_1474> ;
skos:broader ?parent ;
skosxl:prefLabel/skosxl:literalForm ?label .
?parent skosxl:prefLabel/skosxl:literalForm ?parentLabel .
FILTER(LANG(?label) = "en" && LANG(?parentLabel) = "en")
}
ORDER BY ?parentLabel ?label
10 changes: 10 additions & 0 deletions demo-queries/agriculture/agrovoc-translations.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#+ name: Translations of an AGROVOC concept
#+ description: Preferred labels of the concept 'maize' (c_12332) in all available languages.
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX skosxl: <http://www.w3.org/2008/05/skos-xl#>

SELECT ?language ?label WHERE {
<http://aims.fao.org/aos/agrovoc/c_12332> skosxl:prefLabel/skosxl:literalForm ?label .
BIND(LANG(?label) AS ?language)
}
ORDER BY ?language
14 changes: 14 additions & 0 deletions demo-queries/agriculture/concepts-related-to-wheat.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#+ name: Concepts related to 'wheat'
#+ description: Looks up the AGROVOC concept with the English label 'wheat' (SKOS-XL) and lists its narrower and related concepts.
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX skosxl: <http://www.w3.org/2008/05/skos-xl#>

SELECT ?relation ?concept ?label WHERE {
?wheatLabel skosxl:literalForm "wheat"@en .
?wheat skosxl:prefLabel ?wheatLabel .
VALUES (?property ?relation) { (skos:narrower "narrower") (skos:related "related") (skos:broader "broader") }
?wheat ?property ?concept .
?concept skosxl:prefLabel/skosxl:literalForm ?label .
FILTER(LANG(?label) = "en")
}
ORDER BY ?relation ?label
20 changes: 20 additions & 0 deletions demo-queries/cultural-heritage/aat-hierarchy-graph.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#+ name: AAT hierarchy below 'bridges' (graph)
#+ description: CONSTRUCTs the narrower hierarchy of the AAT concept 'bridges (built works)' (aat:300007836). Use the Graph plugin.
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX gvp: <http://vocab.getty.edu/ontology#>
PREFIX xl: <http://www.w3.org/2008/05/skos-xl#>
PREFIX aat: <http://vocab.getty.edu/aat/>
PREFIX tgn: <http://vocab.getty.edu/tgn/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

CONSTRUCT {
?concept skos:broader ?parent ;
rdfs:label ?term .
aat:300007836 rdfs:label ?topTerm .
}
WHERE {
aat:300007836 gvp:prefLabelGVP/xl:literalForm ?topTerm .
?concept gvp:broaderPreferred+ aat:300007836 ;
gvp:broaderPreferred ?parent ;
gvp:prefLabelGVP/xl:literalForm ?term .
}
16 changes: 16 additions & 0 deletions demo-queries/cultural-heritage/aat-search.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#+ name: Search the Art & Architecture Thesaurus
#+ description: AAT concepts whose preferred English term contains 'bridge', with their parent.
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX gvp: <http://vocab.getty.edu/ontology#>
PREFIX xl: <http://www.w3.org/2008/05/skos-xl#>
PREFIX aat: <http://vocab.getty.edu/aat/>
PREFIX tgn: <http://vocab.getty.edu/tgn/>

SELECT ?concept ?term ?parentTerm WHERE {
?concept skos:inScheme aat: ;
gvp:prefLabelGVP/xl:literalForm ?term .
FILTER(CONTAINS(LCASE(STR(?term)), "bridge"))
OPTIONAL { ?concept gvp:broaderPreferred/gvp:prefLabelGVP/xl:literalForm ?parentTerm }
}
ORDER BY ?term
LIMIT 100
19 changes: 19 additions & 0 deletions demo-queries/cultural-heritage/tgn-places-in-belgium.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#+ name: TGN: inhabited places in Belgium
#+ description: Places in the Getty Thesaurus of Geographic Names that lie in Belgium (tgn:1000063), with coordinates.
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX gvp: <http://vocab.getty.edu/ontology#>
PREFIX xl: <http://www.w3.org/2008/05/skos-xl#>
PREFIX aat: <http://vocab.getty.edu/aat/>
PREFIX tgn: <http://vocab.getty.edu/tgn/>
PREFIX wgs: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

SELECT ?place ?name ?lat ?long WHERE {
?place gvp:broaderPartitive+ tgn:1000063 ;
gvp:placeTypePreferred aat:300008347 ;
gvp:prefLabelGVP/xl:literalForm ?name ;
foaf:focus ?focus .
?focus wgs:lat ?lat ;
wgs:long ?long .
}
LIMIT 200
12 changes: 12 additions & 0 deletions demo-queries/data-europa-eu/authority-tables/data-themes.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#+ name: Data themes
#+ description: The DCAT-AP data themes (authority table data-theme) in English, French and German. data.europa.eu keeps each vocabulary in a named graph with the same IRI as the concept scheme.
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>

SELECT DISTINCT ?theme ?en ?fr ?de WHERE {
GRAPH <http://publications.europa.eu/resource/authority/data-theme> {
?theme a skos:Concept .
OPTIONAL { ?theme skos:prefLabel ?en . FILTER(LANG(?en) = "en") }
OPTIONAL { ?theme skos:prefLabel ?fr . FILTER(LANG(?fr) = "fr") }
OPTIONAL { ?theme skos:prefLabel ?de . FILTER(LANG(?de) = "de") }
}
}
11 changes: 11 additions & 0 deletions demo-queries/data-europa-eu/authority-tables/frequencies.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#+ name: Update frequencies
#+ description: The frequency authority table used for dct:accrualPeriodicity.
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>

SELECT DISTINCT ?frequency ?label WHERE {
GRAPH <http://publications.europa.eu/resource/authority/frequency> {
?frequency a skos:Concept ;
skos:prefLabel ?label .
FILTER(LANG(?label) = "en")
}
}
12 changes: 12 additions & 0 deletions demo-queries/data-europa-eu/authority-tables/hvd-categories.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#+ name: High-value dataset categories
#+ description: The high-value dataset categories vocabulary with its hierarchy (top categories and sub-categories).
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>

SELECT DISTINCT ?category ?label ?parent WHERE {
GRAPH <http://data.europa.eu/bna/asd487ae75> {
?category a skos:Concept ;
skos:prefLabel ?label .
FILTER(LANG(?label) = "en")
OPTIONAL { ?category skos:broader ?parent }
}
}
11 changes: 11 additions & 0 deletions demo-queries/data-europa-eu/authority-tables/licences.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#+ name: Licences
#+ description: The licence authority table used to describe the licence of datasets and distributions.
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>

SELECT DISTINCT ?licence ?label WHERE {
GRAPH <http://publications.europa.eu/resource/authority/licence> {
?licence a skos:Concept ;
skos:prefLabel ?label .
FILTER(LANG(?label) = "en")
}
}
11 changes: 11 additions & 0 deletions demo-queries/data-europa-eu/datasets/catalogues.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#+ name: Data catalogues
#+ description: Catalogues harvested by data.europa.eu with their title and country.
PREFIX dcat: <http://www.w3.org/ns/dcat#>
PREFIX dct: <http://purl.org/dc/terms/>

SELECT ?catalogue ?title ?spatial WHERE {
?catalogue a dcat:Catalog ;
dct:title ?title .
OPTIONAL { ?catalogue dct:spatial ?spatial }
}
LIMIT 300
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#+ name: A dataset and its distributions (graph)
#+ description: CONSTRUCTs one railway dataset with its publisher and distributions. Open the result in the Graph plugin.
PREFIX dcat: <http://www.w3.org/ns/dcat#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

CONSTRUCT {
?dataset a dcat:Dataset ;
dct:title ?title ;
dct:publisher ?publisher ;
dcat:distribution ?distribution ;
dcat:theme ?theme .
?publisher foaf:name ?publisherName .
?distribution dct:format ?format ;
dcat:accessURL ?accessURL .
}
WHERE {
{
SELECT ?dataset WHERE {
?dataset a dcat:Dataset ;
dcat:keyword "railway"@en ;
dcat:distribution ?d .
}
LIMIT 1
}
?dataset dct:title ?title .
OPTIONAL { ?dataset dcat:theme ?theme }
OPTIONAL { ?dataset dct:publisher ?publisher . OPTIONAL { ?publisher foaf:name ?publisherName } }
OPTIONAL {
?dataset dcat:distribution ?distribution .
OPTIONAL { ?distribution dct:format ?format }
OPTIONAL { ?distribution dcat:accessURL ?accessURL }
}
}
15 changes: 15 additions & 0 deletions demo-queries/data-europa-eu/datasets/datasets-by-keyword.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#+ name: Datasets by keyword
#+ description: Datasets tagged with a keyword (exact match, several spellings). Replace the VALUES to search for something else.
PREFIX dcat: <http://www.w3.org/ns/dcat#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

SELECT DISTINCT ?dataset ?title ?publisherName WHERE {
VALUES ?keyword { "railway"@en "railway" "rail transport"@en "railways"@en }
?dataset a dcat:Dataset ;
dcat:keyword ?keyword ;
dct:title ?title .
FILTER(LANGMATCHES(LANG(?title), "en") || LANG(?title) = "")
OPTIONAL { ?dataset dct:publisher/foaf:name ?publisherName }
}
LIMIT 200
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#+ name: Distribution formats of transport data
#+ description: Which file formats are used by the distributions of transport datasets?
PREFIX dcat: <http://www.w3.org/ns/dcat#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX theme: <http://publications.europa.eu/resource/authority/data-theme/>

SELECT ?format (COUNT(DISTINCT ?distribution) AS ?distributions) WHERE {
?dataset dcat:theme theme:TRAN ;
dcat:distribution ?distribution .
?distribution dct:format ?format .
}
GROUP BY ?format
ORDER BY DESC(?distributions)
LIMIT 25
12 changes: 12 additions & 0 deletions demo-queries/data-europa-eu/datasets/high-value-datasets.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#+ name: High-value datasets
#+ description: Datasets declared as high-value datasets (Implementing Regulation (EU) 2023/138), with their HVD category.
PREFIX dcat: <http://www.w3.org/ns/dcat#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX dcatap: <http://data.europa.eu/r5r/>

SELECT ?dataset ?title ?category WHERE {
?dataset dcatap:hvdCategory ?category ;
dct:title ?title .
FILTER(LANGMATCHES(LANG(?title), "en"))
}
LIMIT 200
15 changes: 15 additions & 0 deletions demo-queries/data-europa-eu/datasets/publishers-of-railway-data.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#+ name: Publishers of railway data
#+ description: Organisations publishing datasets tagged 'railway', ranked by number of datasets.
PREFIX dcat: <http://www.w3.org/ns/dcat#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

SELECT ?publisher (SAMPLE(?name) AS ?publisherName) (COUNT(DISTINCT ?dataset) AS ?datasets) WHERE {
VALUES ?keyword { "railway"@en "railway" "railways"@en }
?dataset dcat:keyword ?keyword ;
dct:publisher ?publisher .
OPTIONAL { ?publisher foaf:name ?name }
}
GROUP BY ?publisher
ORDER BY DESC(?datasets)
LIMIT 25
Loading
Loading