Skip to content

Commit

Permalink
adding notations to the hierarchical group view
Browse files Browse the repository at this point in the history
  • Loading branch information
henriyli committed Sep 25, 2015
1 parent 0ca06b3 commit ca9d867
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
12 changes: 9 additions & 3 deletions model/sparql/GenericSparql.php
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,7 @@ public function listConceptGroups($groupClass, $lang)
{
$gc = $this->graphClause;
$query = <<<EOQ
SELECT ?group (GROUP_CONCAT(STR(?child)) as ?children) ?label ?members
SELECT ?group (GROUP_CONCAT(STR(?child)) as ?children) ?label ?members ?notation
WHERE {
$gc {
?group a <$groupClass> .
Expand All @@ -1214,9 +1214,10 @@ public function listConceptGroups($groupClass, $lang)
OPTIONAL { ?group skos:prefLabel ?label }
OPTIONAL { ?group rdfs:label ?label }
FILTER (langMatches(lang(?label), '$lang'))
OPTIONAL { ?group skos:notation ?notation }
}
}
GROUP BY ?group ?label ?members
GROUP BY ?group ?label ?members ?notation
ORDER BY lcase(?label)
EOQ;
$ret = array();
Expand All @@ -1228,6 +1229,8 @@ public function listConceptGroups($groupClass, $lang)
$group['childGroups'] = explode(' ', $row->children->getValue());
if (isset($row->members))
$group['hasMembers'] = $row->members->getValue();
if (isset($row->notation))
$group['notation'] = $row->notation->getValue();
$ret[] = $group;
}
return $ret;
Expand All @@ -1244,7 +1247,7 @@ public function listConceptGroupContents($groupClass, $group, $lang)
{
$gc = $this->graphClause;
$query = <<<EOQ
SELECT ?conc ?super ?label ?members ?type
SELECT ?conc ?super ?label ?members ?type ?notation
WHERE {
$gc {
<$group> a <$groupClass> .
Expand All @@ -1253,6 +1256,7 @@ public function listConceptGroupContents($groupClass, $group, $lang)
?conc skos:prefLabel ?label .
?conc a ?type .
FILTER (langMatches(lang(?label), '$lang'))
OPTIONAL { ?conc skos:notation ?notation }
}
BIND(EXISTS{?submembers isothes:superGroup ?conc} as ?super)
BIND(EXISTS{?conc skos:member ?submembers} as ?members)
Expand All @@ -1270,6 +1274,8 @@ public function listConceptGroupContents($groupClass, $group, $lang)
'hasMembers' => $row->members->getValue(),
'type' => array($row->type->shorten())
);
if (isset($row->notation))
$values[$row->conc->getURI()]['notation'] = $row->notation->getValue();
} else {
$values[$row->conc->getURI()]['type'][] = $row->type->shorten();
}
Expand Down
7 changes: 6 additions & 1 deletion resource/js/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function invokeGroupTree() {

$('.group-hierarchy').jstree({
'plugins' : ['sort'],
'sort' : function (a,b) { return this.get_text(a).toLowerCase() > this.get_text(b).toLowerCase() ? 1 : -1; },
'sort' : function (a,b) { return naturalCompare(this.get_text(a).toLowerCase(), this.get_text(b).toLowerCase()); },
'core' : {
'data' :
function(node, cb) {
Expand All @@ -78,6 +78,9 @@ function invokeGroupTree() {
if (member.hasMembers || member.isSuper) {
child.children = true;
}
if (member.notation) {
child.text = '<span class="tree-notation">' + member.notation + '</span> ' + child.text;
}
if ($.inArray('skos:Collection', member.type) !== -1) {
child.a_attr.class = 'group';
child.a_attr.href = vocab + '/' + lang + '/groups/?uri=' + encodeURIComponent(member.uri);
Expand All @@ -100,6 +103,8 @@ function createGroupNode(uri, groupObject) {
node.text = groupObject.prefLabel;
if (groupObject.hasMembers || groupObject.isSuper) {
node.children = true;
if (groupObject.notation)
node.text = '<span class="tree-notation">' + groupObject.notation + '</span> ' + node.text;
}
return node;
}
Expand Down

0 comments on commit ca9d867

Please sign in to comment.