Skip to content

Commit

Permalink
adding notations to the children rest method and support for this to …
Browse files Browse the repository at this point in the history
…the hierarchy view, related to #264
  • Loading branch information
henriyli committed Sep 24, 2015
1 parent 8eb5c23 commit 64dea6b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 8 additions & 3 deletions model/sparql/GenericSparql.php
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ public function queryChildren($uri, $lang, $fallback)
$uri = is_array($uri) ? $uri[0] : $uri;
$gc = $this->graphClause;
$query = <<<EOQ
SELECT ?child ?label ?child ?grandchildren WHERE {
SELECT ?child ?label ?child ?grandchildren ?notation WHERE {
$gc {
<$uri> a skos:Concept .
OPTIONAL {
Expand All @@ -1014,6 +1014,9 @@ public function queryChildren($uri, $lang, $fallback)
OPTIONAL { # other language case
?child skos:prefLabel ?label .
}
OPTIONAL {
?child skos:notation ?notation .
}
BIND ( EXISTS { ?child skos:narrower ?a . } AS ?grandchildren )
}
}
Expand All @@ -1032,12 +1035,14 @@ public function queryChildren($uri, $lang, $fallback)
else
$label = $row->label->getValue() . " (" . $row->label->getLang() . ")";
}

$ret[] = array(
$child_array = array(
'uri' => $row->child->getUri(),
'prefLabel' => $label,
'hasChildren' => filter_var($row->grandchildren->getValue(), FILTER_VALIDATE_BOOLEAN),
);
if (isset($row->notation))
$child_array['notation'] = $row->notation->getValue();
$ret[] = $child_array;
}
if (sizeof($ret) > 0)
return $ret; // existing concept, with children
Expand Down
2 changes: 2 additions & 0 deletions resource/js/hierarchy.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ function createObjectsFromNarrowers(narrowerResponse) {
parents: narrowerResponse.uri,
state: { opened: false, disabled: false, selected: false }
};
if (conceptObject.notation)
childObject.text = '<span class="tree-notation">' + conceptObject.notation + '</span> ' + childObject.text;
if (hasChildren) {
childObject.children = true;
childObject.state.opened = false;
Expand Down

0 comments on commit 64dea6b

Please sign in to comment.