description template build default value fix issue

This commit is contained in:
amentis 2024-05-09 11:09:51 +03:00
parent 0dc9a5e856
commit 40df26c560
2 changed files with 7 additions and 1 deletions

View File

@ -48,6 +48,12 @@ public class DefaultValuePersist {
this.booleanValue = booleanValue; 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) @Component(DefaultValuePersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class DefaultValuePersistValidator extends BaseValidator<DefaultValuePersist> { public static class DefaultValuePersistValidator extends BaseValidator<DefaultValuePersist> {

View File

@ -413,7 +413,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
private @NotNull DefaultValueEntity buildDefaultValueEntity(DefaultValuePersist persist, FieldEntity fieldEntity) { private @NotNull DefaultValueEntity buildDefaultValueEntity(DefaultValuePersist persist, FieldEntity fieldEntity) {
FieldType fieldType = fieldEntity != null && fieldEntity.getData() != null ? fieldEntity.getData().getFieldType() : FieldType.FREE_TEXT; FieldType fieldType = fieldEntity != null && fieldEntity.getData() != null ? fieldEntity.getData().getFieldType() : FieldType.FREE_TEXT;
DefaultValueEntity data = new DefaultValueEntity(); 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.isTextType(fieldType) || FieldType.isTextListType(fieldType)) {
if (FieldType.UPLOAD.equals(fieldType) && !this.conventionService.isNullOrEmpty(persist.getTextValue())) throw new NotImplementedException("Upload not supported"); if (FieldType.UPLOAD.equals(fieldType) && !this.conventionService.isNullOrEmpty(persist.getTextValue())) throw new NotImplementedException("Upload not supported");