From 8fb647b21305e61460193225866e3ad31c7fca35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Prunayre?= Date: Mon, 7 Oct 2024 10:30:49 +0200 Subject: [PATCH] Thesaurus / Date improvements. (#8392) * Thesaurus / Date parsing fix. https://github.com/geonetwork/core-geonetwork/pull/6972/files#diff-c7548d94bdb4268915f50f66df5a90f1f7868e4fb1de2f3d2938397e202aaf2fR1057 added month and year format support. This was resolving thesaurus date to the last matching format ie. 1st January for the default date. This can be tested using regions thesaurus which will contains 2 dates for the thesaurus block. * Thesaurus / Avoid having multiple dates with same type code https://github.com/geonetwork/core-geonetwork/pull/6972 adds retrieval of `dct:issued|modified|created` dates but multiple dates could be added more than one time with same date type code. Improve the mapping. * Thesaurus / INSPIRE registry / Only keep one date to avoid validation errors * Thesaurus / LD registry registry / Only keep one date No need for duplicated date --- .../java/org/fao/geonet/kernel/Thesaurus.java | 11 +- .../convert/thesaurus-transformation.xsl | 135 ++++-------------- .../convert/thesaurus-transformation.xsl | 102 +++---------- .../services/thesaurus/ldregistry-to-skos.xsl | 1 - .../services/thesaurus/registry-to-skos.xsl | 1 - 5 files changed, 52 insertions(+), 198 deletions(-) diff --git a/core/src/main/java/org/fao/geonet/kernel/Thesaurus.java b/core/src/main/java/org/fao/geonet/kernel/Thesaurus.java index efaeaf60a89..91a506b57ab 100644 --- a/core/src/main/java/org/fao/geonet/kernel/Thesaurus.java +++ b/core/src/main/java/org/fao/geonet/kernel/Thesaurus.java @@ -1064,12 +1064,11 @@ private Date parseThesaurusDate(Element dateEl) { StringBuffer errorMsg = new StringBuffer("Error parsing the thesaurus date value: "); errorMsg.append(dateVal); - boolean success = false; for (SimpleDateFormat df : dfList) { try { thesaurusDate = df.parse(dateVal); - success = true; + return thesaurusDate; } catch (Exception ex) { // Ignore the exception and try next format errorMsg.append("\n * with format: "); @@ -1079,11 +1078,9 @@ private Date parseThesaurusDate(Element dateEl) { } } // Report error if no success - if (!success) { - errorMsg.append("\nCheck thesaurus date in "); - errorMsg.append(this.fname); - Log.error(Geonet.THESAURUS_MAN, errorMsg.toString()); - } + errorMsg.append("\nCheck thesaurus date in "); + errorMsg.append(this.fname); + Log.error(Geonet.THESAURUS_MAN, errorMsg.toString()); return thesaurusDate; } diff --git a/schemas/iso19115-3.2018/src/main/plugin/iso19115-3.2018/convert/thesaurus-transformation.xsl b/schemas/iso19115-3.2018/src/main/plugin/iso19115-3.2018/convert/thesaurus-transformation.xsl index 40e13cd3e65..59a02c55f4d 100644 --- a/schemas/iso19115-3.2018/src/main/plugin/iso19115-3.2018/convert/thesaurus-transformation.xsl +++ b/schemas/iso19115-3.2018/src/main/plugin/iso19115-3.2018/convert/thesaurus-transformation.xsl @@ -82,6 +82,12 @@ + + + + + + + + + else $thesaurus/title"/> - + @@ -282,121 +290,30 @@ - - - - + + + + + + - + + - - - - - - - - - - - - + + + + codeList="http://standards.iso.org/iso/19115/resources/Codelists/cat/codelists.xml#CI_DateTypeCode" + codeListValue="{name(current-group()[1])}"/> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/schemas/iso19139/src/main/plugin/iso19139/convert/thesaurus-transformation.xsl b/schemas/iso19139/src/main/plugin/iso19139/convert/thesaurus-transformation.xsl index a27b85bcb18..9e3103d71c4 100644 --- a/schemas/iso19139/src/main/plugin/iso19139/convert/thesaurus-transformation.xsl +++ b/schemas/iso19139/src/main/plugin/iso19139/convert/thesaurus-transformation.xsl @@ -136,6 +136,10 @@ + + + + + + else $thesaurus/title"/> - + @@ -341,95 +347,31 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - - + + - - - - - - - - - - - - + + + + codeListValue="{name(current-group()[1])}"/> - +