diff --git a/app/graphql/shared-types.ts b/app/graphql/shared-types.ts index c52308d430..017f6fdc46 100644 --- a/app/graphql/shared-types.ts +++ b/app/graphql/shared-types.ts @@ -65,6 +65,7 @@ export type ResolvedDimension = { timeUnit?: TimeUnit; timeFormat?: string; scaleType?: "Nominal" | "Ordinal" | "Ratio" | "Interval"; + hasHierarchy?: boolean; }; }; diff --git a/app/rdf/parse.ts b/app/rdf/parse.ts index 1b2fabdeca..6b17d152d1 100644 --- a/app/rdf/parse.ts +++ b/app/rdf/parse.ts @@ -20,6 +20,7 @@ import { ResolvedDataCube, ResolvedDimension } from "../graphql/shared-types"; import { locales } from "../locales/locales"; import * as ns from "./namespace"; +import { hasHierarchy } from "./queries"; export const getQueryLocales = (locale: string): string[] => [ locale, @@ -247,6 +248,8 @@ export const parseCubeDimension = ({ : undefined; const isDecimal = dataType?.equals(ns.xsd.decimal) ?? false; + const dimensionHasHierarchy = hasHierarchy(dim); + return { cube, dimension: dim, @@ -263,6 +266,7 @@ export const parseCubeDimension = ({ isKeyDimension, isMeasureDimension, hasUndefinedValues, + hasHierarchy: dimensionHasHierarchy, unit: dimensionUnitLabel, dataType: dataType?.value, resolution, diff --git a/app/rdf/queries.ts b/app/rdf/queries.ts index 6cf167ec8d..d63a81e937 100644 --- a/app/rdf/queries.ts +++ b/app/rdf/queries.ts @@ -48,6 +48,7 @@ const DIMENSION_VALUE_UNDEFINED = ns.cube.Undefined.value; /** Adds a suffix to an iri to mark its label */ const labelDimensionIri = (iri: string) => `${iri}/__label__`; +const iriDimensionIri = (iri: string) => `${iri}/__iri__`; const getLatestCube = async (cube: Cube): Promise => { const source = cube.source; @@ -765,6 +766,9 @@ function parseObservation( : obs[d.data.iri]?.value; const rawValue = parseObservationValue({ value: obs[d.data.iri] }); + if (d.data.hasHierarchy) { + res[iriDimensionIri(d.data.iri)] = obs[d.data.iri]?.value; + } res[d.data.iri] = raw ? rawValue : label ?? value ?? null; } return res;