Skip to content
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

Only shorten URIs of types in the SKOS namespace in the search results #1284

Merged
merged 1 commit into from
Mar 2, 2022

Conversation

osma
Copy link
Member

@osma osma commented Mar 2, 2022

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 prefix lajisto: (which is used for both regular concepts and types) and is able to shorten type URIs into qnames such as lajisto:MX.species. For most other vocabularies with custom types, the types are in a different namespace, e.g. yso-meta: for YSO and rdac: 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 as lajisto:, 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:

  1. Ensure that all prefixes known to EasyRdf are included in the JSON-LD context that the search method returns.
  2. Avoid shortening type URIs which are not defined in the JSON-LD context.

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 and skos: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

  • Shorten only type URIs in the SKOS namespace, instead of in all namespaces known to EasyRdf
  • Modify the tests accordingly

Known problems or uncertainties in this PR

n/a

Checklist

  • phpUnit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if not, explain why below)
  • The PR doesn't introduce unintended code changes (e.g. empty lines or useless reindentation)

@osma osma added the bug label Mar 2, 2022
@osma osma added this to the 2.14 milestone Mar 2, 2022
@osma osma self-assigned this Mar 2, 2022
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 2, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@codecov
Copy link

codecov bot commented Mar 2, 2022

Codecov Report

Merging #1284 (c23e9e5) into master (2896c69) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #1284   +/-   ##
=========================================
  Coverage     69.36%   69.36%           
- Complexity     1649     1650    +1     
=========================================
  Files            32       32           
  Lines          4047     4047           
=========================================
  Hits           2807     2807           
  Misses         1240     1240           
Impacted Files Coverage Δ
model/sparql/GenericSparql.php 92.24% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2896c69...c23e9e5. Read the comment docs.

Copy link
Contributor

@joelit joelit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine now. Strange that the prefixing only had an effect for the property objects but not for the URI of the search results.

@joelit joelit merged commit ed4ad1d into master Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging this pull request may close these issues.

Concept types in the search box are shown as URIs, not labels
2 participants