Skip to content

Commit

Permalink
Issue #738 replace .inc configuration files by .ttl (turtle) files.
Browse files Browse the repository at this point in the history
The cache that was created in the Model instance, now was moved to the
GlobalConfig, but is still accessed from Model to add entries looked up.

There is no more need of a separate .ttl file for vocabularies, as it is
now part of the configuration file. Old files were removed.

In order to maintain backward compatibility, most methods of GlobalConfig
and of VocabularyConfig were maintained as-is. With internal changes to
re-route requests to the right RDF objects.

Tests were minor updates in tests, but only to replace .inc by .ttl or fix
coverage annotations.
  • Loading branch information
kinow authored and osma committed Jun 4, 2018
1 parent aea8e8f commit 6d28f04
Showing 29 changed files with 712 additions and 454 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
config.inc
config.ttl
vocabularies.ttl
build
vendor
71 changes: 0 additions & 71 deletions config.inc.dist

This file was deleted.

124 changes: 124 additions & 0 deletions config.ttl.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
@prefix void: <http://rdfs.org/ns/void#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix dc: <http://purl.org/dc/terms/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix wv: <http://vocab.org/waiver/terms/norms> .
@prefix sd: <http://www.w3.org/ns/sparql-service-description#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix skosmos: <http://purl.org/net/skosmos#> .
@prefix isothes: <http://purl.org/iso25964/skos-thes#> .
@prefix mdrtype: <http://publications.europa.eu/resource/authority/dataset-type/> .
@prefix : <#> .

# Skosmos main configuration

:config a skosmos:Configuration ;
# SPARQL endpoint
# a local Fuseki server is usually on localhost:3030
skosmos:sparqlEndpoint "http://localhost:3030/ds/sparql" ;
# sparql-query extension, or "Generic" for plain SPARQL 1.1
# set to "JenaText" instead if you use Fuseki with jena-text index
skosmos:sparqlDialect "Generic" ;
# whether to enable collation in sparql queries
skosmos:sparqlCollationEnabled false ;
# HTTP client configuration
skosmos:sparqlTimeout 20 ;
skosmos:httpTimeout 5 ;
# customize the service name
skosmos:serviceName "Skosmos" ;
# customize the base element. Set this if the automatic base url detection doesn't work. For example setups behind a proxy.
# skosmos:baseHref "http://localhost/Skosmos/" ;
# interface languages available, and the corresponding system locales
skosmos:languages [ :name "fi" ; :value "fi_FI.utf8" ] ,
[ :name "sv" ; :value "sv_SE.utf8" ] ,
[ :name "en" ; :value "en_GB.utf8" ] ;
# how many results (maximum) to load at a time on the search results page
skosmos:searchResultsSize 20 ;
# how many items (maximum) to retrieve in transitive property queries
skosmos:transitiveLimit 1000 ;
# whether or not to log caught exceptions
skosmos:logCaughtExceptions false ;
# set to TRUE to enable logging into browser console
skosmos:logBrowserConsole false ;
# set to a logfile path to enable logging into log file
# skosmos:logFileName "" ;
# a default location for Twig template rendering
skosmos:templateCache "/tmp/skosmos-template-cache" ;
# customize the css by adding your own stylesheet
skosmos:customCss "resource/css/stylesheet.css" ;
# default email address where to send the feedback
skosmos:feedbackAddress "" ;
# email address to set as the sender for feedback messages
skosmos:feedbackSender "" ;
# email address to set as the envelope sender for feedback messages
skosmos:feedbackEnvelopeSender "" ;
# whether to display the ui language selection as a dropdown (useful for cases where there are more than 3 languages)
skosmos:uiLanguageDropdown false ;
# whether to enable the spam honey pot or not, enabled by default
skosmos:uiHoneypotEnabled true ;
# default time a user must wait before submitting a form
skosmos:uiHoneypotTime 5 .

# Skosmos vocabularies

:ysa a skosmos:Vocabulary, void:Dataset ;
dc:title "YSA - Yleinen suomalainen asiasanasto"@fi,
"YSA - Allmän tesaurus på finska"@sv,
"YSA - General Finnish thesaurus"@en ;
dc:subject :cat_general ;
dc:type mdrtype:THESAURUS ;
void:uriSpace "http://www.yso.fi/onto/ysa/";
skosmos:groupClass skos:Collection;
skosmos:language "fi";
skosmos:shortName "YSA";
skosmos:feedbackRecipient "vesa-posti@helsinki.fi" ;
skosmos:showChangeList "true" ;
void:dataDump <http://api.finto.fi/download/ysa/ysa-skos.ttl> ;
void:sparqlEndpoint <http://api.dev.finto.fi/sparql> ;
skosmos:sparqlGraph <http://www.yso.fi/onto/ysa/>
.

:yso a skosmos:Vocabulary, void:Dataset ;
dc:title "YSO - Yleinen suomalainen ontologia"@fi,
"ALLFO - Allmän finländsk ontologi"@sv,
"YSO - General Finnish ontology"@en ;
dc:subject :cat_general ;
dc:type mdrtype:ONTOLOGY ;
void:uriSpace "http://www.yso.fi/onto/yso/";
skosmos:language "fi", "sv", "en";
skosmos:defaultLanguage "fi";
skosmos:showTopConcepts "true";
skosmos:showStatistics "false";
skosmos:loadExternalResources "false";
skosmos:shortName "YSO",
"ALLFO"@sv;
skosmos:groupClass isothes:ConceptGroup ;
skosmos:arrayClass isothes:ThesaurusArray ;
void:dataDump <http://api.finto.fi/download/yso/yso-skos.ttl> ;
void:sparqlEndpoint <http://api.dev.finto.fi/sparql> ;
skosmos:sparqlGraph <http://www.yso.fi/onto/yso/> ;
skosmos:mainConceptScheme <http://www.yso.fi/onto/yso/>
.

:categories a skos:ConceptScheme;
skos:prefLabel "Skosmos Vocabulary Categories"@en
.

:cat_general a skos:Concept ;
skos:topConceptOf :categories ;
skos:inScheme :categories ;
skos:prefLabel "Yleiskäsitteet"@fi,
"Allmänna begrepp"@sv,
"General concepts"@en
.

mdrtype:THESAURUS a skos:Concept ;
skos:prefLabel "Тезаурус"@bg, "Tezaurus"@cs, "Tesaurus"@da, "Thesaurus"@de, "Θησαυρός"@el, "Thesaurus"@en, "Tesaurus"@et, "Tesaurus"@fi, "Thésaurus"@fr, "Pojmovnik"@hr, "Tezaurusz"@hu, "Tesauro"@it, "Tēzaurs"@lv, "Tezauras"@lt, "Teżawru"@mt, "Thesaurus"@nl, "Tesaurus"@no, "Tezaurus"@pl, "Tesauro"@pt, "Tezaur"@ro, "Synonymický slovník"@sk, "Tezaver"@sl, "Tesauro"@es, "Tesaurus"@sv
.

mdrtype:ONTOLOGY a skos:Concept ;
skos:prefLabel "Онтология"@bg, "Ontologie"@cs, "Ontologi"@da, "Ontologie"@de, "Οντολογία"@el, "Ontology"@en, "Ontoloogia"@et, "Ontologia"@fi, "Ontologie"@fr, "Ontologija"@hr, "Ontológia"@hu, "Ontologia"@it, "Ontoloģija"@lv, "Ontologija"@lt, "Ontoloġija"@mt, "Ontologie"@nl, "Ontologi"@no, "Struktura pojęciowa"@pl, "Ontologia"@pt, "Ontologie"@ro, "Ontológia"@sk, "Ontologija"@sl, "Ontología"@es, "Ontologi"@sv
.
64 changes: 64 additions & 0 deletions model/BaseConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

/**
* Base class for configurations. Contains methods for accessing RDF
* Resources, handling literals and booleans.
*/
abstract class BaseConfig extends DataObject
{

/**
* Returns a boolean value based on a literal value from the vocabularies.ttl configuration.
* @param string $property the property to query
* @param boolean $default the default value if the value is not set in configuration
*/
protected function getBoolean($property, $default = false)
{
$val = $this->getResource()->getLiteral($property);
if ($val) {
return filter_var($val->getValue(), FILTER_VALIDATE_BOOLEAN);
}
return $default;
}

/**
* Returns an array of URIs based on a property from the vocabularies.ttl configuration.
* @param string $property the property to query
* @return string[] List of URIs
*/
protected function getResources($property)
{
$resources = $this->getResource()->allResources($property);
$ret = array();
foreach ($resources as $res) {
$ret[] = $res->getURI();
}
return $ret;
}

/**
* Returns a boolean value based on a literal value from the vocabularies.ttl configuration.
* @param string $property the property to query
* @param string $default default value
* @param string $lang preferred language for the literal
*/
protected function getLiteral($property, $default=null, $lang=null)
{
if (!isset($lang)) {;
$lang = $this->getEnvLang();
}

$literal = $this->getResource()->getLiteral($property, $lang);
if ($literal) {
return $literal->getValue();
}

// not found with selected language, try any language
$literal = $this->getResource()->getLiteral($property);
if ($literal)
return $literal->getValue();

return $default;
}

}
Loading

0 comments on commit 6d28f04

Please sign in to comment.