Skip to content
Snippets Groups Projects
Commit 77913411 authored by Mikko Koho's avatar Mikko Koho
Browse files

Change place parent prop, always fetch hierarchy


Co-authored-by: default avatarEsko Ikkala <esko.ikkala@aalto.fi>
parent f61397b0
No related branches found
No related tags found
No related merge requests found
......@@ -135,7 +135,7 @@ class HierarchicalFacet extends Component {
render() {
const { classes } = this.props;
const { searchString, searchFocusIndex, searchFoundCount } = this.state;
//console.log(this.props.data)
// console.log(this.props.data)
// Case insensitive search of `node.title`
const customSearchMethod = ({ node, searchQuery }) =>
......
......@@ -197,12 +197,14 @@ module.exports = {
PREFIX frbroo: <http://erlangen-crm.org/efrbroo/>
PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/>
PREFIX mmm-schema: <http://ldf.fi/mmm/schema/>
PREFIX gvp: <http://vocab.getty.edu/ontology#>
SELECT *
WHERE {
BIND (<PLACE_ID> AS ?id)
?id skos:prefLabel ?prefLabel .
OPTIONAL {
?id crm:P89_falls_within ?parent__id .
?id gvp:broaderPreferred ?parent__id .
?parent__id skos:prefLabel ?parent__prefLabel .
?parent__id mmm-schema:data_provider_url ?parent__dataProviderUrl .
}
......@@ -228,6 +230,8 @@ module.exports = {
PREFIX geosparql: <http://www.opengis.net/ont/geosparql#>
PREFIX frbroo: <http://erlangen-crm.org/efrbroo/>
PREFIX mmm-schema: <http://ldf.fi/mmm/schema/>
PREFIX gvp: <http://vocab.getty.edu/ontology#>
SELECT DISTINCT ?id ?prefLabel ?selected ?source ?parent ?instanceCount {
{
{
......@@ -239,7 +243,10 @@ module.exports = {
<SELECTED_VALUES>
BIND(COALESCE(?selected_, false) as ?selected)
OPTIONAL { ?id dct:source ?source }
OPTIONAL { ?id crm:P89_falls_within ?parent_ }
OPTIONAL {
?id gvp:broaderPreferred ?parent_ .
FILTER(?parent_ != <http://ldf.fi/mmm/places/tgn_7029392>)
}
BIND(COALESCE(?parent_, '0') as ?parent)
}
<PARENTS>
......
......@@ -16,7 +16,7 @@ const facetConfigs = {
label: 'Production place',
labelPath: '^crm:P108_has_produced/crm:P7_took_place_at/skos:prefLabel',
predicate: '^crm:P108_has_produced/crm:P7_took_place_at',
parentPredicate: '^crm:P108_has_produced/crm:P7_took_place_at/crm:P89_falls_within*',
parentPredicate: '^crm:P108_has_produced/crm:P7_took_place_at/gvp:broaderPreferred+',
type: 'hierarchical',
},
author: {
......@@ -145,26 +145,26 @@ export const getFacet = (id, sortBy, sortDirection, filters) => {
}
if (facetConfig.type === 'hierarchical') {
mapper = mapHierarchicalFacet;
if (filters !== null) {
parentBlock = `
UNION
{
${generateFacetFilterParents(id, filters)}
?parentInstance ${facetConfig.parentPredicate} ?id .
?instance ${facetConfig.parentPredicate} ?id .
BIND(COALESCE(?selected_, false) as ?selected)
OPTIONAL { ?id skos:prefLabel ?prefLabel_ }
BIND(COALESCE(STR(?prefLabel_), STR(?id)) AS ?prefLabel)
OPTIONAL { ?id dct:source ?source }
OPTIONAL { ?id crm:P89_falls_within ?parent_ }
OPTIONAL { ?id gvp:broaderPreferred ?parent_ }
BIND(COALESCE(?parent_, '0') as ?parent)
}
`;
}
}
facetQuery = facetQuery.replace(/<FILTER>/g, filterBlock );
facetQuery = facetQuery.replace(/<PREDICATE>/g, facetConfig.predicate);
facetQuery = facetQuery.replace('<SELECTED_VALUES>', selectedBlock);
facetQuery = facetQuery.replace('<PARENTS>', parentBlock);
facetQuery = facetQuery.replace('<ORDER_BY>', `ORDER BY ${sortDirection}(?${sortBy})` );
// if (id == 'author') {
// if (id == 'productionPlace') {
// //console.log(filters)
// console.log(facetQuery)
// }
......@@ -190,7 +190,7 @@ const generateFacetFilterParents = (facetId, filters) => {
if (property !== facetId) {
filterStr += `
VALUES ?${property}FilterParents { <${filters[property].join('> <')}> }
?parentInstance ${facetConfigs[property].predicate} ?${property}FilterParents .
?instance ${facetConfigs[property].predicate} ?${property}FilterParents .
`;
}
}
......
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