Skip to content

Triple Store Configuration File Format

Timo edited this page Nov 14, 2022 · 2 revisions

This section describes the triples store JSON configuration file format used by the SPARQLing Unicorn plugin for configuration purposes.

If the user interface cannot add a given triple store, a triple store might be added by modifying the triple store configuration JSON manually.

triplestoreconf.json: This configuration file is delivered on installing the SPARQL Unicorn QGIS plugin. It is not modified and serves as a backup for a possible reset option.

triplestoreconf_personal.json: This configuration file is created the first time the SPARQL Unicorn QGIS plugin is started. All added triple stores would be stored within there in the following format:

{
    "name": "Research Squirrel Engineers Triplestore",
    "prefixes": {
      "geosparql": "http://www.opengis.net/ont/geosparql#",
      "owl": "http://www.w3.org/2002/07/owl#",
      "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
      "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
      "spatial": "http://geovocab.org/spatial#",
      "hw": "http://hadrianswall.squirrel.link/ontology#"
    },
    "endpoint": "http://digits.mainzed.org/squirrels/sparql",
    "mandatoryvariables": [
      "item",
      "geo"
    ],
    "classfromlabelquery": "SELECT DISTINCT ?discovery { ?discovery rdf:type owl:Class . ?discovery rdfs:label ?label . FILTER(CONTAINS(?label,\"%%label%%\"))} LIMIT 100 ",
    "geoconceptquery": "",
    "whattoenrichquery": "SELECT (COUNT(distinct ?con) AS ?countcon) (COUNT(?rel) AS ?countrel) ?rel WHERE { ?con rdf:type %%concept%% . ?con geosparql:hasGeometry ?coord . ?con ?rel ?val . }  GROUP BY ?rel ORDER BY DESC(?countrel)",
    "geoconceptlimit": 500,
    "querytemplate": [
      {
        "label": "10 Random Geometries",
        "query": "SELECT ?item ?geo WHERE {\n ?item a <%%concept%%>.\n ?item geosparql:hasGeometry ?geom_obj .\n ?geom_obj geosparql:asWKT ?geo .\n } LIMIT 10"
      },
      {
        "label": "Hadrian's Wall Forts",
        "query": "SELECT ?a ?wkt_geom WHERE {\n ?item rdf:type hw:Fort .\n ?item geosparql:hasGeometry ?item_geom . ?item_geom geosparql:asWKT ?wkt_geom .\n }"
      }
    ],
    "crs": 4326,
    "staticconcepts": [
      "http://onto.squirrel.link/ontology#Watchtower",
      "http://hadrianswall.squirrel.link/ontology#Milefortlet",
    ],
    "active": true
}

The following configuration options exist:

  • active: Indicates that the triple store is visible in the GUI
  • classlabelquery: A SPARQL query OR a URL that returns a set of labels for a given list of class URIs
  • classfromlabelquery: A query that retrieves a set of classes from a given label (useful for class searches)
  • propertylabelquery: A SPARQL query OR a URL that returns labels for a given list of properties
  • propertyfromlabelquery: A SPARQL query OR a URL that returns properties for a given list of labels
  • crs: The EPSG code of the CRS, which should be used by QGIS to interpret the data received from the triple store
  • endpoint: The address of the SPARQL endpoint of the triple store
  • geoconceptlimit: A reasonable limit to query considering the performance of the triple store and the data included
  • geoconceptquery: A query to retrieve concepts associated with geometrical representations inside the triple store. The results of this query or the content of static concepts constitute the list of concepts that is selectable in the graphical user interface
  • name: The name of the triple store which is displayed in the user interface
  • mandatoryvariables: A list of SPARQL query variables that have to be present in the SELECT statement (usually ?item for the URI and ?geo for the geometry but sometimes also ?lat ?lon instead of ?geo)
  • querytemplate: A list of JSON objects representing labeled queries that may be selectable in the user interface
  • staticconcepts: A list of concepts that are loaded to the dropdown menu of available concepts
  • prefixes: A list of prefixes that is used by the triple store. Each prefix in this list is recognized in the query interface automatically.
  • whattoenrichquery: A query that is sent to the triple store returning attributes and their occurrence frequency for the whattoenrich dialog

The configuration file allows the definition of placeholder variables (currently only %%concept%%) in template queries. These variables are prefixed and suffixed with %% statements. Example:

SELECT ?item ?label ?geo WHERE {
    ?place a <%%concept%%>.
    ?place pleiades:hasLocation ?item .
    ?item geosparql:asWKT ?geo .
    ?item dcterms:title ?label .
} LIMIT 100

This query defines the placeholder variable %%concept%%, which is replaced by the currently selected concept from the dropdown menu in the user interface when a concept is selected.