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

Editor / Add keywords even if thesaurus not available in record languages #8268

Merged
merged 3 commits into from
Dec 11, 2024

Conversation

fxprunayre
Copy link
Member

Add english as default language for thesaurus searches in order to populate metadata with english label if the thesaurus is not available in the current record language. For example, this can happen when using DCAT-AP related vocabularies only avilable in english that have to be used in Member States records not in english.

Display english label if UI and record language is not available in thesaurus
After/Before
image

Use the english label when encoding the keyword in the metadata (API changes):

http://localhost:8080/geonetwork/srv/api/registries/vocabularies/keyword?thesaurus=external.theme.gemet&id=http:%2F%2Fwww.eionet.europa.eu%2Fgemet%2Fconcept%2F3599,http:%2F%2Fwww.eionet.europa.eu%2Fgemet%2Fconcept%2F15034,http:%2F%2Fwww.eionet.europa.eu%2Fgemet%2Fconcept%2F105,http:%2F%2Fwww.eionet.europa.eu%2Fgemet%2Fconcept%2F10170,http:%2F%2Fwww.eionet.europa.eu%2Fgemet%2Fconcept%2F10140&transformation=to-iso19115-3.2018-keyword-with-anchor&langMap=%7B%22fre%22:%22%23FR%22%7D&lang=fre&textgroupOnly=false
will return keyword in french (if GEMET is loaded with french)

<mri:keyword>
<gcx:Anchor xmlns:gcx="http://standards.iso.org/iso/19115/-3/gcx/1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.eionet.europa.eu/gemet/concept/3599">alimentation en gaz</gcx:Anchor>
</mri:keyword>

but requesting ukrainian will return english terms
http://localhost:8080/geonetwork/srv/api/registries/vocabularies/keyword?thesaurus=external.theme.gemet&id=http:%2F%2Fwww.eionet.europa.eu%2Fgemet%2Fconcept%2F3599,http:%2F%2Fwww.eionet.europa.eu%2Fgemet%2Fconcept%2F15034,http:%2F%2Fwww.eionet.europa.eu%2Fgemet%2Fconcept%2F105,http:%2F%2Fwww.eionet.europa.eu%2Fgemet%2Fconcept%2F10170,http:%2F%2Fwww.eionet.europa.eu%2Fgemet%2Fconcept%2F10140&transformation=to-iso19115-3.2018-keyword-with-anchor&langMap=%7B%22ukr%22:%22%23UK%22%7D&lang=ukr&textgroupOnly=false

<mri:keyword>
<gcx:Anchor xmlns:gcx="http://standards.iso.org/iso/19115/-3/gcx/1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.eionet.europa.eu/gemet/concept/15034">alternative fuel</gcx:Anchor>
</mri:keyword>

This will also avoid the message box when keywords are not found due to language mismatch. The message will still be displayed if a keyword in the metadata is not found in the thesaurus, proposing the user to only keep keywords from the thesaurus.

image

Funded by Service Public de Wallonie

Checklist

  • I have read the contribution guidelines
  • Pull request provided for main branch, backports managed with label
  • Good housekeeping of code, cleaning up comments, tests, and documentation
  • Clean commit history broken into understandable chucks, avoiding big commits with hundreds of files, cautious of reformatting and whitespace changes
  • Clean commit messages, longer verbose messages are encouraged
  • API Changes are identified in commit messages
  • Testing provided for features or enhancements using automatic tests
  • User documentation provided for new features or enhancements in manual
  • Build documentation provided for development instructions in README.md files
  • Library management using pom.xml dependency management. Update build documentation with intended library use and library tutorials or documentation

…ages

Add english as default language for thesaurus searches in order to populate metadata with english label if the thesaurus is not available in the current record language. Can happen with some DCAT-AP related vocabularies that have to be used in Member States records not often in english.

This will also avoid the message box when keywords are not found due to language mismatch. The message will still be displayed if a keyword in the metadata is not found in the thesaurus, proposing the user to only keep keywords from the thesaurus.

Funded by Service Public de Wallonie
@fxprunayre fxprunayre added the api change Indicate a change in the API label Jul 19, 2024
@fxprunayre fxprunayre added this to the 4.4.6 milestone Jul 19, 2024
@fxprunayre fxprunayre requested a review from josegar74 July 19, 2024 08:32
Copy link

sonarcloud bot commented Jul 19, 2024

Copy link
Member

@josegar74 josegar74 left a comment

Choose a reason for hiding this comment

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

A question, this is still as previously. I guess is not cover in the changes, correct?

With a thesaurus having French and English keywords:

  1. With French UI: Create a metadata with French language and adding keywords in French
  2. Switch to English UI: Edit the metadata

I see: Warning! Keywords Conditions atmosphériques, Bâtiments not found in thesaurus.

@@ -501,7 +501,12 @@ private Object getKeyword(
if (langs == null) {
langs = context.getLanguage().split(",");
}
String[] iso3langCodes = Arrays.copyOf(langs, langs.length);
List<String> langList = new ArrayList<>(List.of(langs));
if (!langList.contains("'eng'")) {
Copy link
Member

Choose a reason for hiding this comment

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

Why is checking the string with the single quotes?

@fxprunayre
Copy link
Member Author

A question, this is still as previously. I guess is not cover in the changes, correct?
With a thesaurus having French and English keywords:
With French UI: Create a metadata with French language and adding keywords in French
Switch to English UI: Edit the metadata

Yes, one option to overcome this on the long run would be to only rely on the concept ID but it is only available when Anchor encoding is used so it would not work on all records.

Copy link

sonarcloud bot commented Oct 11, 2024

fxprunayre added a commit to metadata101/dcat-ap that referenced this pull request Oct 22, 2024
…k/core-geonetwork#8268 is useful when language is not available in vocabulary. More generic keyword indexing.
@fxprunayre fxprunayre modified the milestones: 4.4.6, 4.4.7 Oct 24, 2024
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Member

@josegar74 josegar74 left a comment

Choose a reason for hiding this comment

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

@fxprunayre tested and looks working fine. Applied some code improvements to KeywordsApi.

@fxprunayre fxprunayre merged commit 795b153 into main Dec 11, 2024
7 checks passed
@fxprunayre fxprunayre deleted the 44-editorkeywordfallback branch December 11, 2024 11:50
Copy link

sonarcloud bot commented Dec 11, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api change Indicate a change in the API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants