-
Notifications
You must be signed in to change notification settings - Fork 95
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
Issue #634 : Retrieve and display domains of ConceptScheme at the top of the tree hierarchy #660
Closed
Closed
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
5c28e7e
Merge remote-tracking branch 'upstream/master'
tfrancart 1cc640d
Necessary updates for #636 and #634 i na single commit
tfrancart 7b7d55e
clean
6bb6ef7
Beautifying code on PHP side
tfrancart 293a433
Beautifying hierarchy.js
tfrancart cdc7dd3
Modified hierarchy.js to : 1/ handle multiple 'tops' value 2/ sort
tfrancart 997482f
Properly set the 'top' key from the 'tops' key in RestController
tfrancart 60d313a
merge
7508813
Merge branch 'skosmosWithDomains-single' of
b7fb35b
Added subject as a key in @context of JSON-LD response
tfrancart 0337e03
Added 'tops' key on the top concepts if vocabulary has showHierarchy to
c8708b0
Merge branch 'skosmosWithDomains-single' of
a5d625b
Added unit test on queryConceptSchemes to test subject retrieval
tfrancart 63d80d4
Fixed test to assert tops (plural) instead of 'opt' (singular)
tfrancart 4caf82b
Deleted wrong test
tfrancart 0f33af3
Merge pull request #4 from NatLibFi/master
tfrancart 96ef242
Merge branch 'skosmos-canope' into skosmosWithDomains-single
tfrancart 38050b3
Updated tests
tfrancart 109b9ea
Merge branch 'skosmosWithDomains-single' of https://github.com/tfranc…
tfrancart File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -200,6 +200,7 @@ public function vocabularyInformation($request) | |
'skos' => 'http://www.w3.org/2004/02/skos/core#', | ||
'onki' => 'http://schema.onki.fi/onki#', | ||
'dct' => 'http://purl.org/dc/terms/', | ||
'dcterms' =>'http://purl.org/dc/terms/', | ||
'uri' => '@id', | ||
'type' => '@type', | ||
'title' => 'rdfs:label', | ||
|
@@ -208,6 +209,7 @@ public function vocabularyInformation($request) | |
'defaultLanguage' => 'onki:defaultLanguage', | ||
'languages' => 'onki:language', | ||
'label' => 'rdfs:label', | ||
'subject' => 'dcterms:subject', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use dct |
||
'prefLabel' => 'skos:prefLabel', | ||
'title' => 'dct:title', | ||
'@language' => $request->getLang(), | ||
|
@@ -254,6 +256,7 @@ public function vocabularyStatistics($request) | |
'void' => 'http://rdfs.org/ns/void#', | ||
'onki' => 'http://schema.onki.fi/onki#', | ||
'uri' => '@id', | ||
'dcterms' =>'http://purl.org/dc/terms/', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto |
||
'id' => 'onki:vocabularyIdentifier', | ||
'concepts' => 'void:classPartition', | ||
'label' => 'rdfs:label', | ||
|
@@ -549,6 +552,7 @@ private function returnDataResults($results, $format) { | |
'dct' => 'http://purl.org/dc/terms/', | ||
'dc11' => 'http://purl.org/dc/elements/1.1/', | ||
'uri' => '@id', | ||
'dcterms' =>'http://purl.org/dc/terms/', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto |
||
'type' => '@type', | ||
'lang' => '@language', | ||
'value' => '@value', | ||
|
@@ -734,6 +738,29 @@ public function hierarchy($request) | |
if (empty($results)) { | ||
return $this->returnError('404', 'Not Found', "Could not find concept <{$request->getUri()}>"); | ||
} | ||
|
||
// set the "top" key from the "tops" key | ||
foreach ($results as $value) { | ||
$uri = $value['uri']; | ||
if (isset($value['tops'])) { | ||
if ($request->getVocab()->getMainConceptScheme() != null) { | ||
foreach ($results[$uri]['tops'] as $top) { | ||
// if a value in 'tops' matches the main concept scheme, take it | ||
if ($top == $request->getVocab()->getMainConceptScheme()) { | ||
$results[$uri]['top'] = $top; | ||
break; | ||
} | ||
} | ||
// if the main concept scheme was not found, set 'top' to the first 'tops' (sorted alphabetically on the URIs) | ||
if (! isset($results[$uri]['top'])) { | ||
$results[$uri]['top'] = $results[$uri]['tops'][0]; | ||
} | ||
} else { | ||
// no main concept scheme set on the vocab, take the first value of 'tops' (sorted alphabetically) | ||
$results[$uri]['top'] = $results[$uri]['tops'][0]; | ||
} | ||
} | ||
} | ||
|
||
if ($request->getVocab()->getConfig()->getShowHierarchy()) { | ||
$schemes = $request->getVocab()->getConceptSchemes($request->getLang()); | ||
|
@@ -743,12 +770,13 @@ public function hierarchy($request) | |
} | ||
|
||
} | ||
|
||
/* encode the results in a JSON-LD compatible array */ | ||
$topconcepts = $request->getVocab()->getTopConcepts(array_keys($schemes), $request->getLang()); | ||
|
||
foreach ($topconcepts as $top) { | ||
if (!isset($results[$top['uri']])) { | ||
$results[$top['uri']] = array('uri' => $top['uri'], 'top' => $top['topConceptOf'], 'prefLabel' => $top['label'], 'hasChildren' => $top['hasChildren']); | ||
$results[$top['uri']] = array('uri' => $top['uri'], 'top'=>$top['topConceptOf'], 'tops'=>array($top['topConceptOf']), 'prefLabel' => $top['label'], 'hasChildren' => $top['hasChildren']); | ||
if (isset($top['notation'])) { | ||
$results[$top['uri']]['notation'] = $top['notation']; | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need to define this prefix?
dct
is defined on the line above, you can just use that.