From 196812d16fd1dc71dc7376212d4470dd1416bc04 Mon Sep 17 00:00:00 2001 From: Oleg Mirzov Date: Mon, 21 Oct 2024 11:42:47 +0200 Subject: [PATCH] [portal] Add city network filter for ICOSCities --- src/main/js/portal/main/backend.ts | 3 +- src/main/js/portal/main/config.ts | 3 +- src/main/js/portal/main/sparqlQueries.ts | 42 +++++++++++++++--------- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/main/js/portal/main/backend.ts b/src/main/js/portal/main/backend.ts index 6a149ceb..e75af87f 100644 --- a/src/main/js/portal/main/backend.ts +++ b/src/main/js/portal/main/backend.ts @@ -65,7 +65,8 @@ export const fetchDobjOriginsAndCounts = (filters: FilterRequest[]) => { site: b.site?.value, ecosystem: b.ecosystem?.value, location: b.location?.value, - stationclass: b.stationclass?.value + stationclass: b.stationclass?.value, + stationNetwork: b.stationNetwork?.value })); }; diff --git a/src/main/js/portal/main/config.ts b/src/main/js/portal/main/config.ts index 4f9708fe..81fd45b2 100644 --- a/src/main/js/portal/main/config.ts +++ b/src/main/js/portal/main/config.ts @@ -199,6 +199,7 @@ const defaultCategNames = { submitter: 'Data submitter', station: 'Station of origin', stationclass: 'Station class', + stationNetwork: 'Station network', project: 'Project', ecosystem: 'Ecosystem type', location: 'Location' @@ -301,7 +302,7 @@ export const filters: IFilterCategories = { {panelTitle: "Submission date", filterList: ['submission']}, ], ICOSCities: [ - { panelTitle: "Data origin", filterList: ['project', 'theme', 'station', 'stationclass', 'ecosystem', 'countryCode', 'submitter', 'samplingHeight'] }, + { panelTitle: "Data origin", filterList: ['theme', 'station', 'stationNetwork', 'countryCode', 'submitter', 'samplingHeight'] }, { panelTitle: "Data types", filterList: ['type', 'keywordFilter', 'level', 'format'] }, { panelTitle: "Value types", filterList: ['valType', 'variable', 'quantityUnit', 'quantityKind'] }, { panelTitle: "Sampling date", filterList: ['dataTime'] }, diff --git a/src/main/js/portal/main/sparqlQueries.ts b/src/main/js/portal/main/sparqlQueries.ts index 4bb44c17..7ec4d2fb 100644 --- a/src/main/js/portal/main/sparqlQueries.ts +++ b/src/main/js/portal/main/sparqlQueries.ts @@ -73,24 +73,41 @@ where{ return { text }; } -export type DobjOriginsAndCountsQuery = Query<"spec" | "submitter" | "count", "station" | "countryCode" | "ecosystem" | "location" | "site" | "stationclass"> +export type DobjOriginsAndCountsQuery = Query<"spec" | "submitter" | "count", "station" | "countryCode" | "ecosystem" | "location" | "site" | "stationclass" | "stationNetwork"> export function dobjOriginsAndCounts(filters: FilterRequest[]): DobjOriginsAndCountsQuery { - const siteQueries = config.envri === "SITES" - ? `BIND (COALESCE(?site, ) as ?boundSite) - OPTIONAL {?boundSite cpmeta:hasEcosystemType ?ecosystem} - OPTIONAL {?boundSite cpmeta:hasSpatialCoverage ?location}` - : `BIND (COALESCE(?station, ) as ?boundStation) - OPTIONAL {?boundStation cpmeta:hasEcosystemType ?ecosystem} - OPTIONAL {?boundStation cpmeta:countryCode ?countryCode} - OPTIONAL {?boundStation cpmeta:hasStationClass ?stClassOpt}`; + let siteQueries: string + switch(config.envri){ + case "SITES": + siteQueries = `BIND (COALESCE(?site, ) as ?boundSite) + OPTIONAL {?boundSite cpmeta:hasEcosystemType ?ecosystem} + OPTIONAL {?boundSite cpmeta:hasSpatialCoverage ?location}` + break + case "ICOS": + siteQueries = `BIND (COALESCE(?station, ) as ?boundStation) + OPTIONAL {?boundStation cpmeta:hasEcosystemType ?ecosystem} + OPTIONAL {?boundStation cpmeta:countryCode ?countryCode} + OPTIONAL {?boundStation cpmeta:hasStationClass ?stClassOpt} + BIND (IF( + bound(?stClassOpt), + IF(strstarts(?stClassOpt, "Ass"), "Associated", "ICOS"), + IF(bound(?station), "Other", ?stClassOpt) + ) as ?stationclass)` + break + case "ICOSCities": + siteQueries = `BIND (COALESCE(?station, ) as ?boundStation) + OPTIONAL {?boundStation cpmeta:belongsToNetwork ?stationNetwork} + OPTIONAL {?boundStation cpmeta:countryCode ?countryCode}` + break + + } const text = `# dobjOriginsAndCounts prefix cpmeta: <${config.cpmetaOntoUri}> prefix prov: prefix xsd: prefix geo: -select ?spec ?countryCode ?submitter ?count ?station ?ecosystem ?location ?site ?stationclass +select ?spec ?countryCode ?submitter ?count ?station ?ecosystem ?location ?site ?stationclass ?stationNetwork where{ { select ?station ?site ?submitter ?spec (count(?dobj) as ?count) where{ @@ -106,11 +123,6 @@ where{ FILTER(STRSTARTS(str(?spec), "${config.sparqlGraphFilter}")) FILTER NOT EXISTS {?spec cpmeta:hasAssociatedProject/cpmeta:hasHideFromSearchPolicy "true"^^xsd:boolean} ${siteQueries} - BIND (IF( - bound(?stClassOpt), - IF(strstarts(?stClassOpt, "Ass"), "Associated", "ICOS"), - IF(bound(?station), "Other", ?stClassOpt) - ) as ?stationclass) }`; return { text };