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

Actors: add birth date facet

parent 8c214105
No related branches found
No related tags found
No related merge requests found
......@@ -77,7 +77,7 @@ export const INITIAL_STATE = {
makeLink: false,
sortValues: true,
numberedList: false,
minWidth: 200
minWidth: 220
},
{
id: 'deathDateTimespan',
......
......@@ -51,9 +51,29 @@ export const INITIAL_STATE = {
uriFilter: null,
spatialFilter: null
},
birthDateTimespan: {
id: 'birthDateTimespan',
label: 'Date of birth/formation',
//predicate: defined in backend
distinctValueCount: 0,
values: [],
flatValues: [],
sortBy: null,
sortDirection: null,
sortButton: false,
spatialFilterButton: false,
isFetching: false,
searchField: false,
containerClass: 'three',
filterType: 'timespanFilter',
min: null,
max: null,
timespanFilter: null,
type: 'timespan'
},
birthPlace: {
id: 'birthPlace',
label: 'Place of birth',
label: 'Place of birth/formation',
// predicate: defined in backend
distinctValueCount: 0,
values: [],
......
......@@ -158,6 +158,34 @@ export const facetConfigs = {
predicate: 'dct:source',
type: 'list',
},
birthDateTimespan: {
id: 'birthDateTimespan',
facetValueFilter: `
FILTER(?timespan NOT IN (
<http://ldf.fi/mmm/actor/sdbm_39923_birth_timespan>,
<http://ldf.fi/mmm/actor/sdbm_2814_birth_timespan>,
<http://ldf.fi/mmm/actor/sdbm_4391_birth_timespan>,
<http://ldf.fi/mmm/actor/sdbm_45865_birth_timespan>,
<http://ldf.fi/mmm/time/bibale_element_876634-269>,
<http://ldf.fi/mmm/time/bibale_element_876940-269>,
<http://ldf.fi/mmm/time/bibale_element_877018-269>,
<http://ldf.fi/mmm/time/bibale_element_876634-269>,
<http://ldf.fi/mmm/time/bibale_element_877167-269>,
<http://ldf.fi/mmm/time/bibale_element_877167-269>,
<http://ldf.fi/mmm/time/bibale_element_882490-269>,
<http://ldf.fi/mmm/actor/sdbm_44872_birth_timespan>,
<http://ldf.fi/mmm/actor/sdbm_45182_birth_timespan>,
<http://ldf.fi/mmm/actor/sdbm_40695_birth_timespan>,
<http://ldf.fi/mmm/actor/sdbm_44762_birth_timespan>
))
`,
sortByAscPredicate: 'crm:P98i_was_born/crm:P4_has_time-span/crm:P82a_begin_of_the_begin',
sortByDescPredicate: 'crm:P98i_was_born/crm:P4_has_time-span/crm:P82b_end_of_the_end',
predicate: 'crm:P98i_was_born/crm:P4_has_time-span',
startProperty: 'crm:P82a_begin_of_the_begin',
endProperty: 'crm:P82b_end_of_the_end',
type: 'timespan',
},
birthPlace: {
id: 'birthPlace',
facetValueFilter: `
......
......@@ -104,7 +104,7 @@ export const getFacet = ({
}
q = q.replace('<SELECTED_VALUES>', selectedBlock);
q = q.replace('<SELECTED_VALUES_NO_HITS>', selectedNoHitsBlock);
q = q.replace('<FACET_VALUE_FILTER>', facetConfig.facetValueFilter);
q = q.replace(/<FACET_VALUE_FILTER>/g, facetConfig.facetValueFilter);
q = q.replace('<PARENTS>', parentBlock);
if (facetConfig.type === 'list') {
q = q.replace('<ORDER_BY>', `ORDER BY ${sortDirection}(?${sortBy})` );
......@@ -118,7 +118,7 @@ export const getFacet = ({
q = q.replace('<START_PROPERTY>', facetConfig.startProperty);
q = q.replace('<END_PROPERTY>', facetConfig.endProperty);
}
// if (facetID == 'productionPlace') {
// if (facetID == 'birthDateTimespan') {
// console.log(prefixes + q)
// }
return runSelectQuery(prefixes + q, endpoint, mapper);
......
......@@ -56,7 +56,7 @@ export const generateFilter = ({
// ?${filterTarget} ${facetConfig.predicate} ?timespan .
// ?timespan ${facetConfig.startProperty} ?start .
// ?timespan ${facetConfig.endProperty} ?end .
// # both start and end is included in selected range
// # both start and end is in selected range
// FILTER(?start >= "${start}"^^xsd:date)
// FILTER(?end <= "${end}"^^xsd:date)
// `;
......@@ -64,7 +64,7 @@ export const generateFilter = ({
?${filterTarget} ${facetConfig.predicate} ?timespan .
?timespan ${facetConfig.startProperty} ?timespanStart .
?timespan ${facetConfig.endProperty} ?timespanEnd .
# either start or end is included in the selected range
# either start or end is in selected range
FILTER(
?timespanStart >= "${selectionStart}"^^xsd:date && ?timespanStart <= "${selectionEnd}"^^xsd:date
||
......
......@@ -106,6 +106,7 @@ export const facetValuesQueryTimespan = `
VALUES ?facetClass { <FACET_CLASS> }
?instance a ?facetClass .
?timespan <START_PROPERTY> ?start .
<FACET_VALUE_FILTER>
}
}
{
......@@ -114,6 +115,7 @@ export const facetValuesQueryTimespan = `
VALUES ?facetClass { <FACET_CLASS> }
?instance a ?facetClass .
?timespan <END_PROPERTY> ?end .
<FACET_VALUE_FILTER>
}
}
}
......
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