Commit bf16ff83 authored by Fabien Amarger's avatar Fabien Amarger
Browse files

feat: [priorityFor] Define non suitable data for a dedicated view

Returns -1 if the view is not suitable.
parent 7a0eb8a1e4e6
Pipeline #15061 failed with stages
in 3 minutes and 42 seconds
...@@ -14,6 +14,7 @@ L.Icon.Default.imagePath = `${process.env.DOMAIN}/images/`; ...@@ -14,6 +14,7 @@ L.Icon.Default.imagePath = `${process.env.DOMAIN}/images/`;
const RDF = $rdf.Namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#'); const RDF = $rdf.Namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#');
const RDFS = $rdf.Namespace('http://www.w3.org/2000/01/rdf-schema#'); const RDFS = $rdf.Namespace('http://www.w3.org/2000/01/rdf-schema#');
const OWL = $rdf.Namespace('http://www.w3.org/2002/07/owl#');
const CULT = $rdf.Namespace('http://graphe-culture.fr/'); const CULT = $rdf.Namespace('http://graphe-culture.fr/');
const DESCRIPTOR_BIENCULTURELCLASS: definition.ViewDescriptor = { const DESCRIPTOR_BIENCULTURELCLASS: definition.ViewDescriptor = {
...@@ -142,6 +143,14 @@ class BienCulturelClassRendering implements implementation.ViewImplementation { ...@@ -142,6 +143,14 @@ class BienCulturelClassRendering implements implementation.ViewImplementation {
const targetSym = $rdf.sym(target.uri); const targetSym = $rdf.sym(target.uri);
if (
context.any(null, RDF('type'), targetSym) === null &&
context.any(targetSym, RDF('type'), OWL('Class')) === null &&
context.any(targetSym, RDF('type'), RDFS('Class')) === null
) {
return -1; // this view is not suitable if it is not a class
}
if (target.uri === CULT('BienCulturel').value) { if (target.uri === CULT('BienCulturel').value) {
// if it is BienCulturel // if it is BienCulturel
score += 30; score += 30;
......
...@@ -14,6 +14,7 @@ import './localisation.css'; ...@@ -14,6 +14,7 @@ import './localisation.css';
const RDF = $rdf.Namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#'); const RDF = $rdf.Namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#');
const RDFS = $rdf.Namespace('http://www.w3.org/2000/01/rdf-schema#'); const RDFS = $rdf.Namespace('http://www.w3.org/2000/01/rdf-schema#');
const OWL = $rdf.Namespace('http://www.w3.org/2002/07/owl#');
const CULT = $rdf.Namespace('http://graphe-culture.fr/'); const CULT = $rdf.Namespace('http://graphe-culture.fr/');
const DESCRIPTOR_LOCALISATION: definition.ViewDescriptor = { const DESCRIPTOR_LOCALISATION: definition.ViewDescriptor = {
...@@ -160,6 +161,14 @@ class LocalisationRendering implements implementation.ViewImplementation { ...@@ -160,6 +161,14 @@ class LocalisationRendering implements implementation.ViewImplementation {
const targetSym = $rdf.sym(target.uri); const targetSym = $rdf.sym(target.uri);
if (
context.any(null, RDF('type'), targetSym) !== null ||
context.any(targetSym, RDF('type'), OWL('Class')) !== null ||
context.any(targetSym, RDF('type'), RDFS('Class')) !== null
) {
return -1; // this view is not suitable if it is a class
}
// has at least one type // has at least one type
const firstType = context.any(targetSym, RDF('type')); const firstType = context.any(targetSym, RDF('type'));
if (firstType !== null) { if (firstType !== null) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment