Skip to content
Snippets Groups Projects
Commit b9dbcf41 authored by esikkala's avatar esikkala
Browse files

Simplify facet query, remove tgn fixes from sparql api

parent 052aa554
No related branches found
No related tags found
No related merge requests found
...@@ -176,7 +176,6 @@ module.exports = { ...@@ -176,7 +176,6 @@ module.exports = {
WHERE { WHERE {
# https://github.com/uber/deck.gl/blob/master/docs/layers/arc-layer.md # https://github.com/uber/deck.gl/blob/master/docs/layers/arc-layer.md
?manuscript__id ^frbroo:R18_created/crm:P7_took_place_at ?from__id . ?manuscript__id ^frbroo:R18_created/crm:P7_took_place_at ?from__id .
?manuscript__id mmm-schema:data_provider_url ?manuscript__url . ?manuscript__id mmm-schema:data_provider_url ?manuscript__url .
?from__id skos:prefLabel ?from__name . ?from__id skos:prefLabel ?from__name .
?from__id wgs84:lat ?from__lat ; ?from__id wgs84:lat ?from__lat ;
...@@ -228,52 +227,38 @@ module.exports = { ...@@ -228,52 +227,38 @@ module.exports = {
} }
`, `,
'facetQuery': ` 'facetQuery': `
PREFIX skos: <http://www.w3.org/2004/02/skos/core#> PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/> PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/>
PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX text: <http://jena.apache.org/text#> PREFIX text: <http://jena.apache.org/text#>
PREFIX dct: <http://purl.org/dc/terms/> PREFIX dct: <http://purl.org/dc/terms/>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX sch: <http://schema.org/> PREFIX sch: <http://schema.org/>
PREFIX geosparql: <http://www.opengis.net/ont/geosparql#> PREFIX geosparql: <http://www.opengis.net/ont/geosparql#>
PREFIX frbroo: <http://erlangen-crm.org/efrbroo/> PREFIX frbroo: <http://erlangen-crm.org/efrbroo/>
PREFIX mmm-schema: <http://ldf.fi/mmm/schema/> PREFIX mmm-schema: <http://ldf.fi/mmm/schema/>
SELECT DISTINCT ?cnt ?facet_text ?value ?parent SELECT DISTINCT ?cnt ?facet_text ?value ?parent
WHERE { WHERE {
SELECT DISTINCT ?cnt ?value ?facet_text ?parent { SELECT DISTINCT ?cnt ?value ?facet_text ?parent {
{ SELECT DISTINCT (count(DISTINCT ?id) as ?cnt) ?value ?parent { SELECT DISTINCT (count(DISTINCT ?id) as ?cnt) ?value ?parent
{ {
?id a frbroo:F4_Manifestation_Singleton . ?id a frbroo:F4_Manifestation_Singleton .
<FILTER> <FILTER>
?id <PREDICATE> ?value . ?id <PREDICATE> ?value .
OPTIONAL { ?value crm:P89_falls_within ?parent } OPTIONAL { ?value crm:P89_falls_within ?parent }
#?value dct:source mmm-schema:Bodley . #?value dct:source mmm-schema:Bodley .
} }
GROUP BY ?value ?parent GROUP BY ?value ?parent
ORDER BY DESC(?cnt) ORDER BY DESC(?cnt)
}
FILTER(BOUND(?value)) BIND(COALESCE(?value, <http://ldf.fi/NONEXISTENT_URI>) AS ?labelValue)
OPTIONAL { ?labelValue skos:prefLabel ?lbl .
FILTER(langMatches(lang(?lbl), "fi")) . }
OPTIONAL { ?labelValue rdfs:label ?lbl .
FILTER(langMatches(lang(?lbl), "fi")) . }
OPTIONAL { ?labelValue skos:prefLabel ?lbl .
FILTER(langMatches(lang(?lbl), "en")) . }
OPTIONAL { ?labelValue rdfs:label ?lbl .
FILTER(langMatches(lang(?lbl), "en")) . }
OPTIONAL { ?labelValue skos:prefLabel ?lbl .
FILTER(langMatches(lang(?lbl), "sv")) . }
OPTIONAL { ?labelValue rdfs:label ?lbl .
FILTER(langMatches(lang(?lbl), "sv")) . }
OPTIONAL { ?labelValue skos:prefLabel ?lbl .
FILTER(langMatches(lang(?lbl), "")) . }
OPTIONAL { ?labelValue rdfs:label ?lbl .
FILTER(langMatches(lang(?lbl), "")) . }
BIND(COALESCE(?lbl, IF(!ISURI(?value), ?value, "")) AS ?facet_text) }
} }
FILTER(BOUND(?value))
?value skos:prefLabel ?facet_text_
BIND(STR(?facet_text_) AS ?facet_text)
}
}
`, `,
'tgn': { 'tgn': {
// Getty LOD documentation: // Getty LOD documentation:
......
...@@ -38,12 +38,8 @@ class SparqlApi { ...@@ -38,12 +38,8 @@ class SparqlApi {
} }
selectQuery(query, params = { headers: defaultSelectHeaders }) { selectQuery(query, params = { headers: defaultSelectHeaders }) {
return this.query(query, params).then((data) => { return this.query(query, params).then(data => {
if (this.endpoint === 'http://vocab.getty.edu/sparql.json') { return JSON.parse(data);
return(data);
} else {
return JSON.parse(data);
}
}); });
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment