Skip to content

Commit

Permalink
Added support for scoping vocabularies by skos:inScheme.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Hale committed Nov 9, 2021
1 parent 3ea6c18 commit 36a7511
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 44 deletions.
8 changes: 8 additions & 0 deletions model/GlobalConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,4 +360,12 @@ public function getCollationEnabled()
{
return $this->getBoolean('skosmos:sparqlCollationEnabled', FALSE);
}

/**
* @return boolean
*/
public function getDefaultGraphOnly()
{
return $this->getBoolean('skosmos:defaultGraphOnly', FALSE);
}
}
7 changes: 4 additions & 3 deletions model/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -585,19 +585,20 @@ public function getResourceFromUri($uri)
* @param string $endpoint url address of endpoint
* @param string|null $graph uri for the target graph.
*/
public function getSparqlImplementation($dialect, $endpoint, $graph)
public function getSparqlImplementation($dialect, $endpoint, $graph, $conceptSchemes=null)
{
$classname = $dialect . "Sparql";

return new $classname($endpoint, $graph, $this);
return new $classname($endpoint, $graph, $this, $conceptSchemes);
}

/**
* Returns a SPARQL endpoint object using the default implementation set in the config.ttl.
*/
public function getDefaultSparql()
{
return $this->getSparqlImplementation($this->getConfig()->getDefaultSparqlDialect(), $this->getConfig()->getDefaultEndpoint(), '?graph');
$graph = !$this->getConfig()->getDefaultGraphOnly() ? '?graph' : null;
return $this->getSparqlImplementation($this->getConfig()->getDefaultSparqlDialect(), $this->getConfig()->getDefaultEndpoint(), $graph);
}

}
3 changes: 2 additions & 1 deletion model/Vocabulary.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ public function getSparql()
$endpoint = $this->getEndpoint();
$graph = $this->getGraph();
$dialect = $this->config->getSparqlDialect() ?? $this->model->getConfig()->getDefaultSparqlDialect();
$conceptSchemes = $this->config->getConceptSchemeURIs() ?? null;

return $this->model->getSparqlImplementation($dialect, $endpoint, $graph);
return $this->model->getSparqlImplementation($dialect, $endpoint, $graph, $conceptSchemes);
}

/**
Expand Down
8 changes: 8 additions & 0 deletions model/VocabularyConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,14 @@ public function getDataURLs()
return $ret;
}

/**
* Returns an array of concept schemes to restrict to using skos:inScheme.
*/
public function getConceptSchemeURIs()
{
return $this->getResources("skosmos:conceptSchemes");
}

/**
* Returns the main Concept Scheme URI of that Vocabulary,
* or null if not set.
Expand Down
Loading

0 comments on commit 36a7511

Please sign in to comment.