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

Add custom parents for places that are not linked to TGN

parent 37ec4c71
No related branches found
No related tags found
No related merge requests found
......@@ -118,7 +118,8 @@ class HierarchicalFacet extends Component {
generateLabelClass = (classes, node) => {
let labelClass = classes.label;
if (this.props.property === 'author' || this.props.property === 'productionPlace' || this.props.property === 'source') {
if (this.props.property === 'author' || this.props.property === 'source')
{
if (node.source === 'http://ldf.fi/mmm/schema/SDBM' || node.id === 'http://ldf.fi/mmm/schema/SDBM') {
labelClass = classes.sdbmLabel;
}
......@@ -138,9 +139,11 @@ class HierarchicalFacet extends Component {
// console.log(this.props.data)
// Case insensitive search of `node.title`
const customSearchMethod = ({ node, searchQuery }) =>
searchQuery.length > 2 &&
node.prefLabel.toLowerCase().indexOf(searchQuery.toLowerCase()) > -1;
const customSearchMethod = ({ node, searchQuery }) => {
let prefLabel = Array.isArray(node.prefLabel) ? node.prefLabel[0] : node.prefLabel;
return searchQuery.length > 2 &&
prefLabel.toLowerCase().indexOf(searchQuery.toLowerCase()) > -1;
};
const selectPrevMatch = () =>
this.setState({
......
......@@ -231,8 +231,6 @@ module.exports = {
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 {
{
{
......@@ -246,7 +244,7 @@ module.exports = {
OPTIONAL { ?id dct:source ?source }
OPTIONAL {
?id gvp:broaderPreferred ?parent_ .
FILTER(?parent_ != <http://ldf.fi/mmm/places/tgn_7029392>)
#FILTER(?parent_ != <http://ldf.fi/mmm/places/tgn_7029392>)
}
BIND(COALESCE(?parent_, '0') as ?parent)
}
......
......@@ -37,11 +37,36 @@ export const mapFacet = sparqlBindings => {
export const mapHierarchicalFacet = sparqlBindings => {
const results = makeObjectList(sparqlBindings);
//console.log(results)
results.push({
id: 'http://ldf.fi/mmm/places/sdbm_not_linked',
prefLabel: 'SDBM places not linked to TGN',
selected: 'false',
source: 'http://ldf.fi/mmm/schema/SDBM',
instanceCount: '0',
parent: '0'
});
results.push({
id: 'http://ldf.fi/mmm/places/bodley_not_linked',
prefLabel: 'Bodley places not linked to TGN',
selected: 'false',
source: 'http://ldf.fi/mmm/schema/Bodley',
instanceCount: '0',
parent: '0'
});
results.push({
id: 'http://ldf.fi/mmm/places/bibale_not_linked',
prefLabel: 'Bibale places not linked to TGN',
selected: 'false',
source: 'http://ldf.fi/mmm/schema/Bibale',
instanceCount: '0',
parent: '0'
});
let treeData = getTreeFromFlatData({
flatData: results,
getKey: node => node.id, // resolve a node's key
getParentKey: node => node.parent, // resolve node's parent's key
rootKey: 0, // The value of the parent key when there is no parent (i.e., at root level)
getParentKey: getParentKey, // resolve node's parent's key
rootKey: '0', // The value of the parent key when there is no parent (i.e., at root level)
});
treeData = recursiveSort(treeData);
treeData.forEach(node => sumUp(node));
......@@ -51,6 +76,37 @@ export const mapHierarchicalFacet = sparqlBindings => {
};
};
const rootLevel = new Set([
'http://ldf.fi/mmm/places/tgn_7029392',
'http://ldf.fi/mmm/places/sdbm_not_linked',
'http://ldf.fi/mmm/places/bodley_not_linked',
'http://ldf.fi/mmm/places/bibale_not_linked'
]);
const getParentKey = node => {
let parent = '';
if (node.parent === '0' && !rootLevel.has(node.id)) {
if (Array.isArray(node.source)) {
if (node.source.indexOf('http://ldf.fi/mmm/schema/SDBM') != -1) {
parent = 'http://ldf.fi/mmm/places/sdbm_not_linked';
} else if (node.source.indexOf('http://ldf.fi/mmm/schema/Bodley') != -1) {
parent = 'http://ldf.fi/mmm/places/bodley_not_linked';
} else if (node.source.indexOf('http://ldf.fi/mmm/schema/Bibale') != -1) {
parent = 'http://ldf.fi/mmm/places/bibale_not_linked';
}
} else if (node.source === 'http://ldf.fi/mmm/schema/SDBM') {
parent = 'http://ldf.fi/mmm/places/sdbm_not_linked';
} else if (node.source === 'http://ldf.fi/mmm/schema/Bodley') {
parent = 'http://ldf.fi/mmm/places/bodley_not_linked';
} else if (node.source === 'http://ldf.fi/mmm/schema/Bibale') {
parent = 'http://ldf.fi/mmm/places/bibale_not_linked';
}
} else {
parent = node.parent;
}
return parent;
};
const comparator = (a, b) => {
if (Array.isArray(a.prefLabel)) {
a.prefLabel = a.prefLabel[0];
......
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