hitontology / database

Schema, diagram and SPARQL import and export of the HITO software product PostgreSQL database.
Creative Commons Zero v1.0 Universal
2 stars 1 forks source link

Import from RDF files #24

Closed KonradHoeffner closed 2 years ago

KonradHoeffner commented 2 years ago

Importing using SPARQL queries used to be adequate but creates problems in a docker-compose setup where the SPARQL endpoint may not be properly initialized yet. Also this requires creating the SQL files at runtime, while using serialized RDF files in a format such as Turtle or NTriples could create the SQL files at build time.

KonradHoeffner commented 2 years ago

Using RDFLib.

Problem: Synonym CVIS not found with the query:

PREFIX dct: <http://purl.org/dc/terms/>
PREFIX dce: <http://purl.org/dc/elements/1.1/>
SELECT
?suffix
(REPLACE(STR(?catalogue),".*/","") AS ?catalogue_suffix)
(STR(SAMPLE(?n)) AS ?n)
(STR(SAMPLE(?label)) AS ?label)
(STR(SAMPLE(?comment)) AS ?comment)
(GROUP_CONCAT(DISTINCT(STR(?synonym));separator="|") AS ?synonyms)
(GROUP_CONCAT(DISTINCT(STR(?dct_source));separator="|") AS ?dct_sources)
(GROUP_CONCAT(DISTINCT(STR(?dce_source));separator="|") AS ?dce_sources)
{
 ?classified ?p ?catalogue;
             rdfs:label ?label.
 FILTER(?classified=<http://hitontology.eu/ontology/BbCardiovascularInformationSystem>) 
 OPTIONAL {?classified rdfs:comment ?comment.}
 OPTIONAL {?classified skos:altLabel ?synonym.}
 OPTIONAL {?classified hito:memberNr ?n.}
 OPTIONAL {?classified dct:source ?dct_source.}
 OPTIONAL {?classified dce:source ?dce_source.}
 ?p rdfs:subPropertyOf hito:catalogue.

 BIND(REPLACE(STR(?classified),".*/","") AS ?suffix)
 FILTER(!STRSTARTS(STR(?suffix),"Unknown")) # We treat UnknownX instances as NULL in DB
}
GROUP BY ?suffix ?catalogue
ORDER BY ASC(?suffix)

Update: Fixed by correcting the SKOS prefix.

KonradHoeffner commented 2 years ago

As HITO is over soon, implementing this is not worth it right now because it would take too much time, would add too much complexity and further causes of errors and synchronization problems with versions of the ontology. Closing as won't fix. Reopen if you find a better solution.