Skip to content

Commit

Permalink
Xsl utility / Add a function to retrieve thesaurus title with its key (
Browse files Browse the repository at this point in the history
…#8378)

* Xsl utility / Add a function to retrieve thesaurus title with its key

Some schema (eg. DCAT) does not contain thesaurus name in the metadata record. While indexing we add the thesaurus title in the index. This utility function allows to retrieve it with the thesaurus key (eg. external.theme.publisher-type).

* Update core/src/main/java/org/fao/geonet/util/XslUtil.java

Co-authored-by: Jose García <[email protected]>

---------

Co-authored-by: Jose García <[email protected]>
  • Loading branch information
fxprunayre and josegar74 authored Sep 19, 2024
1 parent 74cdf4a commit e77f9d6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions core/src/main/java/org/fao/geonet/util/XslUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -1440,6 +1440,19 @@ public static String getThesaurusIdByTitle(String title) {

return thesaurus == null ? "" : "geonetwork.thesaurus." + thesaurus.getKey();
}

/**
* Retrieve the thesaurus title using the thesaurus key.
*
* @param id the thesaurus key
* @return the thesaurus title or empty string if the thesaurus doesn't exist.
*/
public static String getThesaurusTitleByKey(String id) {
ApplicationContext applicationContext = ApplicationContextHolder.get();
ThesaurusManager thesaurusManager = applicationContext.getBean(ThesaurusManager.class);
Thesaurus thesaurus = thesaurusManager.getThesaurusByName(id);
return thesaurus == null ? "" : thesaurus.getTitle();
}


/**
Expand Down

0 comments on commit e77f9d6

Please sign in to comment.