From 20e5ec2d4e8b59053e4ba98ef0ee8a69b1fea84c Mon Sep 17 00:00:00 2001 From: Jeremy Stucki Date: Mon, 19 Jul 2021 17:34:24 +0200 Subject: [PATCH] feat: Add queries for https://ld.admin.ch/vocabulary/CreativeWorkStatus See https://github.com/zazuko/rdf-cube-schema-viz/issues/1#issuecomment-881647791 --- app/rdf/namespace.ts | 1 + app/rdf/parse.ts | 4 +++- app/rdf/queries.ts | 13 ++++++++++--- app/typings/rdf.d.ts | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/rdf/namespace.ts b/app/rdf/namespace.ts index e0e928524..b2e7b7601 100644 --- a/app/rdf/namespace.ts +++ b/app/rdf/namespace.ts @@ -18,6 +18,7 @@ export const classifications = namespace( ); export const schemaAdmin = namespace("https://schema.ld.admin.ch/"); export const adminTerm = namespace("https://ld.admin.ch/definedTerm/"); +export const adminVocabulary = namespace("https://ld.admin.ch/vocabulary/"); export const cube = namespace("https://cube.link/"); export const cubeView = namespace("https://cube.link/view/"); export const cubeMeta = namespace("https://cube.link/meta/"); diff --git a/app/rdf/parse.ts b/app/rdf/parse.ts index a2606afed..be1325387 100644 --- a/app/rdf/parse.ts +++ b/app/rdf/parse.ts @@ -44,7 +44,9 @@ export const parseCube = ({ version: cube.out(ns.schema.version)?.value, publicationStatus: ns.adminTerm("CreativeWorkStatus/Published").value === - cube.out(ns.schema.creativeWorkStatus)?.value + cube.out(ns.schema.creativeWorkStatus)?.value || + ns.adminVocabulary("CreativeWorkStatus/Published").value === + cube.out(ns.schema.creativeWorkStatus)?.value ? DataCubePublicationStatus.Published : DataCubePublicationStatus.Draft, theme: cube.out(ns.dcat.theme)?.value, diff --git a/app/rdf/queries.ts b/app/rdf/queries.ts index f9d751610..94459b601 100644 --- a/app/rdf/queries.ts +++ b/app/rdf/queries.ts @@ -64,7 +64,10 @@ export const getCubes = async ({ ].concat( includeDrafts ? [] - : Cube.filter.status(ns.adminTerm("CreativeWorkStatus/Published")) + : Cube.filter.status([ + ns.adminTerm("CreativeWorkStatus/Published"), + ns.adminVocabulary("CreativeWorkStatus/Published"), + ]) ), }); @@ -91,7 +94,9 @@ export const getCube = async ({ // const versionHistory = cube.in(ns.schema.hasPart)?.term; // const isPublished = // cube.out(ns.schema.creativeWorkStatus)?.value === - // ns.adminTerm("CreativeWorkStatus/Published").value; + // ns.adminTerm("CreativeWorkStatus/Published").value || + // cube.out(ns.schema.creativeWorkStatus)?.value === + // ns.adminVocabulary("CreativeWorkStatus/Published").value; // const version = cube.out(ns.schema.version); // // console.log(`Cube <${iri}> version: ${version?.value}`); @@ -146,7 +151,9 @@ export const getCube = async ({ // newerCubes.find( // (cube) => // cube.out(ns.schema.creativeWorkStatus)?.value === - // ns.adminTerm("CreativeWorkStatus/Published").value + // ns.adminTerm("CreativeWorkStatus/Published").value || + // cube.out(ns.schema.creativeWorkStatus)?.value === + // ns.adminVocabulary("CreativeWorkStatus/Published").value // ) ?? newerCubes[0]; // // console.log("Picked latest cube", latestCube.term?.value); diff --git a/app/typings/rdf.d.ts b/app/typings/rdf.d.ts index e5208835d..388f6a33d 100644 --- a/app/typings/rdf.d.ts +++ b/app/typings/rdf.d.ts @@ -20,7 +20,7 @@ declare module "rdf-cube-view-query" { static filter: { isPartOf: (container: $FixMe) => $FixMe; noValidThrough: () => $FixMe; - status: (values: Term) => $FixMe; + status: (values: Term | Term[]) => $FixMe; }; dimensions: CubeDimension[]; source: CubeSource;