Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a default vocabulary ID when guessing vocabulary, to save lookups #851

Merged
merged 2 commits into from
Apr 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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