Only shorten URIs of types in the SKOS namespace in the search results #1284
+8
−7
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.
Reasons for creating this PR
See #1254 - some types are not shown correctly in the autocomplete popup for the search box.
The underlying problem is/was that the REST
search
method can return types either in shortened format (e.g.skos:Concept
) or as full URIs (e.g.http://www.yso.fi/onto/yso/yso-meta/Concept
). Those type URIs that can be shortened are, based on the URI namespace prefixes registered to EasyRdf. This includes vocabulary-specific prefixes from the Skosmos configuration file. In the case of Lajisto vocabulary where the problem was first discovered, EasyRdf knows the namespace prefixlajisto:
(which is used for both regular concepts and types) and is able to shorten type URIs into qnames such aslajisto:MX.species
. For most other vocabularies with custom types, the types are in a different namespace, e.g.yso-meta:
for YSO andrdac:
for KANTO/finaf, and EasyRdf doesn't know about these namespaces so cannot shorten these URIs.The JS code that populates the autocomplete box attempts to resolve the shortened URIs and expand them back to full URIs. But the expansion is based on the JSON-LD context of the response of the
search
method. The context doesn't include custom prefixes such aslajisto:
, so expansion will fail and the shortened type URI ends up being displayed in the UI, instead of a human-readable label.There are at least two approaches to fixing this:
search
method returns.I chose the 2nd approach, as it was easier and less disruptive. So instead of eagerly trying to shorten type URIs, the
search
method will now return full type URIs, except for types in the SKOS namespace (i.e.skos:Concept
andskos:Collection
). The SKOS type URIs are still shortened because not doing so could be disruptive for API clients used to the old behaviour.Link to relevant issue(s), if any
Description of the changes in this PR
Known problems or uncertainties in this PR
n/a
Checklist