From 64dea6b4df582b100d0193750d3bb5c4c701a2a5 Mon Sep 17 00:00:00 2001 From: henriyli Date: Thu, 24 Sep 2015 09:30:26 +0300 Subject: [PATCH] adding notations to the children rest method and support for this to the hierarchy view, related to #264 --- model/sparql/GenericSparql.php | 11 ++++++++--- resource/js/hierarchy.js | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/model/sparql/GenericSparql.php b/model/sparql/GenericSparql.php index 5d6a471e0..5c87a4366 100644 --- a/model/sparql/GenericSparql.php +++ b/model/sparql/GenericSparql.php @@ -998,7 +998,7 @@ public function queryChildren($uri, $lang, $fallback) $uri = is_array($uri) ? $uri[0] : $uri; $gc = $this->graphClause; $query = << a skos:Concept . OPTIONAL { @@ -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 ) } } @@ -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 diff --git a/resource/js/hierarchy.js b/resource/js/hierarchy.js index f87a4df8c..2ba2656b4 100644 --- a/resource/js/hierarchy.js +++ b/resource/js/hierarchy.js @@ -218,6 +218,8 @@ function createObjectsFromNarrowers(narrowerResponse) { parents: narrowerResponse.uri, state: { opened: false, disabled: false, selected: false } }; + if (conceptObject.notation) + childObject.text = '' + conceptObject.notation + ' ' + childObject.text; if (hasChildren) { childObject.children = true; childObject.state.opened = false;