Skip to content

Commit

Permalink
feat: qudt:hasUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
tpluscode committed Oct 31, 2023
1 parent 9dc96c7 commit 259b48b
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .changeset/tender-masks-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@cube-creator/cli": patch
---

Add `qudt:hasUnit` in addition to `qudt:unit`. The former will be removed in a future version (see #1473)
Closes #1440
Re https://gitlab.ldbar.ch/bafu/visualize/-/issues/562
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ To be able to run transform/publish pipelines locally, an OIDC secret must be ad
AUTH_RUNNER_CLIENT_SECRET=foo-bar
```

It is obtained from [keycloak](https://keycloak.zazukoians.org/admin/master/console/#/realms/zazuko-dev/clients/64f92868-71e3-48e1-9d8b-7bfaf5fac2bd/credentials)
It is obtained from [keycloak](https://keycloak.zazukoians.org/admin/master/console/#/zazuko-dev/clients/64f92868-71e3-48e1-9d8b-7bfaf5fac2bd/credentials)

### Starting

Expand Down
11 changes: 11 additions & 0 deletions cli/lib/publish/patch-stream.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Dataset } from 'rdf-js'
import { qudt } from '@tpluscode/rdf-ns-builders'
import $rdf from 'rdf-ext'

export function addQudtHasUnit(dataset: Dataset) {
dataset.match(null, qudt.unit).forEach(({ subject, object }) => {
dataset.add($rdf.quad(subject, qudt.hasUnit, object))
})

return dataset
}
18 changes: 18 additions & 0 deletions cli/pipelines/publish.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
[
:stepList (
<#loadCubeMetadata>
<#addQudtUnit>
<#shaclValidate>
<#flatten>
) ;
Expand Down Expand Up @@ -193,6 +194,23 @@ _:get
code:value "graph-store-password"^^:VariableName
] .

<#addQudtUnit>
a :Step ;
code:implementedBy
[
a code:EcmaScriptModule ;
code:link <node:barnard59-base/map.js#default> ;
] ;
code:arguments
(
[
code:link <file:../lib/publish/patch-stream#addQudtHasUnit> ;
a code:EcmaScript ;
]
)
.


<#uniqueBnodes>
a :Step ;
code:implementedBy [ a code:EcmaScriptModule ; code:link <node:barnard59-base/map.js#default> ] ;
Expand Down
13 changes: 13 additions & 0 deletions cli/test/lib/commands/publish.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,17 @@ describe('@cube-creator/cli/lib/commands/publish', function () {
})
}

function duplicatesQudtUnit() {
expect(cubePointer.namedNode(targetCube('dimension/year'))).to.matchShape({
property: {
path: qudt.hasUnit,
minCount: 1,
maxCount: 1,
equals: qudt.unit,
},
})
}

describe('publishing published', () => {
before(resetData)
before(function makeCubePublished() {
Expand All @@ -153,6 +164,7 @@ describe('@cube-creator/cli/lib/commands/publish', function () {

it('removes hydra terms', removesHydraTerms)
it('removes original values of mapped dimensions', removesMappingsOriginalValues)
it('adds qudt:hasUnit', duplicatesQudtUnit)

it('does not publish a cube with trailing slash', async () => {
const trailingSlashCubeExists = await ASK`${ns.baseCube('3/')} ?p ?o`
Expand Down Expand Up @@ -205,6 +217,7 @@ describe('@cube-creator/cli/lib/commands/publish', function () {
before(runJob)

it('removes hydra terms', removesHydraTerms)
it('adds qudt:hasUnit', duplicatesQudtUnit)
it('removes original values of mapped dimensions', removesMappingsOriginalValues)
it('adds software versions', addsSoftwareVersions)

Expand Down
1 change: 1 addition & 0 deletions fuseki/sample-ubd.trig
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ graph <cube-project/ubd/dimensions-metadata> {
<cube-project/ubd/dimensions-metadata/dimension-value>
schema:about <https://environment.ld.admin.ch/foen/ubd/28/dimension/value> ;
schema:name "Wert"@de ;
qudt:unit <http://qudt.org/vocab/unit/MicroGM-PER-M3> ;
.

<cube-project/ubd/dimensions-metadata/station>
Expand Down

0 comments on commit 259b48b

Please sign in to comment.