Skip to content

dev guide

Sandra Mierz edited this page Nov 5, 2021 · 3 revisions

The dev guide contains some resources specifically for developers, e.g. how to add a data source or query, how to put variables from code into the query.

Extensible

The software is easily extensible.

Remove a data source

If you are not interested in using one or more of the supplied data sources, just remove the respective folder from src/main/resources/sparqlg and the according controller in the package eu.tib.controller. There are no dependencies between queries of different data sources.

Add a data source

Follow the steps to add a new data source:

  • add a new folder named after your data source under src/main/resources/sparqlg.
  • for every query add a folder and include a sparql-generate-conf.json (its structure is described on the SPARQL-Generate website).
  • add a controller in eu.tib.controller that retrieves your input and calls your query like wrService.execute(queryid, input)
    • queryid contains the path to your sparql-generate-conf.json within the resources folder.
    • input is a Map where you put your input values. Every key-value-pair will be available in your query as a binding, where ?key will be replaced with value.
      .

Query structure

Queries from a data source are typically divided into three steps: source, extraction, vivo-rdf.

  • source: this query only loads data from a source, e.g. via the source command or HTTP GET/POST
  • mapping: this query extracts the relevant properties from the retrieved data and binds them to variables
  • vivo-rdf: this query defines the VIVO objects and puts the extracted properties into the RDF statements

This structure has the following advantages:

  • sometimes a source query can be skipped, if the data was already loaded by a previous query
  • all RDF statements for VIVO are in a central folder and can be reused

Input variables as query bindings

To transfer input variables from a HTTP request / Java code into one of the queries, use the input parameter required by wrService.execute(queryid, input). input is a Map (=set of key-value-pairs). Every key-value-pair will be available in your query as a binding, where ?key will contain the value.

Clone this wiki locally