From 66acbed8b70ccd3456a2f333299404fb251c22a0 Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Mon, 11 Mar 2024 11:51:31 +0100 Subject: [PATCH] fix: do not save date when the string is emty (#545) * fix: do not save date when the string is emty * fix: review --- .../bauhaus_services/datasets/DatasetServiceImpl.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/insee/rmes/bauhaus_services/datasets/DatasetServiceImpl.java b/src/main/java/fr/insee/rmes/bauhaus_services/datasets/DatasetServiceImpl.java index 9050572a1..33df5ef63 100644 --- a/src/main/java/fr/insee/rmes/bauhaus_services/datasets/DatasetServiceImpl.java +++ b/src/main/java/fr/insee/rmes/bauhaus_services/datasets/DatasetServiceImpl.java @@ -27,6 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; import java.util.ArrayList; import java.util.List; @@ -299,8 +300,14 @@ private void persistStatisticsInformations(IRI datasetIri, Dataset dataset, Mode model.add(node, RDF.TYPE, DCTERMS.PERIOD_OF_TIME, graph); if(dataset.getTemporalCoverageDataType().endsWith("date")){ - model.add(node, DCAT.START_DATE, RdfUtils.setLiteralDate(dataset.getTemporalCoverageStartDate()), graph); - model.add(node, DCAT.END_DATE, RdfUtils.setLiteralDate(dataset.getTemporalCoverageEndDate()), graph); + + if(StringUtils.hasLength(dataset.getTemporalCoverageStartDate())){ + model.add(node, DCAT.START_DATE, RdfUtils.setLiteralDate(dataset.getTemporalCoverageStartDate()), graph); + } + if(StringUtils.hasLength(dataset.getTemporalCoverageEndDate())){ + model.add(node, DCAT.END_DATE, RdfUtils.setLiteralDate(dataset.getTemporalCoverageEndDate()), graph); + } + } else { model.add(node, DCAT.START_DATE, RdfUtils.setLiteralYear(dataset.getTemporalCoverageStartDate()), graph); model.add(node, DCAT.END_DATE, RdfUtils.setLiteralYear(dataset.getTemporalCoverageEndDate()), graph);