From b5da0cf5e20cf2d496b0f1620e9369cf28567ecc Mon Sep 17 00:00:00 2001 From: WANGF Date: Wed, 5 Apr 2023 10:23:23 -0400 Subject: [PATCH 1/7] add isFileSystemDate flag to thesaurus model --- core/src/main/java/org/fao/geonet/kernel/Thesaurus.java | 7 +++++++ .../main/java/org/fao/geonet/kernel/ThesaurusManager.java | 5 +++++ 2 files changed, 12 insertions(+) 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 5c5ed93ec5a..1eb5fe91bbc 100644 --- a/core/src/main/java/org/fao/geonet/kernel/Thesaurus.java +++ b/core/src/main/java/org/fao/geonet/kernel/Thesaurus.java @@ -99,6 +99,8 @@ public class Thesaurus { private String date; + private boolean isFileSystemDate; + private String defaultNamespace; private String downloadUrl; @@ -258,6 +260,10 @@ public String getDate() { return date; } + public boolean isFileSystemDate() { + return isFileSystemDate; + } + @Nonnull public FileTime getLastModifiedTime() { FileTime lastModified; @@ -996,6 +1002,7 @@ private void retrieveThesaurusInformation(Path thesaurusFile, String defaultTitl } if (this.date == null) { this.date = new ISODate(lastModifiedTime.toMillis(), true).toString(); + this.isFileSystemDate = true; } } diff --git a/core/src/main/java/org/fao/geonet/kernel/ThesaurusManager.java b/core/src/main/java/org/fao/geonet/kernel/ThesaurusManager.java index 62d7a83bcfd..31b3cecfa77 100644 --- a/core/src/main/java/org/fao/geonet/kernel/ThesaurusManager.java +++ b/core/src/main/java/org/fao/geonet/kernel/ThesaurusManager.java @@ -551,6 +551,10 @@ public Element buildResultfromThTable(ServiceContext context) throws SQLExceptio String date = currentTh.getDate(); elDate.addContent(date); + Element elIsFileSystemDate = new Element("isFileSystemDate"); + boolean isFileSystemDate = currentTh.isFileSystemDate(); + elIsFileSystemDate.addContent(Boolean.toString(isFileSystemDate)); + Element elUrl = new Element("url"); String url = currentTh.getDownloadUrl(); elUrl.addContent(url); @@ -568,6 +572,7 @@ public Element buildResultfromThTable(ServiceContext context) throws SQLExceptio elLoop.addContent(elDublinCoreMultilingual); elLoop.addContent(elMultilingualDescriptions); elLoop.addContent(elDate); + elLoop.addContent(elIsFileSystemDate); elLoop.addContent(elUrl); elLoop.addContent(elDefaultURI); elLoop.addContent(elType); From 62b384c9fad79d9d5ff39935a98a28d0ee3e0ddc Mon Sep 17 00:00:00 2001 From: WANGF Date: Fri, 14 Apr 2023 16:30:38 -0400 Subject: [PATCH 2/7] pass thesaurus created, issued, modified date to the schemas. --- .../java/org/fao/geonet/kernel/Thesaurus.java | 39 ++++++++++++++----- .../fao/geonet/kernel/ThesaurusManager.java | 18 +++++++-- 2 files changed, 43 insertions(+), 14 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 1eb5fe91bbc..69e09641422 100644 --- a/core/src/main/java/org/fao/geonet/kernel/Thesaurus.java +++ b/core/src/main/java/org/fao/geonet/kernel/Thesaurus.java @@ -99,7 +99,11 @@ public class Thesaurus { private String date; - private boolean isFileSystemDate; + private String createdDate; + + private String issuedDate; + + private String modifiedDate; private String defaultNamespace; @@ -260,8 +264,16 @@ public String getDate() { return date; } - public boolean isFileSystemDate() { - return isFileSystemDate; + public String getCreatedDate() { + return createdDate; + } + + public String getIssuedDate() { + return issuedDate; + } + + public String getModifiedDate() { + return modifiedDate; } @Nonnull @@ -971,18 +983,26 @@ private void retrieveThesaurusInformation(Path thesaurusFile, String defaultTitl this.defaultNamespace = DEFAULT_THESAURUS_NAMESPACE; } - Element dateEl = Xml.selectElement(thesaurusEl, "skos:ConceptScheme/dcterms:issued|skos:Collection/dc:date", theNSs); + Element issuedDateEl = Xml.selectElement(thesaurusEl, "skos:ConceptScheme/dcterms:issued|skos:Collection/dc:date", theNSs); + DateFormat dateFormatYearOnly = new SimpleDateFormat("yyyy"); + this.issuedDate = dateFormatYearOnly.format(parseThesaurusDate(issuedDateEl)); + + Element modifiedDateEl = Xml.selectElement(thesaurusEl, "skos:ConceptScheme/dcterms:modified", theNSs); + DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + this.modifiedDate = dateFormat.format(parseThesaurusDate(modifiedDateEl)); + + Element createdDateEl = Xml.selectElement(thesaurusEl, "skos:ConceptScheme/dcterms:created", theNSs); + this.createdDate = dateFormat.format(parseThesaurusDate(createdDateEl)); - Date thesaususDate = parseThesaurusDate(dateEl); + // Default date + Date thesaususDate = parseThesaurusDate(issuedDateEl); if (thesaususDate == null) { - dateEl = Xml.selectElement(thesaurusEl, "skos:ConceptScheme/dcterms:modified", theNSs); - thesaususDate = parseThesaurusDate(dateEl); + thesaususDate = parseThesaurusDate(modifiedDateEl); } if (thesaususDate != null) { - DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); - this.date = df.format(thesaususDate); + this.date = dateFormat.format(thesaususDate); } FileTime lastModifiedTime = null; @@ -1002,7 +1022,6 @@ private void retrieveThesaurusInformation(Path thesaurusFile, String defaultTitl } if (this.date == null) { this.date = new ISODate(lastModifiedTime.toMillis(), true).toString(); - this.isFileSystemDate = true; } } diff --git a/core/src/main/java/org/fao/geonet/kernel/ThesaurusManager.java b/core/src/main/java/org/fao/geonet/kernel/ThesaurusManager.java index 31b3cecfa77..a48563dc3d2 100644 --- a/core/src/main/java/org/fao/geonet/kernel/ThesaurusManager.java +++ b/core/src/main/java/org/fao/geonet/kernel/ThesaurusManager.java @@ -551,9 +551,17 @@ public Element buildResultfromThTable(ServiceContext context) throws SQLExceptio String date = currentTh.getDate(); elDate.addContent(date); - Element elIsFileSystemDate = new Element("isFileSystemDate"); - boolean isFileSystemDate = currentTh.isFileSystemDate(); - elIsFileSystemDate.addContent(Boolean.toString(isFileSystemDate)); + Element elCreatedDate = new Element("createdDate"); + String createdDate = currentTh.getCreatedDate(); + elCreatedDate.addContent(createdDate); + + Element elIssuedDate = new Element("issuedDate"); + String issuedDate = currentTh.getIssuedDate(); + elIssuedDate.addContent(issuedDate); + + Element elModifiedDate = new Element("modifiedDate"); + String modifiedDate = currentTh.getModifiedDate(); + elModifiedDate.addContent(modifiedDate); Element elUrl = new Element("url"); String url = currentTh.getDownloadUrl(); @@ -572,7 +580,9 @@ public Element buildResultfromThTable(ServiceContext context) throws SQLExceptio elLoop.addContent(elDublinCoreMultilingual); elLoop.addContent(elMultilingualDescriptions); elLoop.addContent(elDate); - elLoop.addContent(elIsFileSystemDate); + elLoop.addContent(elCreatedDate); + elLoop.addContent(elIssuedDate); + elLoop.addContent(elModifiedDate); elLoop.addContent(elUrl); elLoop.addContent(elDefaultURI); elLoop.addContent(elType); From 20d8015547f1d9bc95a7ab87c04b6d56f2e1c02f Mon Sep 17 00:00:00 2001 From: WANGF Date: Mon, 17 Apr 2023 17:22:23 -0400 Subject: [PATCH 3/7] Fixed null pointer exception. --- core/src/main/java/org/fao/geonet/kernel/Thesaurus.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 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 69e09641422..3bea530d234 100644 --- a/core/src/main/java/org/fao/geonet/kernel/Thesaurus.java +++ b/core/src/main/java/org/fao/geonet/kernel/Thesaurus.java @@ -985,14 +985,17 @@ private void retrieveThesaurusInformation(Path thesaurusFile, String defaultTitl Element issuedDateEl = Xml.selectElement(thesaurusEl, "skos:ConceptScheme/dcterms:issued|skos:Collection/dc:date", theNSs); DateFormat dateFormatYearOnly = new SimpleDateFormat("yyyy"); - this.issuedDate = dateFormatYearOnly.format(parseThesaurusDate(issuedDateEl)); + Date thesaususIssuedDate = parseThesaurusDate(issuedDateEl); + this.issuedDate = thesaususIssuedDate == null? "" : dateFormatYearOnly.format(thesaususIssuedDate); Element modifiedDateEl = Xml.selectElement(thesaurusEl, "skos:ConceptScheme/dcterms:modified", theNSs); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - this.modifiedDate = dateFormat.format(parseThesaurusDate(modifiedDateEl)); + Date thesaususModifiedDate = parseThesaurusDate(modifiedDateEl); + this.modifiedDate = thesaususModifiedDate==null? "" : dateFormat.format(thesaususModifiedDate); Element createdDateEl = Xml.selectElement(thesaurusEl, "skos:ConceptScheme/dcterms:created", theNSs); - this.createdDate = dateFormat.format(parseThesaurusDate(createdDateEl)); + Date thesaususCreatedDate = parseThesaurusDate(createdDateEl); + this.createdDate = thesaususCreatedDate==null? "":dateFormat.format(thesaususCreatedDate); // Default date Date thesaususDate = parseThesaurusDate(issuedDateEl); From 94925ce8d0681884cec61cd92a24b1941d9aad02 Mon Sep 17 00:00:00 2001 From: WANGF Date: Tue, 18 Apr 2023 09:57:58 -0400 Subject: [PATCH 4/7] remove date conversion --- .../main/java/org/fao/geonet/kernel/Thesaurus.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 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 3bea530d234..e41a9465847 100644 --- a/core/src/main/java/org/fao/geonet/kernel/Thesaurus.java +++ b/core/src/main/java/org/fao/geonet/kernel/Thesaurus.java @@ -984,18 +984,13 @@ private void retrieveThesaurusInformation(Path thesaurusFile, String defaultTitl } Element issuedDateEl = Xml.selectElement(thesaurusEl, "skos:ConceptScheme/dcterms:issued|skos:Collection/dc:date", theNSs); - DateFormat dateFormatYearOnly = new SimpleDateFormat("yyyy"); - Date thesaususIssuedDate = parseThesaurusDate(issuedDateEl); - this.issuedDate = thesaususIssuedDate == null? "" : dateFormatYearOnly.format(thesaususIssuedDate); + this.issuedDate = issuedDateEl==null? "": issuedDateEl.getText(); Element modifiedDateEl = Xml.selectElement(thesaurusEl, "skos:ConceptScheme/dcterms:modified", theNSs); - DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - Date thesaususModifiedDate = parseThesaurusDate(modifiedDateEl); - this.modifiedDate = thesaususModifiedDate==null? "" : dateFormat.format(thesaususModifiedDate); + this.modifiedDate = modifiedDateEl==null? "": modifiedDateEl.getText(); Element createdDateEl = Xml.selectElement(thesaurusEl, "skos:ConceptScheme/dcterms:created", theNSs); - Date thesaususCreatedDate = parseThesaurusDate(createdDateEl); - this.createdDate = thesaususCreatedDate==null? "":dateFormat.format(thesaususCreatedDate); + this.createdDate = createdDateEl==null? "": createdDateEl.getText(); // Default date Date thesaususDate = parseThesaurusDate(issuedDateEl); @@ -1005,7 +1000,8 @@ private void retrieveThesaurusInformation(Path thesaurusFile, String defaultTitl } if (thesaususDate != null) { - this.date = dateFormat.format(thesaususDate); + DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + this.date = df.format(thesaususDate); } FileTime lastModifiedTime = null; From 81f171af03ab8f32a93d606c13157764b4388952 Mon Sep 17 00:00:00 2001 From: WANGF Date: Thu, 20 Apr 2023 09:07:32 -0400 Subject: [PATCH 5/7] Revert default thesaurus date to original code --- core/src/main/java/org/fao/geonet/kernel/Thesaurus.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 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 e41a9465847..0192e0b50f4 100644 --- a/core/src/main/java/org/fao/geonet/kernel/Thesaurus.java +++ b/core/src/main/java/org/fao/geonet/kernel/Thesaurus.java @@ -993,10 +993,12 @@ private void retrieveThesaurusInformation(Path thesaurusFile, String defaultTitl this.createdDate = createdDateEl==null? "": createdDateEl.getText(); // Default date - Date thesaususDate = parseThesaurusDate(issuedDateEl); + Element dateEl = Xml.selectElement(thesaurusEl, "skos:ConceptScheme/dcterms:issued|skos:Collection/dc:date", theNSs); + Date thesaususDate = parseThesaurusDate(dateEl); if (thesaususDate == null) { - thesaususDate = parseThesaurusDate(modifiedDateEl); + dateEl = Xml.selectElement(thesaurusEl, "skos:ConceptScheme/dcterms:modified", theNSs); + thesaususDate = parseThesaurusDate(dateEl); } if (thesaususDate != null) { From 955a99a9557603090366effad460fd64d99929eb Mon Sep 17 00:00:00 2001 From: WANGF Date: Fri, 21 Apr 2023 09:32:17 -0400 Subject: [PATCH 6/7] add more dateformat to parsing Thesaurus date --- core/src/main/java/org/fao/geonet/kernel/Thesaurus.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 0192e0b50f4..d9937ed8958 100644 --- a/core/src/main/java/org/fao/geonet/kernel/Thesaurus.java +++ b/core/src/main/java/org/fao/geonet/kernel/Thesaurus.java @@ -983,7 +983,7 @@ private void retrieveThesaurusInformation(Path thesaurusFile, String defaultTitl this.defaultNamespace = DEFAULT_THESAURUS_NAMESPACE; } - Element issuedDateEl = Xml.selectElement(thesaurusEl, "skos:ConceptScheme/dcterms:issued|skos:Collection/dc:date", theNSs); + Element issuedDateEl = Xml.selectElement(thesaurusEl, "skos:ConceptScheme/dcterms:issued", theNSs); this.issuedDate = issuedDateEl==null? "": issuedDateEl.getText(); Element modifiedDateEl = Xml.selectElement(thesaurusEl, "skos:ConceptScheme/dcterms:modified", theNSs); @@ -1054,6 +1054,8 @@ private Date parseThesaurusDate(Element dateEl) { dfList.add(new SimpleDateFormat("EEE MMM d HH:mm:ss z yyyy")); dfList.add(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); dfList.add(new SimpleDateFormat("yyyy-MM-dd")); + dfList.add(new SimpleDateFormat("yyyy-MM")); + dfList.add(new SimpleDateFormat("yyyy")); StringBuffer errorMsg = new StringBuffer("Error parsing the thesaurus date value: "); errorMsg.append(dateVal); From 9f057edd0abcd742a581941c3736431fbac6c5a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Garc=C3=ADa?= Date: Fri, 21 Apr 2023 16:31:46 +0200 Subject: [PATCH 7/7] Update thesaurus-transformation.xsl --- .../convert/thesaurus-transformation.xsl | 87 +++++++++++++++++++ .../convert/thesaurus-transformation.xsl | 71 +++++++++++++-- 2 files changed, 153 insertions(+), 5 deletions(-) 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 69dbdf75dee..bb7004ee347 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 @@ -272,6 +272,12 @@ + + + @@ -299,6 +305,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 12e4e850735..8df2248199b 100644 --- a/schemas/iso19139/src/main/plugin/iso19139/convert/thesaurus-transformation.xsl +++ b/schemas/iso19139/src/main/plugin/iso19139/convert/thesaurus-transformation.xsl @@ -330,20 +330,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - + - + - + @@ -351,7 +412,7 @@ + codeListValue="creation"/>