Skip to content

Commit

Permalink
Merge pull request #1525 from zazuko/shared-dimension-uri
Browse files Browse the repository at this point in the history
Correct links to shared dimensions
  • Loading branch information
tpluscode authored Jun 19, 2024
2 parents 8d5e92b + 2181698 commit ab4c883
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/friendly-dryers-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cube-creator/shared-dimensions-api": patch
---

Correct links to shared dimension terms (fixes #1498)
3 changes: 3 additions & 0 deletions apis/shared-dimensions/lib/handlers/shared-dimension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { serializers } from '@rdfjs-elements/formats-pretty'
import error from 'http-errors'
import { md, meta } from '@cube-creator/core/namespace'
import * as ns from '@tpluscode/rdf-ns-builders'
import { oa } from '@tpluscode/rdf-ns-builders'
import { createTerm, getExportedDimension } from '../domain/shared-dimension'
import { store } from '../store'
import { shaclValidate } from '../middleware/shacl'
Expand All @@ -19,6 +20,8 @@ export const post = protectedResource(shaclValidate, asyncMiddleware(async (req,
store: store(),
})

term.addOut(oa.canonical, term)

res.setHeader('Location', term.value)
res.status(201)
return res.dataset(term.dataset)
Expand Down
2 changes: 1 addition & 1 deletion apis/shared-dimensions/lib/middleware/canonicalRewrite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface ShouldRewrite {
const defaultShouldRewrite: ShouldRewrite = ({ predicate }) => {
if (predicate.equals(oa.canonical)) {
return {
subject: false,
object: false,
}
}

Expand Down
4 changes: 4 additions & 0 deletions e2e-tests/shared-dimensions/term-set.hydra
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ PREFIX schema: <http://schema.org/>
PREFIX qudt: <http://qudt.org/schema/qudt/>
PREFIX meta: <https://cube.link/meta/>
PREFIX sh: <http://www.w3.org/ns/shacl#>
PREFIX oa: <http://www.w3.org/ns/oa#>

ENTRYPOINT "dimension/technologies"

Expand Down Expand Up @@ -39,6 +40,9 @@ With Class meta:SharedDimension {
Expect Property schema:inDefinedTermSet
Expect Property schema:validFrom
Expect Property schema:validThrough
Expect Property oa:canonical {
Expect Id <https://ld.admin.ch/cube/dimension/technologies/node-js>
}
}

Invoke {
Expand Down
4 changes: 4 additions & 0 deletions e2e-tests/shared-dimensions/term.hydra
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ PREFIX schema: <http://schema.org/>
PREFIX qudt: <http://qudt.org/schema/qudt/>
PREFIX meta: <https://cube.link/meta/>
PREFIX sh: <http://www.w3.org/ns/shacl#>
PREFIX oa: <http://www.w3.org/ns/oa#>

ENTRYPOINT "dimension/technologies/rdf"

Expand Down Expand Up @@ -37,6 +38,9 @@ With Class schema:DefinedTerm {

Expect Type schema:DefinedTerm
Expect Property schema:name "Resource Description Framework"
Expect Property oa:canonical {
Expect Id <https://ld.admin.ch/cube/dimension/technologies/rdf>
}
}
}
}

0 comments on commit ab4c883

Please sign in to comment.