From 5e5efea33d93f23401e06c14e8fb2de71dc5fe26 Mon Sep 17 00:00:00 2001 From: sgiannopoulos Date: Wed, 26 Jun 2024 17:53:07 +0300 Subject: [PATCH] migration fixes --- .../java/eu/old/eudat/migration/DatasetMigrationService.java | 2 +- .../main/java/eu/old/eudat/migration/DmpMigrationService.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DatasetMigrationService.java b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DatasetMigrationService.java index be391268c..81b2bb01f 100644 --- a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DatasetMigrationService.java +++ b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DatasetMigrationService.java @@ -438,7 +438,7 @@ public class DatasetMigrationService { private FieldEntity buildField(Dataset item, org.opencdmp.commons.types.descriptiontemplate.FieldEntity currentField, Object propertyValue, Map referenceTypeDefinitionEntityMap, Map referenceMap, int ordinal, List createdDescriptionReferenceEntities){ FieldEntity fieldEntity = new FieldEntity(); - String textValue = propertyValue != null ? propertyValue.toString() : null; + String textValue = propertyValue != null ? propertyValue.toString() : null; if (textValue == null || textValue.isEmpty()) return fieldEntity; switch (currentField.getData().getFieldType()){ case FREE_TEXT, TEXT_AREA, RICH_TEXT_AREA, RADIO_BOX -> fieldEntity.setTextValue(textValue.trim()); diff --git a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DmpMigrationService.java b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DmpMigrationService.java index db8dfeadf..4c2e436b3 100644 --- a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DmpMigrationService.java +++ b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DmpMigrationService.java @@ -188,7 +188,8 @@ public class DmpMigrationService { switch (extraFieldEntity.getType()){ case Date -> { try { - valueEntity.setDateValue(Instant.parse((String) val)); + if (((String) val).isBlank()) valueEntity.setDateValue(null); + else valueEntity.setDateValue(Instant.parse((String) val)); } catch (DateTimeParseException ex) { valueEntity.setDateValue(LocalDate.parse((String) val).atStartOfDay().toInstant(ZoneOffset.UTC)); }