sparnatural
Version:
Visual client-side SPARQL query builder and knowledge graph exploration tool
641 lines • 33.4 kB
JavaScript
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _SHACLSpecificationEntity_instances, _SHACLSpecificationEntity_findShapesTargetingClassIn, _SHACLSpecificationEntity_getSuperClassesRec, _SHACLSpecificationEntity_getSuperClassesAtLevel, _SHACLSpecificationEntity_getShNode, _SHACLSpecificationEntity_getInverseOfShNodeForExplicitNodeShapes, _SHACLSpecificationEntity_getTargetClasses, _SHACLSpecificationEntity_isNodeShapeAndClass;
import { DataFactory } from 'rdf-data-factory';
import { RDF } from "../../../rdf/vocabularies/RDF";
import { RDFS } from "../../../rdf/vocabularies/RDFS";
import { DASH } from "../../../rdf/vocabularies/DASH";
import { DCT } from "../../../rdf/vocabularies/DCT";
import { FOAF } from "../../../rdf/vocabularies/FOAF";
import { SCHEMA } from "../../../rdf/vocabularies/SCHEMA";
import { SH } from "../../../rdf/vocabularies/SH";
import { SKOS } from "../../../rdf/vocabularies/SKOS";
import { VOLIPI } from "../../../rdf/vocabularies/VOLIPI";
import { XSD } from "../../../rdf/vocabularies/XSD";
import { SHACLSpecificationEntry } from "./SHACLSpecificationEntry";
import { SHACLSpecificationProperty } from "./SHACLSpecificationProperty";
import { StoreModel } from "../../../rdf/StoreModel";
import { Dag } from "../../dag/Dag";
import { GEOSPARQL } from '../../components/widgets/MapWidget';
const factory = new DataFactory();
export class SHACLSpecificationEntity extends SHACLSpecificationEntry {
constructor(uri, provider, n3store, lang) {
super(uri, provider, n3store, lang);
_SHACLSpecificationEntity_instances.add(this);
}
getLabel() {
// first try to read an rdfs:label
let label = this.graph.readSinglePropertyInLang(factory.namedNode(this.uri), RDFS.LABEL, this.lang)?.value;
if (!label) {
// attempt to read it on the targetClass, if we have it
if (this.graph.hasTriple(factory.namedNode(this.uri), SH.TARGET_CLASS, null)) {
let targetClass = this.graph.readSingleProperty(factory.namedNode(this.uri), SH.TARGET_CLASS);
label = this.graph.readSinglePropertyInLang(targetClass, RDFS.LABEL, this.lang)?.value;
}
}
if (!label) {
// attempt to read the local part of the targetClass URI
if (this.graph.hasTriple(factory.namedNode(this.uri), SH.TARGET_CLASS, null)) {
let targetClass = this.graph.readSingleProperty(factory.namedNode(this.uri), SH.TARGET_CLASS);
label = StoreModel.getLocalName(targetClass.value);
}
}
if (!label) {
// default : read the local part of the URI
label = StoreModel.getLocalName(this.uri);
}
return label;
}
getTooltip() {
let tooltip = this.graph.readSinglePropertyInLang(factory.namedNode(this.uri), VOLIPI.MESSAGE, this.lang)?.value;
if (!tooltip) {
// try with sh:description
tooltip = this.graph.readSinglePropertyInLang(factory.namedNode(this.uri), SH.DESCRIPTION, this.lang)?.value;
}
if (this.graph.hasTriple(factory.namedNode(this.uri), SH.TARGET_CLASS, null)) {
if (!tooltip) {
// try to read an rdfs:comment on the class itself
// note that we try to read the value even in case the target is a blank node, e.g. SPARQL target
tooltip = this.graph.readSinglePropertyInLang(this.graph.readSingleProperty(factory.namedNode(this.uri), SH.TARGET_CLASS), SKOS.DEFINITION, this.lang)?.value;
}
if (!tooltip) {
// try to read an rdfs:comment on the class itself
// note that we try to read the value even in case the target is a blank node, e.g. SPARQL target
tooltip = this.graph.readSinglePropertyInLang(this.graph.readSingleProperty(factory.namedNode(this.uri), SH.TARGET_CLASS), RDFS.COMMENT, this.lang)?.value;
}
}
return tooltip;
}
getConnectingProperties(range) {
// read all sh:property and find the ones that can target the selected class
var items = [];
let propShapes = this.getProperties();
propShapes.forEach(ps => {
let prop = new SHACLSpecificationProperty(ps, this.provider, this.store, this.lang);
let pRange = prop.getRange();
if (pRange.indexOf(range) > -1) {
items.push(ps);
}
});
// add properties available from parents - recursively
let parents = this.provider.getEntity(range).getParents();
parents.forEach(aParent => {
items = [...items, ...this.getConnectingProperties(aParent)];
});
// dedup, although probably dedup is not necessary here
var dedupItems = [...new Set(items)];
// sort dedups
var sortedDedups = SHACLSpecificationEntry.sort(dedupItems.map(s => new SHACLSpecificationProperty(s, this.provider, this.store, this.lang)));
// return dedup array of strings
return sortedDedups.map(e => e.getId());
}
/**
* Return the tree of properties connecting this entity to the specified range entity
* @param range The URI of the selected target entity
* @returns
*/
getConnectingPropertiesTree(range) {
// 1. get list of properties
let properties = this.getConnectingProperties(range).map(s => this.provider.getProperty(s));
// retrieve the potential parents
while (!properties.every(property => {
return property.getParents().every(parent => {
return (properties.find(anotherProperty => anotherProperty.getId() === parent) != undefined);
});
})) {
let parentsToAdd = [];
properties.forEach(property => {
property.getParents().forEach(parent => {
// if the parent is not already there, add it to the list of parents to add
if (!properties.find(anotherProperty => anotherProperty.getId() === parent)) {
parentsToAdd.push(this.provider.getProperty(parent));
}
});
});
parentsToAdd.forEach(p => properties.push(p));
}
// 2. turn it into a tree
let dag = new Dag();
dag.initFromParentableAndIdAbleEntity(properties, []);
// sort the tree with compare function
dag.sort(SHACLSpecificationProperty.compare);
return dag;
}
getConnectedEntities() {
var items = [];
// read all properties that make sense for Sparnatural
let propShapes = this.getProperties();
propShapes
.forEach(ps => {
// read the property
let prop = new SHACLSpecificationProperty(ps, this.provider, this.store, this.lang);
// and then read their ranges
items.push(...prop.getRange());
});
// dedup
var dedupItems = [...new Set(items)];
// sort dedups
var sortedDedups = SHACLSpecificationEntry.sort(dedupItems.map(s => new SHACLSpecificationEntity(s, this.provider, this.store, this.lang)));
// return dedup array of strings
return sortedDedups.map(e => e.getId());
}
getConnectedEntitiesTree() {
// 1. get directly connected entities
let entities = this.getConnectedEntities().map(s => this.provider.getEntity(s));
// 2. add the children of these entities - recursively
while (!entities.every(entity => {
return entity.getChildren().every(child => {
return (entities.find(anotherEntity => anotherEntity.getId() === child) != undefined);
});
})) {
let childrenToAdd = [];
entities.forEach(entity => {
entity.getChildren().forEach(child => {
if (!entities.find(anotherEntity => anotherEntity.getId() === child)) {
childrenToAdd.push(this.provider.getEntity(child));
}
});
});
childrenToAdd.forEach(p => entities.push(p));
}
// 3. complement the initial list with their parents
let disabledList = new Array();
// while not all parents of all entities are not part of the list...
while (!entities.every(entity => {
return entity.getParents().every(parent => {
return (entities.find(anotherEntity => anotherEntity.getId() === parent) != undefined);
});
})) {
let parentsToAdd = [];
entities.forEach(entity => {
entity.getParents().forEach(parent => {
if (!entities.find(anotherEntity => anotherEntity.getId() === parent)) {
parentsToAdd.push(this.provider.getEntity(parent));
}
});
});
parentsToAdd.forEach(p => entities.push(p));
// also keep that as a disabled node
parentsToAdd.forEach(p => disabledList.push(p.getId()));
}
let dag = new Dag();
dag.initFromParentableAndIdAbleEntity(entities, disabledList);
// sort the tree with compare function
dag.sort(SHACLSpecificationEntity.compare);
return dag;
}
hasConnectedEntities() {
return (this.getConnectedEntities().length > 0);
}
/**
* @returns all (non-deactivated) properties available on this node shape, including inherited properties from superclasses
*/
getProperties() {
var items = [];
// read all sh:property
let propShapes = this.graph.readProperty(factory.namedNode(this.uri), SH.PROPERTY)
.map(node => node.value);
// add all properties from parents (either through sh:node or sh:targetClass/rdfs:subClassOf/^sh:targetClass)
let parents = this.getParents();
parents.forEach(p => {
let parentEntity = new SHACLSpecificationEntity(p, this.provider, this.store, this.lang);
propShapes.push(...parentEntity.getProperties());
});
// filter properties not to be shown
propShapes
.forEach(ps => {
if (SHACLSpecificationProperty.isSparnaturalSHACLSpecificationProperty(ps, this.store)) {
items.push(ps);
}
});
// dedup, although probably dedup is not necessary here
var dedupItems = [...new Set(items)];
// sort dedups
var sortedDedups = SHACLSpecificationEntry.sort(dedupItems.map(s => new SHACLSpecificationProperty(s, this.provider, this.store, this.lang)));
// return dedup array of strings
return sortedDedups.map(e => e.getId());
}
/**
*
* @returns true if sh:nodeKind = sh:Literal, or if sh:datatype is present, or if sh:languageIn is present
*/
isLiteralEntity() {
var hasNodeKindLiteral = this.graph.hasTriple(factory.namedNode(this.uri), SH.NODE_KIND, SH.LITERAL);
var hasDatatype = this.graph.hasTriple(factory.namedNode(this.uri), SH.DATATYPE, null);
var hasLanguageIn = this.graph.hasTriple(factory.namedNode(this.uri), SH.LANGUAGE_IN, null);
var hasUniqueLang = this.graph.hasTriple(factory.namedNode(this.uri), SH.UNIQUE_LANG, null);
return hasNodeKindLiteral || hasDatatype || hasLanguageIn || hasUniqueLang;
}
/**
* @returns true if this shape has a target, either a targetClass or sh:target, or is itself a Class
*/
hasTypeCriteria() {
var hasTargetClass = this.graph.hasTriple(factory.namedNode(this.uri), SH.TARGET_CLASS, null);
var hasTarget = this.graph.hasTriple(factory.namedNode(this.uri), SH.TARGET, null);
var isItselfClass = this.graph.hasTriple(factory.namedNode(this.uri), RDF.TYPE, RDFS.CLASS);
return (hasTargetClass || hasTarget || isItselfClass);
}
/**
* @returns a property labelled with dash:propertyRole = dash:LabelRole
*/
getDefaultLabelProperty() {
var items = [];
// read all properties
let propShapes = this.graph.readProperty(factory.namedNode(this.uri), SH.PROPERTY);
propShapes.forEach(ps => {
if (this.store.getQuads(ps, DASH.PROPERTY_ROLE, DASH.LABEL_ROLE, null).length > 0) {
items.push(ps.value);
}
});
// nothing found, see if we can inherit it
if (items.length == 0) {
let parents = this.getParents();
parents.forEach(p => {
// if not found already, set it to the parent default label prop - otherwise keep the value we found
let parentEntity = new SHACLSpecificationEntity(p, this.provider, this.store, this.lang);
let parentDefaultLabelProp = parentEntity.getDefaultLabelProperty();
// could be undefined or a string
if (parentDefaultLabelProp) {
items.push(parentDefaultLabelProp);
}
;
});
}
if (items.length == 0) {
// nothing found, check for SKOS.PREF_LABEL, FOAF.NAME, SCHEMA.NAME, DCTERMS.TITLE, RDFS.LABEL
const PROPERTIES_TO_CHECK = [SKOS.PREF_LABEL, FOAF.NAME, SCHEMA.NAME, DCT.TITLE, RDFS.LABEL];
for (let i = 0; i < PROPERTIES_TO_CHECK.length; i++) {
let prop = PROPERTIES_TO_CHECK[i];
propShapes.forEach(ps => {
if (this.store.getQuads(ps, SH.PATH, prop, null).length > 0) {
items.push(ps.value);
}
});
if (items.length > 0) {
// break as soon as we find something
break;
}
}
}
if (items.length > 0) {
// return the first one found
return items[0];
}
else {
return undefined;
}
}
getParents() {
let parentsFromSuperClasses = __classPrivateFieldGet(this, _SHACLSpecificationEntity_instances, "m", _SHACLSpecificationEntity_findShapesTargetingClassIn).call(this, this.getImmediateSuperClassesOfTargetClass());
if (parentsFromSuperClasses.length == 0) {
parentsFromSuperClasses = __classPrivateFieldGet(this, _SHACLSpecificationEntity_instances, "m", _SHACLSpecificationEntity_findShapesTargetingClassIn).call(this, this.getSuperClassesOfTargetClass(2));
}
if (parentsFromSuperClasses.length == 0) {
parentsFromSuperClasses = __classPrivateFieldGet(this, _SHACLSpecificationEntity_instances, "m", _SHACLSpecificationEntity_findShapesTargetingClassIn).call(this, this.getSuperClassesOfTargetClass(3));
}
if (parentsFromSuperClasses.length == 0) {
parentsFromSuperClasses = __classPrivateFieldGet(this, _SHACLSpecificationEntity_instances, "m", _SHACLSpecificationEntity_findShapesTargetingClassIn).call(this, this.getSuperClassesOfTargetClass(4));
}
if (parentsFromSuperClasses.length == 0) {
parentsFromSuperClasses = __classPrivateFieldGet(this, _SHACLSpecificationEntity_instances, "m", _SHACLSpecificationEntity_findShapesTargetingClassIn).call(this, this.getSuperClassesOfTargetClass(5));
}
// get the parents from sh:node
let parentsFromShNode = __classPrivateFieldGet(this, _SHACLSpecificationEntity_instances, "m", _SHACLSpecificationEntity_getShNode).call(this);
// concat parents from superclasses and from node - deduplicated
let parents = [...new Set([...parentsFromSuperClasses, ...parentsFromShNode])];
return parents
// and simply return the string value
.map(term => term.value);
}
getChildren() {
let cildrenFromSuperClasses = this.getSubClassesOfTargetClass()
// note : we exclude blank nodes
.filter(term => term.termType == "NamedNode")
// we find the shape targeting this class - it can be the class itself
.map(term => {
if (this.graph.hasTriple(term, RDF.TYPE, RDFS.CLASS)) {
return term;
}
else {
return this.graph.findSingleSubjectOf(SH.TARGET_CLASS, term);
}
})
// remove those for which the shape was not found
.filter(term => (term != undefined));
// get the children from sh:node
let childrenFromShNode = __classPrivateFieldGet(this, _SHACLSpecificationEntity_instances, "m", _SHACLSpecificationEntity_getInverseOfShNodeForExplicitNodeShapes).call(this);
// concat parents from superclasses and from node - deduplicated
let children = [...new Set([...cildrenFromSuperClasses, ...childrenFromShNode])];
return children
// and simply return the string value
.map(term => term.value);
}
/**
* @returns the recursive superclasses of the target class of this Shape (can be the shape itself)
*/
getAllSuperClassesOfTargetClass() {
// retrieve target classes
let targetClasses = __classPrivateFieldGet(this, _SHACLSpecificationEntity_instances, "m", _SHACLSpecificationEntity_getTargetClasses).call(this);
// then retrieve super classes of those classes
let superClasses = [];
targetClasses.forEach(tc => {
let allSuperClasses = this.graph.readPropertyRec(tc, RDFS.SUBCLASS_OF);
superClasses.push(...allSuperClasses);
});
return superClasses;
}
/**
* @returns the immediate superclasses of the target class of this Shape (can be the shape itself)
*/
getImmediateSuperClassesOfTargetClass() {
return this.getSuperClassesOfTargetClass(1);
}
getSuperClassesOfTargetClass(level) {
// retrieve target classes
let targetClasses = __classPrivateFieldGet(this, _SHACLSpecificationEntity_instances, "m", _SHACLSpecificationEntity_getTargetClasses).call(this);
// then retrieve super classes of those classes
let superClasses = [];
targetClasses.forEach(tc => {
let currentSuperClasses = __classPrivateFieldGet(this, _SHACLSpecificationEntity_instances, "m", _SHACLSpecificationEntity_getSuperClassesAtLevel).call(this, tc, level);
superClasses.push(...currentSuperClasses);
});
return superClasses;
}
/**
* @returns the immediate subclasses of the target class of this Shape (can be the shape itself)
*/
getSubClassesOfTargetClass() {
// retrieve target classes
let targetClasses = __classPrivateFieldGet(this, _SHACLSpecificationEntity_instances, "m", _SHACLSpecificationEntity_getTargetClasses).call(this);
// then retrieve sub classes of those classes
let subClasses = [];
targetClasses.forEach(tc => {
let currentSubClasses = this.graph.findSubjectsOf(RDFS.SUBCLASS_OF, tc);
subClasses.push(...currentSubClasses);
});
return subClasses;
}
isRangeOf(n3store, shapeUri) {
return (SHACLSpecificationProperty.readShClassAndShNodeOn(n3store, shapeUri).indexOf(this.uri) > -1);
}
/**
* @returns all values of sh:targetClass on this entity, as RDF Terms
*/
getShTargetClass() {
return this.graph.readProperty(factory.namedNode(this.uri), SH.TARGET_CLASS);
}
/**
* @returns true if this shape as an sh:target predicate (indicating it is associated to a SPARQL query target)
*/
hasShTarget() {
return this.graph.hasTriple(factory.namedNode(this.uri), SH.TARGET, null);
}
couldBeSkosConcept() {
return SHACLSpecificationEntity.couldBeSkosConcept(this.uri, this.provider);
}
static couldBeSkosConcept(nodeShapeUri, config) {
let specEntity = config.getEntity(nodeShapeUri);
if (specEntity) {
let isItselfSkosConcept = (nodeShapeUri == SKOS.CONCEPT.value);
let targetsSkosConcept = (specEntity.getShTargetClass().findIndex(t => t.value == SKOS.CONCEPT.value) > -1);
// read all sh:property, including sh:deactivated, ones with sh:hasValue, etc.
let propShapes = specEntity.graph.readProperty(factory.namedNode(nodeShapeUri), SH.PROPERTY).map(node => node.value);
let hasPropertyRdfTypeSkosConcept = propShapes.findIndex(p => {
let propertyShape = config.getProperty(p);
let path = propertyShape.getShPath();
if (path
&&
(path.value === RDF.TYPE.value)
&&
specEntity.graph.hasTriple(factory.namedNode(p), SH.HAS_VALUE, SKOS.CONCEPT)) {
return true;
}
return false;
}) > -1;
let hasConstraintOnSkosInScheme = propShapes.findIndex(p => {
let propertyShape = config.getProperty(p);
let path = propertyShape.getShPath();
if (path
&&
(path.value === SKOS.IN_SCHEME.value)
&&
specEntity.graph.hasTriple(factory.namedNode(p), SH.HAS_VALUE, null)) {
return true;
}
return false;
}) > -1;
return isItselfSkosConcept || targetsSkosConcept || hasPropertyRdfTypeSkosConcept || hasConstraintOnSkosInScheme;
}
}
static compare(item1, item2) {
return SHACLSpecificationEntry.compare(item1, item2);
}
}
_SHACLSpecificationEntity_instances = new WeakSet(), _SHACLSpecificationEntity_findShapesTargetingClassIn = function _SHACLSpecificationEntity_findShapesTargetingClassIn(classes) {
// note : we exclude blank nodes
return classes.filter(term => term.termType == "NamedNode")
// we find the shape targeting this class - it can be the class itself
.map(term => {
if (this.graph.hasTriple(term, RDF.TYPE, RDFS.CLASS)) {
return term;
}
else {
return this.graph.findSingleSubjectOf(SH.TARGET_CLASS, term);
}
})
// remove those for which the shape was not found
.filter(term => (term != undefined));
}, _SHACLSpecificationEntity_getSuperClassesRec = function _SHACLSpecificationEntity_getSuperClassesRec(classNode) {
var items = [];
let superClasses = this.graph.readProperty(classNode, RDFS.SUBCLASS_OF);
items.push(...superClasses);
superClasses.forEach(sc => {
items.push(...__classPrivateFieldGet(this, _SHACLSpecificationEntity_instances, "m", _SHACLSpecificationEntity_getSuperClassesRec).call(this, sc));
});
return items;
}, _SHACLSpecificationEntity_getSuperClassesAtLevel = function _SHACLSpecificationEntity_getSuperClassesAtLevel(classNode, level) {
if (level < 1) {
return null;
}
var items = [];
let superClasses = this.graph.readProperty(classNode, RDFS.SUBCLASS_OF);
items.push(...superClasses);
if (level == 1) {
return items;
}
else {
var result = [];
items.forEach(i => result.push(...__classPrivateFieldGet(this, _SHACLSpecificationEntity_instances, "m", _SHACLSpecificationEntity_getSuperClassesAtLevel).call(this, i, (level - 1))));
return result;
}
}, _SHACLSpecificationEntity_getShNode = function _SHACLSpecificationEntity_getShNode() {
return this.graph.readProperty(factory.namedNode(this.uri), SH.NODE);
}, _SHACLSpecificationEntity_getInverseOfShNodeForExplicitNodeShapes = function _SHACLSpecificationEntity_getInverseOfShNodeForExplicitNodeShapes() {
let subjects = this.graph.findSubjectsOf(SH.NODE, factory.namedNode(this.uri));
// keep only the sh:node references from NodeShapes, not property shapes or sh:or on property shapes
// there could be more precise ways of doing this
return subjects.filter(term => term.termType == "NamedNode"
&&
this.graph.hasTriple(term, RDF.TYPE, SH.NODE_SHAPE));
}, _SHACLSpecificationEntity_getTargetClasses = function _SHACLSpecificationEntity_getTargetClasses() {
if (__classPrivateFieldGet(this, _SHACLSpecificationEntity_instances, "m", _SHACLSpecificationEntity_isNodeShapeAndClass).call(this)) {
return [factory.namedNode(this.uri)];
}
else {
return this.getShTargetClass();
}
}, _SHACLSpecificationEntity_isNodeShapeAndClass = function _SHACLSpecificationEntity_isNodeShapeAndClass() {
return (this.graph.hasTriple(factory.namedNode(this.uri), RDF.TYPE, RDFS.CLASS)
&&
this.graph.hasTriple(factory.namedNode(this.uri), RDF.TYPE, SH.NODE_SHAPE));
};
export class SpecialSHACLSpecificationEntity {
constructor(id, icon, label, isRangeOfFunction) {
this.id = id;
this.icon = icon;
this.label = label;
this.isRangeOfFunction = isRangeOfFunction;
}
getId() {
return this.id;
}
getLabel() {
return this.label;
}
getColor() {
// return "slategray";
return undefined;
}
getIcon() {
return this.icon;
}
isRangeOf(n3store, shapeUri) {
return this.isRangeOfFunction(n3store, shapeUri);
}
// default implementation of all other functions
getConnectedEntities() { return new Array(); }
getConnectedEntitiesTree() { return new Dag(); }
hasConnectedEntities() { return false; }
getConnectingProperties(range) { return new Array(); }
getConnectingPropertiesTree(range) { return new Dag(); }
isLiteralEntity() { return true; }
hasTypeCriteria() { return false; }
getDefaultLabelProperty() { return undefined; }
getOrder() { return undefined; }
getTooltip() { return undefined; }
getDatasource() { return null; }
getTreeChildrenDatasource() { return null; }
getTreeRootsDatasource() { return null; }
getHighlightedIcon() { return ""; }
getParents() { return []; }
getChildren() { return []; }
couldBeSkosConcept() { return false; }
}
export class SpecialSHACLSpecificationEntityRegistry {
/**
* The Singleton's constructor should always be private to prevent direct
* construction calls with the `new` operator.
*/
constructor() {
this.registry = new Map();
this.registry.set(SpecialSHACLSpecificationEntityRegistry.SPECIAL_SHACL_ENTITY_OTHER, new SpecialSHACLSpecificationEntity(SpecialSHACLSpecificationEntityRegistry.SPECIAL_SHACL_ENTITY_OTHER, "fa-solid fa-ellipsis", "Other", function (n3store, shapeUri) {
// this is in range if nothing else is in range
let graph = new StoreModel(n3store);
return (!graph.hasTriple(factory.namedNode(shapeUri), SH.NODE, null)
&&
!graph.hasTriple(factory.namedNode(shapeUri), SH.CLASS, null)
&&
!graph.hasTriple(factory.namedNode(shapeUri), SH.DATATYPE, XSD.DATE)
&&
!graph.hasTriple(factory.namedNode(shapeUri), SH.DATATYPE, XSD.DATE_TIME)
&&
!graph.hasTriple(factory.namedNode(shapeUri), SH.DATATYPE, XSD.GYEAR)
&&
!graph.hasTriple(factory.namedNode(shapeUri), SH.DATATYPE, GEOSPARQL.WKT_LITERAL)
&&
!graph.hasTriple(factory.namedNode(shapeUri), SH.DATATYPE, XSD.STRING)
&&
!graph.hasTriple(factory.namedNode(shapeUri), SH.DATATYPE, RDF.LANG_STRING));
}));
this.registry.set(SpecialSHACLSpecificationEntityRegistry.SPECIAL_SHACL_ENTITY_DATES, new SpecialSHACLSpecificationEntity(SpecialSHACLSpecificationEntityRegistry.SPECIAL_SHACL_ENTITY_DATES, "fa-solid fa-calendar", "Date", function (n3store, shapeUri) {
let graph = new StoreModel(n3store);
return (graph.hasTriple(factory.namedNode(shapeUri), SH.DATATYPE, XSD.DATE)
||
graph.hasTriple(factory.namedNode(shapeUri), SH.DATATYPE, XSD.DATE_TIME)
||
graph.hasTriple(factory.namedNode(shapeUri), SH.DATATYPE, XSD.GYEAR));
}));
this.registry.set(SpecialSHACLSpecificationEntityRegistry.SPECIAL_SHACL_ENTITY_LOCATION, new SpecialSHACLSpecificationEntity(SpecialSHACLSpecificationEntityRegistry.SPECIAL_SHACL_ENTITY_LOCATION, "fa-solid fa-map-location-dot", "Location", function (n3store, shapeUri) {
let graph = new StoreModel(n3store);
return graph.hasTriple(factory.namedNode(shapeUri), SH.DATATYPE, GEOSPARQL.WKT_LITERAL);
}));
this.registry.set(SpecialSHACLSpecificationEntityRegistry.SPECIAL_SHACL_ENTITY_TEXT, new SpecialSHACLSpecificationEntity(SpecialSHACLSpecificationEntityRegistry.SPECIAL_SHACL_ENTITY_TEXT, "fa-solid fa-font", "Text", function (n3store, shapeUri) {
let graph = new StoreModel(n3store);
return (graph.hasTriple(factory.namedNode(shapeUri), SH.DATATYPE, XSD.STRING)
||
graph.hasTriple(factory.namedNode(shapeUri), SH.DATATYPE, RDF.LANG_STRING)
||
// no datatype but we know it is a Literal
(graph.hasTriple(factory.namedNode(shapeUri), SH.NODE_KIND, SH.LITERAL)
&&
(!graph.hasTriple(factory.namedNode(shapeUri), SH.DATATYPE, null)
||
(!graph.readSingleProperty(factory.namedNode(shapeUri), SH.DATATYPE)?.value.startsWith("http://www.w3.org/2001/XMLSchema#")
&&
!graph.readSingleProperty(factory.namedNode(shapeUri), SH.DATATYPE)?.value.startsWith("http://www.opengis.net/ont/geosparql#")))));
}));
this.registry.set(SpecialSHACLSpecificationEntityRegistry.SPECIAL_SHACL_ENTITY_NUMBER, new SpecialSHACLSpecificationEntity(SpecialSHACLSpecificationEntityRegistry.SPECIAL_SHACL_ENTITY_NUMBER, "fa-solid fa-1", "Number", function (n3store, shapeUri) {
let graph = new StoreModel(n3store);
return (graph.hasTriple(factory.namedNode(shapeUri), SH.DATATYPE, XSD.BYTE)
||
graph.hasTriple(factory.namedNode(shapeUri), SH.DATATYPE, XSD.DECIMAL)
||
graph.hasTriple(factory.namedNode(shapeUri), SH.DATATYPE, XSD.DOUBLE)
||
graph.hasTriple(factory.namedNode(shapeUri), SH.DATATYPE, XSD.FLOAT)
||
graph.hasTriple(factory.namedNode(shapeUri), SH.DATATYPE, XSD.INT)
||
graph.hasTriple(factory.namedNode(shapeUri), SH.DATATYPE, XSD.INTEGER)
||
graph.hasTriple(factory.namedNode(shapeUri), SH.DATATYPE, XSD.LONG)
||
graph.hasTriple(factory.namedNode(shapeUri), SH.DATATYPE, XSD.NONNEGATIVE_INTEGER)
||
graph.hasTriple(factory.namedNode(shapeUri), SH.DATATYPE, XSD.SHORT)
||
graph.hasTriple(factory.namedNode(shapeUri), SH.DATATYPE, XSD.UNSIGNED_BYTE)
||
graph.hasTriple(factory.namedNode(shapeUri), SH.DATATYPE, XSD.UNSIGNED_INT)
||
graph.hasTriple(factory.namedNode(shapeUri), SH.DATATYPE, XSD.UNSIGNED_LONG)
||
graph.hasTriple(factory.namedNode(shapeUri), SH.DATATYPE, XSD.UNSIGNED_SHORT));
}));
}
/**
* The static method that controls the access to the singleton instance.
*
* This implementation let you subclass the Singleton class while keeping
* just one instance of each subclass around.
*/
static getInstance() {
if (!SpecialSHACLSpecificationEntityRegistry.instance) {
SpecialSHACLSpecificationEntityRegistry.instance = new SpecialSHACLSpecificationEntityRegistry();
}
return SpecialSHACLSpecificationEntityRegistry.instance;
}
getRegistry() {
return this.registry;
}
}
SpecialSHACLSpecificationEntityRegistry.SPECIAL_SHACL_ENTITY_DATES = "http://special/Z_Date";
SpecialSHACLSpecificationEntityRegistry.SPECIAL_SHACL_ENTITY_LOCATION = "http://special/Z_Location";
SpecialSHACLSpecificationEntityRegistry.SPECIAL_SHACL_ENTITY_TEXT = "http://special/Z_Text";
SpecialSHACLSpecificationEntityRegistry.SPECIAL_SHACL_ENTITY_NUMBER = "http://special/Z_Number";
SpecialSHACLSpecificationEntityRegistry.SPECIAL_SHACL_ENTITY_OTHER = "http://special/ZZ_Other";
SpecialSHACLSpecificationEntityRegistry.instance = new SpecialSHACLSpecificationEntityRegistry();
//# sourceMappingURL=SHACLSpecificationEntity.js.map