UNPKG

sparnatural

Version:

Visual client-side SPARQL query builder and knowledge graph exploration tool

68 lines 2.12 kB
import { BaseRdfStore } from "../BaseRdfStore"; import { DataFactory } from 'rdf-data-factory'; import { ShaclModel, ShapeFactory } from "rdf-shacl-commons"; const factory = new DataFactory(); export class SHACLSpecificationEntry extends BaseRdfStore { constructor(uri, provider, n3store, lang) { super(n3store, lang); this.uri = uri; this.provider = provider; this.shape = ShapeFactory.buildShape(factory.namedNode(uri), new ShaclModel(this.store)); } getId() { return this.uri; } getColor() { return this.shape.getVolipiColor(); } getIcon() { return this.shape.getVolipiIconName(); } /** * @returns always return an empty icon. TODO : implement */ getHighlightedIcon() { return ""; } getOrder() { return (this.shape.getShOrder() ? this.shape.getShOrder().value : undefined); } static sort(items) { // sort according to order or label items.sort(SHACLSpecificationEntry.compare); return items; } static compare(item1, item2) { var order1 = item1.getOrder(); var order2 = item2.getOrder(); if (order1) { if (order2) { if (order1 == order2) { return item1.getLabel().localeCompare(item2.getLabel()); } else { // if the order is actually a number, convert it to number and use a number conversion if (!isNaN(Number(order1)) && !isNaN(Number(order2))) { return Number(order1) - Number(order2); } else { return (order1 > order2) ? 1 : -1; } } } else { return -1; } } else { if (order2) { return 1; } else { return item1.getLabel().localeCompare(item2.getLabel()); } } } ; } //# sourceMappingURL=SHACLSpecificationEntry.js.map