Skip to content

Commit

Permalink
Use a default vocabulary ID when guessing vocabulary, to save lookups…
Browse files Browse the repository at this point in the history
…. Part of #836
  • Loading branch information
osma committed Apr 23, 2019
1 parent f433ab2 commit 50c5e08
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion model/Concept.php
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ public function getProperties()

if (isset($ret[$prop])) {
// checking if the property value is not in the current vocabulary
$exvoc = $this->model->guessVocabularyFromURI($val->getUri());
$exvoc = $this->model->guessVocabularyFromURI($val->getUri(), $this->vocab->getId());
if ($exvoc && $exvoc->getId() !== $this->vocab->getId()) {
$ret[$prop]->addValue(new ConceptMappingPropertyValue($this->model, $this->vocab, $val, $this->resource, $prop, $this->clang), $this->clang);
continue;
Expand Down
13 changes: 7 additions & 6 deletions model/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,24 +237,25 @@ public function searchConcepts($params)

foreach ($results as $hit) {
if (sizeof($vocabs) == 1) {
$hitvoc = $voc;
$hit['vocab'] = $vocabs[0]->getId();
} else {
try {
$voc = $this->getVocabularyByGraph($hit['graph']);
$hit['vocab'] = $voc->getId();
$hitvoc = $this->getVocabularyByGraph($hit['graph']);
$hit['vocab'] = $hitvoc->getId();
} catch (Exception $e) {
trigger_error($e->getMessage(), E_USER_WARNING);
$voc = null;
$hitvoc = null;
$hit['vocab'] = "???";
}
}
unset($hit['graph']);

$hit['voc'] = $voc;
$hit['voc'] = $hitvoc;

// if uri is a external vocab uri that is included in the current vocab
$realvoc = $this->guessVocabularyFromURI($hit['uri']);
if ($realvoc !== $voc) {
$realvoc = $this->guessVocabularyFromURI($hit['uri'], $voc !== null ? $voc->getId() : null);
if ($realvoc != $hitvoc) {
unset($hit['localname']);
$hit['exvocab'] = ($realvoc !== null) ? $realvoc->getId() : "???";
}
Expand Down

0 comments on commit 50c5e08

Please sign in to comment.