migration fixes

This commit is contained in:
Efstratios Giannopoulos 2024-06-26 17:53:07 +03:00
parent c05f9e8fbd
commit 5e5efea33d
2 changed files with 3 additions and 2 deletions

View File

@ -438,7 +438,7 @@ public class DatasetMigrationService {
private FieldEntity buildField(Dataset item, org.opencdmp.commons.types.descriptiontemplate.FieldEntity currentField, Object propertyValue, Map<UUID, ReferenceTypeDefinitionEntity> referenceTypeDefinitionEntityMap, Map<ReferenceKey, ReferenceEntity> referenceMap, int ordinal, List<DescriptionReferenceEntity> createdDescriptionReferenceEntities){ private FieldEntity buildField(Dataset item, org.opencdmp.commons.types.descriptiontemplate.FieldEntity currentField, Object propertyValue, Map<UUID, ReferenceTypeDefinitionEntity> referenceTypeDefinitionEntityMap, Map<ReferenceKey, ReferenceEntity> referenceMap, int ordinal, List<DescriptionReferenceEntity> createdDescriptionReferenceEntities){
FieldEntity fieldEntity = new FieldEntity(); 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; if (textValue == null || textValue.isEmpty()) return fieldEntity;
switch (currentField.getData().getFieldType()){ switch (currentField.getData().getFieldType()){
case FREE_TEXT, TEXT_AREA, RICH_TEXT_AREA, RADIO_BOX -> fieldEntity.setTextValue(textValue.trim()); case FREE_TEXT, TEXT_AREA, RICH_TEXT_AREA, RADIO_BOX -> fieldEntity.setTextValue(textValue.trim());

View File

@ -188,7 +188,8 @@ public class DmpMigrationService {
switch (extraFieldEntity.getType()){ switch (extraFieldEntity.getType()){
case Date -> { case Date -> {
try { try {
valueEntity.setDateValue(Instant.parse((String) val)); if (((String) val).isBlank()) valueEntity.setDateValue(null);
else valueEntity.setDateValue(Instant.parse((String) val));
} catch (DateTimeParseException ex) { } catch (DateTimeParseException ex) {
valueEntity.setDateValue(LocalDate.parse((String) val).atStartOfDay().toInstant(ZoneOffset.UTC)); valueEntity.setDateValue(LocalDate.parse((String) val).atStartOfDay().toInstant(ZoneOffset.UTC));
} }