diff --git a/src/client/components/HierarchicalFacet.js b/src/client/components/HierarchicalFacet.js index 2e97dbef486a99f2cb750687ef1b85e6e237c212..a6a296a84993af77dcb6f053dcb7dda009d37708 100644 --- a/src/client/components/HierarchicalFacet.js +++ b/src/client/components/HierarchicalFacet.js @@ -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({ diff --git a/src/server/sparql/Datasets.js b/src/server/sparql/Datasets.js index 664fd033b63d486568970f79cbe76c850a4b78fc..2d70b08006ee061a9f96df79ccce62d80b8ec761 100644 --- a/src/server/sparql/Datasets.js +++ b/src/server/sparql/Datasets.js @@ -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) } diff --git a/src/server/sparql/Mappers.js b/src/server/sparql/Mappers.js index 61d7bc08d293a14ffa190d708b14a470083b1466..797c819aad4cbfdd115c232dda68d758b6e182dc 100644 --- a/src/server/sparql/Mappers.js +++ b/src/server/sparql/Mappers.js @@ -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];