Skip to content

Commit

Permalink
[portal] Add city network filter for ICOSCities
Browse files Browse the repository at this point in the history
  • Loading branch information
mirzov committed Oct 21, 2024
1 parent 724cf28 commit 196812d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 17 deletions.
3 changes: 2 additions & 1 deletion src/main/js/portal/main/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}));
};

Expand Down
3 changes: 2 additions & 1 deletion src/main/js/portal/main/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'] },
Expand Down
42 changes: 27 additions & 15 deletions src/main/js/portal/main/sparqlQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, <http://dummy>) as ?boundSite)
OPTIONAL {?boundSite cpmeta:hasEcosystemType ?ecosystem}
OPTIONAL {?boundSite cpmeta:hasSpatialCoverage ?location}`
: `BIND (COALESCE(?station, <http://dummy>) 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, <http://dummy>) as ?boundSite)
OPTIONAL {?boundSite cpmeta:hasEcosystemType ?ecosystem}
OPTIONAL {?boundSite cpmeta:hasSpatialCoverage ?location}`
break
case "ICOS":
siteQueries = `BIND (COALESCE(?station, <http://dummy>) 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, <http://dummy>) as ?boundStation)
OPTIONAL {?boundStation cpmeta:belongsToNetwork ?stationNetwork}
OPTIONAL {?boundStation cpmeta:countryCode ?countryCode}`
break

}

const text = `# dobjOriginsAndCounts
prefix cpmeta: <${config.cpmetaOntoUri}>
prefix prov: <http://www.w3.org/ns/prov#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix geo: <http://www.opengis.net/ont/geosparql#>
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{
Expand All @@ -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 };
Expand Down

0 comments on commit 196812d

Please sign in to comment.