Skip to content

Commit

Permalink
Rename used-codes-codelist-uri in configuration
Browse files Browse the repository at this point in the history
Renaming these templates for clarity. Both should resolve to the same URI, but the templates need to differ based upon the source data (rows are either components or observations).
  • Loading branch information
Robsteranium committed May 4, 2020
1 parent 9f2d582 commit fe20479
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
11 changes: 11 additions & 0 deletions doc/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,17 @@ The codelist-pipeline will, by deafult, create codelists with URIs of the form `

For example, if you were to use the codelist-pipeline to create a codelist with the `codelist-slug` of `sitc-sections` you could call the `components-pipeline` with a `codelist` of `http://example.com/def/concept-scheme/sitc-sections`.

### Codes-used codelist URI needs to match

You only need to worry about this if you're customising the used-codes codelist URI.

The cube-pipeline generates an `skos:Collection` enumerating the codes that are used in each dimension. We create the `skos:Collection` itself and then populate it with `skos:member` triples in different parts of the pipeline.

The collection is created in the context of the csvw files that have one row per component. The template for the URI is configured with `used-codes-codelist-uri-from-component` defaulting to `$(base-uri)/data/$(dataset-slug)/codes-used/{component_slug}`.

The collection is populated in the context of the csvw files that have one row per observation. The template for the URI is configured with `used-codes-codelist-uri-from-observation` defaulting to `$(base-uri)/data/$(dataset-slug)/codes-used/{_name}` (note that `_name` refers to the columns name).

If you customise one or other of these templates, you need to ensure that they match.

## Validation

Expand Down
4 changes: 3 additions & 1 deletion examples/customising-uris/uri/cube.edn
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
{:dataset-uri "$(base-uri)/imjv/kubus/$(dataset-slug)#id"
:dsd-uri "$(base-uri)/imjv/dsd/$(dataset-slug)#id"}
:dsd-uri "$(base-uri)/imjv/dsd/$(dataset-slug)#id"
:used-codes-codelist-uri-from-component "$(base-uri)/data/$(dataset-slug)/codes-used/{component_slug}"
:used-codes-codelist-uri-from-observation "$(base-uri)/data/$(dataset-slug)/codes-used/{_name}"}
4 changes: 2 additions & 2 deletions resources/uris/cube-pipeline-uris.edn
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{:codelist-uri "$(base-uri)/data/$(dataset-slug)/codes-used/{component_slug}"
:used-codes-codes-codelist-uri "$(base-uri)/data/$(dataset-slug)/codes-used/{_name}"
{:used-codes-codelist-uri-from-component "$(base-uri)/data/$(dataset-slug)/codes-used/{component_slug}"
:used-codes-codelist-uri-from-observation "$(base-uri)/data/$(dataset-slug)/codes-used/{_name}"
:dataset-uri "$(base-uri)/data/$(dataset-slug)"
:dsd-uri "$(base-uri)/data/$(dataset-slug)/structure"
:component-specification-uri "$(base-uri)/data/$(dataset-slug)/component/{component_slug}"}
12 changes: 6 additions & 6 deletions src/table2qb/pipelines/cube.clj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
(assoc col "valueUrl" value_template)
col)))

(defn used-codes-codes-schema [csv-url cube-config {:keys [used-codes-codes-codelist-uri] :as uri-config}]
(defn used-codes-codes-schema [csv-url cube-config {:keys [used-codes-codelist-uri-from-observation] :as uri-config}]
(let [components (cube-config/ordered-columns cube-config)
columns (mapv (fn [comp]
(-> comp
Expand All @@ -37,7 +37,7 @@
components)]
{"url" (str csv-url)
"tableSchema" {"columns" columns
"aboutUrl" used-codes-codes-codelist-uri}}))
"aboutUrl" used-codes-codelist-uri-from-observation}}))

(defn dataset-link-column [dataset-uri]
{"name" "DataSet"
Expand Down Expand Up @@ -77,7 +77,7 @@
(let [base-defs (util/read-edn (io/resource "uris/cube-pipeline-uris.edn"))]
(resolve-uris base-defs base-uri dataset-slug)))

(defn used-codes-codelists-schema [csv-url {:keys [codelist-uri] :as uri-config}]
(defn used-codes-codelists-schema [csv-url {:keys [used-codes-codelist-uri-from-component] :as uri-config}]
{"url" (str csv-url)
"tableSchema"
{"columns"
Expand All @@ -97,7 +97,7 @@
"virtual" true,
"propertyUrl" "rdf:type",
"valueUrl" "skos:Collection"}],
"aboutUrl" codelist-uri}})
"aboutUrl" used-codes-codelist-uri-from-component}})

(defn derive-dsd-label
"Derives the DataSet Definition label from the dataset name"
Expand Down Expand Up @@ -129,7 +129,7 @@
"suppressOutput" true}],
"aboutUrl" dsd-uri}}))

(defn component-specification-schema [csv-url dataset-name {:keys [component-specification-uri codelist-uri]}]
(defn component-specification-schema [csv-url dataset-name {:keys [component-specification-uri used-codes-codelist-uri-from-component]}]
{"url" (str csv-url)
"dc:title" (util/blank->nil dataset-name)
"tableSchema"
Expand All @@ -154,7 +154,7 @@
{"name" "codes_used",
"virtual" true,
"propertyUrl" "http://publishmydata.com/def/qb/codesUsed",
"valueUrl" codelist-uri}],
"valueUrl" used-codes-codelist-uri-from-component}],
"aboutUrl" component-specification-uri}})

(defn dataset-schema [csv-url dataset-name {:keys [dataset-uri dsd-uri]}]
Expand Down

0 comments on commit fe20479

Please sign in to comment.