From 40df26c56084081ebb286138512d0b652547935b Mon Sep 17 00:00:00 2001 From: amentis Date: Thu, 9 May 2024 11:09:51 +0300 Subject: [PATCH] description template build default value fix issue --- .../descriptiontemplatedefinition/DefaultValuePersist.java | 6 ++++++ .../descriptiontemplate/DescriptionTemplateServiceImpl.java | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/descriptiontemplatedefinition/DefaultValuePersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/descriptiontemplatedefinition/DefaultValuePersist.java index 5fa6cdca9..5e70ab236 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/descriptiontemplatedefinition/DefaultValuePersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/descriptiontemplatedefinition/DefaultValuePersist.java @@ -48,6 +48,12 @@ public class DefaultValuePersist { this.booleanValue = booleanValue; } + public Boolean isNullOrEmpty(){ + if ((this.textValue == null || this.textValue.isEmpty()) && this.dateValue == null && this.booleanValue == null) return true; + return false; + } + + @Component(DefaultValuePersistValidator.ValidatorName) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public static class DefaultValuePersistValidator extends BaseValidator { diff --git a/backend/core/src/main/java/org/opencdmp/service/descriptiontemplate/DescriptionTemplateServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/descriptiontemplate/DescriptionTemplateServiceImpl.java index da9b91407..593d08005 100644 --- a/backend/core/src/main/java/org/opencdmp/service/descriptiontemplate/DescriptionTemplateServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/descriptiontemplate/DescriptionTemplateServiceImpl.java @@ -413,7 +413,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic private @NotNull DefaultValueEntity buildDefaultValueEntity(DefaultValuePersist persist, FieldEntity fieldEntity) { FieldType fieldType = fieldEntity != null && fieldEntity.getData() != null ? fieldEntity.getData().getFieldType() : FieldType.FREE_TEXT; DefaultValueEntity data = new DefaultValueEntity(); - if (persist == null) return data; + if (persist == null || persist.isNullOrEmpty()) return data; if (FieldType.isTextType(fieldType) || FieldType.isTextListType(fieldType)) { if (FieldType.UPLOAD.equals(fieldType) && !this.conventionService.isNullOrEmpty(persist.getTextValue())) throw new NotImplementedException("Upload not supported");