Skip to content

Concepts

Femke edited this page Sep 12, 2019 · 2 revisions

Internal Model

The internal model used is based on SHACL in JSON-LD format. An example:

[
  {
    "@id": "AddressShape",
    "https://2019.summerofcode.be/unshacled#path": [
      {
        "@id": "http://example.org/ns#address"
      }
    ],
    "https://2019.summerofcode.be/unshacled#class": [
      {
        "@id": "http://example.org/ns#PostalAddress"
      }
    ]
  },
  {
    "@id": "http://example.org/ns#ClassExampleShape",
    "@type": ["https://2019.summerofcode.be/unshacled#NodeShape"],
    "https://2019.summerofcode.be/unshacled#property": [
      {
        "@id": "AddressShape"
      }
    ],
    "https://2019.summerofcode.be/unshacled#targetNode": [
      {
        "@id": "http://example.org/ns#Bob"
      }
    ]
  }
]

Translation

Existing shape files need to be translated to the internal model before use. This translation consists of two steps:

  1. Parse to JSON-LD: the internal model structure is based on SHACL in JSON-LD format.
  2. Translate SHACL specific terminology to interal terminology.

Parsing and serialization

Classes responsible for parsing or serialization are in src/parsing. Parsing can be done from various formats such as Turtle or N3 to a JSON-LD object via the parserManager which is responsible for assigning a compatible parser. The same holds for the serializerManager which allows to serialize from JSON-LD to other formats.

Convert terminology

Replacing specific terminology with our own is the responsibility of the translatorManager in src/translation e.g. http://www.w3.org/ns/shacl#and becomes https://2019.summerofcode.be/unshacled#and.

Translate between internal uris and SHACL uris. TranslatorManager is responsible for choosing the correct translator e.g. ShaclTranslator translates from and to SHACL.

Translation

Responsible for translating URIs from SHACL or ShEx to URIs used in the model. Translation from and to SHACL uses the shaclTranslator which in turn relies on the shaclDictionary. The translatorManager is responsible for assigning a translation job to the correct translator. Note: makes use of traverse helper function

Validation

Validates RDF data using the shapes in the editor. SHACL data is validated by the shaclValidator which produces a SHACL report. The validatorManager assigns the correct validator to a job. Currently no unified reporting is supported (ShEx and SHACL produce different types of report). Adding such support should be done in the validatorManager by introducing a translation step from SHACL/ShEx report to a unified report.

Util

Contains helper functions used throughout the project.

Dictionaries

extensionToFormat
Returns the corresponding media type for a file extension e.g. "ttl" to "text/turtle".
languages
Contains shape constraint languages such as SHACL and ShEx. Used to ensure no string mismatches happen.
terminology
Contains all existing terms. Classes and predicates such as NodeShape, properties, ...

Konva configuration

Contains all the configuration objects. These are used to determine the colors, position, stroke... in konva figures.

Traverse

traverse(o, func, ...args)
Helper function to traverse over an object and apply a function. Can be used to rename properties of an object or change values of certain properties.

Vocabulary

Contains functions to determine possible options when adding new shapes or constraints.

Vocabulary#isClass(uri)
Returns whether uri is a class.
Vocabulary#isPredicate(uri)
Returns whether uri is a predicate.
Vocabulary#isInDictionary(id)
Returns whether id is a known term. Used to distinguish between model uris and external uris.
Vocabulary#listType(predicate, state)
Returns an array with possible values for @List of predicate
Vocabulary#possiblePredicates(subject)
Returns an array with possible predicates for a given subject.
Vocabulary#possibleObjects(predicate)
Returns an array with possible objects for a given predicate.
Clone this wiki locally