diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/DefaultValueEntity.java b/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/DefaultValueEntity.java index 98a2dd922..0d9187f37 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/DefaultValueEntity.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/DefaultValueEntity.java @@ -3,19 +3,14 @@ package org.opencdmp.commons.types.descriptiontemplate; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlElementWrapper; import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.opencdmp.commons.xmladapter.InstantXmlAdapter; import java.time.Instant; -import java.util.List; @XmlAccessorType(XmlAccessType.FIELD) public class DefaultValueEntity { - @XmlElementWrapper(name = "textListValues") - @XmlElement(name = "textListValue") - private List textListValue; @XmlElement(name="value") private String textValue; @@ -26,14 +21,6 @@ public class DefaultValueEntity { @XmlElement(name = "booleanValue") private Boolean booleanValue; - public List getTextListValue() { - return this.textListValue; - } - - public void setTextListValue(List textListValue) { - this.textListValue = textListValue; - } - public String getTextValue() { return this.textValue; } diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/RuleEntity.java b/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/RuleEntity.java index 2170d0328..fad185807 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/RuleEntity.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/RuleEntity.java @@ -1,11 +1,13 @@ package org.opencdmp.commons.types.descriptiontemplate; -import jakarta.xml.bind.annotation.*; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.opencdmp.commons.xmladapter.InstantXmlAdapter; import java.time.Instant; -import java.util.List; @XmlAccessorType(XmlAccessType.FIELD) public class RuleEntity { @@ -14,10 +16,6 @@ public class RuleEntity { @XmlAttribute(name="value") private String textValue; - @XmlElementWrapper(name = "textListValues") - @XmlElement(name = "textListValue") - private List textListValue; - @XmlElement(name = "dateValue") @XmlJavaTypeAdapter(InstantXmlAdapter.class) private Instant dateValue; @@ -41,14 +39,6 @@ public class RuleEntity { this.textValue = textValue; } - public List getTextListValue() { - return this.textListValue; - } - - public void setTextListValue(List textListValue) { - this.textListValue = textListValue; - } - public Instant getDateValue() { return this.dateValue; } diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/importexport/DescriptionTemplateDefaultValueImportExport.java b/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/importexport/DescriptionTemplateDefaultValueImportExport.java index b9b0d9388..aeecd30eb 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/importexport/DescriptionTemplateDefaultValueImportExport.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/importexport/DescriptionTemplateDefaultValueImportExport.java @@ -1,21 +1,18 @@ package org.opencdmp.commons.types.descriptiontemplate.importexport; -import jakarta.xml.bind.annotation.*; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.opencdmp.commons.xmladapter.InstantXmlAdapter; import java.time.Instant; -import java.util.List; @XmlAccessorType(XmlAccessType.FIELD) public class DescriptionTemplateDefaultValueImportExport { - @XmlAttribute(name="value") private String textValue; - - @XmlElementWrapper(name = "textListValues") - @XmlElement(name = "textListValue") - private List textListValue; @XmlElement(name = "dateValue") @XmlJavaTypeAdapter(InstantXmlAdapter.class) private Instant dateValue; @@ -31,14 +28,6 @@ public class DescriptionTemplateDefaultValueImportExport { this.textValue = textValue; } - public List getTextListValue() { - return this.textListValue; - } - - public void setTextListValue(List textListValue) { - this.textListValue = textListValue; - } - public Instant getDateValue() { return this.dateValue; } diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/importexport/DescriptionTemplateRuleImportExport.java b/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/importexport/DescriptionTemplateRuleImportExport.java index af8a52329..bf5dafbaa 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/importexport/DescriptionTemplateRuleImportExport.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/importexport/DescriptionTemplateRuleImportExport.java @@ -1,11 +1,13 @@ package org.opencdmp.commons.types.descriptiontemplate.importexport; -import jakarta.xml.bind.annotation.*; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.opencdmp.commons.xmladapter.InstantXmlAdapter; import java.time.Instant; -import java.util.List; @XmlAccessorType(XmlAccessType.FIELD) public class DescriptionTemplateRuleImportExport { @@ -15,9 +17,6 @@ public class DescriptionTemplateRuleImportExport { @XmlAttribute(name="value") private String textValue; - @XmlElementWrapper(name = "textListValues") - @XmlElement(name = "textListValue") - private List textListValue; @XmlElement(name = "dateValue") @XmlJavaTypeAdapter(InstantXmlAdapter.class) private Instant dateValue; @@ -41,14 +40,6 @@ public class DescriptionTemplateRuleImportExport { this.textValue = textValue; } - public List getTextListValue() { - return this.textListValue; - } - - public void setTextListValue(List textListValue) { - this.textListValue = textListValue; - } - public Instant getDateValue() { return this.dateValue; } diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/descriptiontemplatedefinition/DefaultValueBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/descriptiontemplatedefinition/DefaultValueBuilder.java index 4aeaca76a..10007622d 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/descriptiontemplatedefinition/DefaultValueBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/descriptiontemplatedefinition/DefaultValueBuilder.java @@ -53,10 +53,9 @@ public class DefaultValueBuilder extends BaseBuilder models = new ArrayList<>(); for (DefaultValueEntity d : data) { DefaultValue m = new DefaultValue(); - if (fields.hasField(this.asIndexer(DefaultValue._dateValue)) && FieldType.isDateType(fieldType)) m.setDateValue(d.getDateValue()); - if (fields.hasField(this.asIndexer(DefaultValue._booleanValue)) && FieldType.isBooleanType(fieldType)) m.setBooleanValue(d.getBooleanValue()); - if (fields.hasField(this.asIndexer(DefaultValue._textValue)) && FieldType.isTextType(fieldType)) m.setTextValue(d.getTextValue()); - if (fields.hasField(this.asIndexer(DefaultValue._textListValue)) && FieldType.isTextListType(fieldType)) m.setTextListValue(d.getTextListValue()); + if (fields.hasField(this.asIndexer(DefaultValue._dateValue))) m.setDateValue(d.getDateValue()); + if (fields.hasField(this.asIndexer(DefaultValue._booleanValue))) m.setBooleanValue(d.getBooleanValue()); + if (fields.hasField(this.asIndexer(DefaultValue._textValue))) m.setTextValue(d.getTextValue()); models.add(m); } diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/descriptiontemplatedefinition/RuleBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/descriptiontemplatedefinition/RuleBuilder.java index d32cf3618..64b325af3 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/descriptiontemplatedefinition/RuleBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/descriptiontemplatedefinition/RuleBuilder.java @@ -61,10 +61,9 @@ public class RuleBuilder extends BaseBuilder { for (RuleEntity d : data) { Rule m = new Rule(); if (fields.hasField(this.asIndexer(Rule._target))) m.setTarget(d.getTarget()); - if (fields.hasField(this.asIndexer(Rule._dateValue)) && FieldType.isDateType(fieldType)) m.setDateValue(d.getDateValue()); - if (fields.hasField(this.asIndexer(Rule._booleanValue)) && FieldType.isBooleanType(fieldType)) m.setBooleanValue(d.getBooleanValue()); - if (fields.hasField(this.asIndexer(Rule._textValue)) && FieldType.isTextType(fieldType)) m.setTextValue(d.getTextValue()); - if (fields.hasField(this.asIndexer(Rule._textListValue)) && FieldType.isTextListType(fieldType)) m.setTextListValue(d.getTextListValue()); + if (fields.hasField(this.asIndexer(Rule._dateValue))) m.setDateValue(d.getDateValue()); + if (fields.hasField(this.asIndexer(Rule._booleanValue))) m.setBooleanValue(d.getBooleanValue()); + if (fields.hasField(this.asIndexer(Rule._textValue))) m.setTextValue(d.getTextValue()); models.add(m); } this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); diff --git a/backend/core/src/main/java/org/opencdmp/model/descriptiontemplatedefinition/DefaultValue.java b/backend/core/src/main/java/org/opencdmp/model/descriptiontemplatedefinition/DefaultValue.java index 456126472..3adb139fc 100644 --- a/backend/core/src/main/java/org/opencdmp/model/descriptiontemplatedefinition/DefaultValue.java +++ b/backend/core/src/main/java/org/opencdmp/model/descriptiontemplatedefinition/DefaultValue.java @@ -1,16 +1,12 @@ package org.opencdmp.model.descriptiontemplatedefinition; import java.time.Instant; -import java.util.List; public class DefaultValue { private String textValue; public static final String _textValue = "textValue"; - private List textListValue; - public static final String _textListValue = "textListValue"; - private Instant dateValue; public static final String _dateValue = "dateValue"; @@ -26,14 +22,6 @@ public class DefaultValue { this.textValue = textValue; } - public List getTextListValue() { - return this.textListValue; - } - - public void setTextListValue(List textListValue) { - this.textListValue = textListValue; - } - public Instant getDateValue() { return this.dateValue; } diff --git a/backend/core/src/main/java/org/opencdmp/model/descriptiontemplatedefinition/Rule.java b/backend/core/src/main/java/org/opencdmp/model/descriptiontemplatedefinition/Rule.java index 41cf53575..08fc27c52 100644 --- a/backend/core/src/main/java/org/opencdmp/model/descriptiontemplatedefinition/Rule.java +++ b/backend/core/src/main/java/org/opencdmp/model/descriptiontemplatedefinition/Rule.java @@ -1,7 +1,6 @@ package org.opencdmp.model.descriptiontemplatedefinition; import java.time.Instant; -import java.util.List; public class Rule { @@ -11,9 +10,6 @@ public class Rule { private String textValue; public static final String _textValue = "textValue"; - private List textListValue; - public static final String _textListValue = "textListValue"; - private Instant dateValue; public static final String _dateValue = "dateValue"; @@ -36,14 +32,6 @@ public class Rule { this.textValue = textValue; } - public List getTextListValue() { - return this.textListValue; - } - - public void setTextListValue(List textListValue) { - this.textListValue = textListValue; - } - public Instant getDateValue() { return this.dateValue; } diff --git a/backend/core/src/main/java/org/opencdmp/model/mapper/publicapi/DescriptionFieldToDatasetFieldMapper.java b/backend/core/src/main/java/org/opencdmp/model/mapper/publicapi/DescriptionFieldToDatasetFieldMapper.java index 525c7c947..d6969ab3a 100644 --- a/backend/core/src/main/java/org/opencdmp/model/mapper/publicapi/DescriptionFieldToDatasetFieldMapper.java +++ b/backend/core/src/main/java/org/opencdmp/model/mapper/publicapi/DescriptionFieldToDatasetFieldMapper.java @@ -29,7 +29,6 @@ public class DescriptionFieldToDatasetFieldMapper { RuleEntity ruleEntity = new RuleEntity(); ruleEntity.setDateValue(x.getDateValue()); ruleEntity.setBooleanValue(x.getBooleanValue()); - ruleEntity.setTextListValue(x.getTextListValue()); ruleEntity.setTarget(x.getTarget()); return ruleEntity; }).toList()); 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 058a7ba71..5fa6cdca9 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 @@ -18,9 +18,6 @@ public class DefaultValuePersist { private String textValue; public static final String _textValue = "textValue"; - private List textListValue; - public static final String _textListValue = "textListValue"; - private Instant dateValue; public static final String _dateValue = "dateValue"; @@ -35,14 +32,6 @@ public class DefaultValuePersist { this.textValue = textValue; } - public List getTextListValue() { - return this.textListValue; - } - - public void setTextListValue(List textListValue) { - this.textListValue = textListValue; - } - public Instant getDateValue() { return this.dateValue; } diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/descriptiontemplatedefinition/RulePersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/descriptiontemplatedefinition/RulePersist.java index 24540a289..47043c8ea 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/descriptiontemplatedefinition/RulePersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/descriptiontemplatedefinition/RulePersist.java @@ -26,9 +26,6 @@ public class RulePersist { private String textValue; public static final String _textValue = "textValue"; - private List textListValue; - public static final String _textListValue = "textListValue"; - private Instant dateValue; public static final String _dateValue = "dateValue"; @@ -54,14 +51,6 @@ public class RulePersist { this.textValue = textValue; } - public List getTextListValue() { - return this.textListValue; - } - - public void setTextListValue(List textListValue) { - this.textListValue = textListValue; - } - public Instant getDateValue() { return this.dateValue; } @@ -119,10 +108,20 @@ public class RulePersist { this.spec() .must(() -> !this.isEmpty(item.getTarget())) .failOn(RulePersist._target).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{RulePersist._target}, LocaleContextHolder.getLocale())), + this.spec() + .iff(() -> this.isNull(fieldType)) + .must(() -> !FieldType.TAGS.equals(fieldType) && !FieldType.INTERNAL_ENTRIES_DESCRIPTIONS.equals(fieldType) && !FieldType.INTERNAL_ENTRIES_DMPS.equals(fieldType) && + !FieldType.UPLOAD.equals(fieldType) && !FieldType.REFERENCE_TYPES.equals(fieldType) && !FieldType.DATASET_IDENTIFIER.equals(fieldType) + && !FieldType.VALIDATION.equals(fieldType)) + .failOn(RulePersist._target).failWith(this.messageSource.getMessage("Validation_UnexpectedValue", new Object[]{RulePersist._target}, LocaleContextHolder.getLocale())), this.spec() .iff(()-> FieldType.isTextType(fieldType)) .must(() -> !this.isEmpty(item.getTextValue())) .failOn(RulePersist._textValue).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{RulePersist._textValue}, LocaleContextHolder.getLocale())), + this.spec() + .iff(()-> FieldType.isTextListType(fieldType)) + .must(() -> !this.isEmpty(item.getTextValue())) + .failOn(RulePersist._textValue).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{RulePersist._textValue}, LocaleContextHolder.getLocale())), this.spec() .iff(()-> FieldType.isDateType(fieldType)) .must(() -> !this.isNull(item.getDateValue())) @@ -131,18 +130,6 @@ public class RulePersist { .iff(()-> FieldType.isBooleanType(fieldType)) .must(() -> !this.isNull(item.getBooleanValue())) .failOn(RulePersist._booleanValue).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{RulePersist._booleanValue}, LocaleContextHolder.getLocale())), - this.spec() - .iff(()-> FieldType.isTextListType(fieldType)) - .must(() -> !this.isNull(item.getTextListValue())) - .failOn(RulePersist._textListValue).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{RulePersist._textListValue}, LocaleContextHolder.getLocale())), - this.spec() - .iff(()-> FieldType.isReferenceType(fieldType)) - .must(() -> !this.isNull(item.getTextListValue())) - .failOn(RulePersist._textListValue).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{RulePersist._textListValue}, LocaleContextHolder.getLocale())), - this.spec() - .iff(()-> !this.isNull(item.getTextListValue()) && (fieldType.equals(FieldType.INTERNAL_ENTRIES_DMPS) || fieldType.equals(FieldType.INTERNAL_ENTRIES_DESCRIPTIONS))) - .must(() -> item.getTextListValue().stream().allMatch(this::isUUID)) - .failOn(RulePersist._textListValue).failWith(this.messageSource.getMessage("Validation_UnexpectedValue", new Object[]{RulePersist._textListValue}, LocaleContextHolder.getLocale())), this.navSpec() .iff(() -> FieldType.isReferenceType(fieldType) && !this.isListNullOrEmpty(item.getReferences())) .on(RulePersist._references) diff --git a/backend/core/src/main/java/org/opencdmp/model/publicapi/datasetwizard/Rule.java b/backend/core/src/main/java/org/opencdmp/model/publicapi/datasetwizard/Rule.java index 7eda2b043..e7464482e 100644 --- a/backend/core/src/main/java/org/opencdmp/model/publicapi/datasetwizard/Rule.java +++ b/backend/core/src/main/java/org/opencdmp/model/publicapi/datasetwizard/Rule.java @@ -43,10 +43,9 @@ public class Rule { public Rule fromDefinitionRule(RuleEntity rule) { this.targetField = rule.getTarget(); //TODO - if (rule.getTextValue() != null && !rule.getTextListValue().isEmpty()) this.requiredValue = rule.getTextValue(); + if (rule.getTextValue() != null) this.requiredValue = rule.getTextValue(); else if (rule.getDateValue() != null) this.requiredValue = rule.getDateValue().toString(); else if (rule.getBooleanValue() != null) this.requiredValue = rule.getBooleanValue().toString(); - else if (rule.getTextListValue() != null) this.requiredValue = String.join(", ", rule.getTextListValue()); return this; } 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 0c433915d..b98452ba4 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 @@ -394,16 +394,14 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic if (persist == null) return data; data.setTarget(persist.getTarget()); - if (FieldType.isTextType(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.INTERNAL_ENTRIES_DMPS.equals(fieldType) && !this.conventionService.isNullOrEmpty(persist.getTextValue())) throw new NotImplementedException("dmps not supported"); + if (FieldType.INTERNAL_ENTRIES_DESCRIPTIONS.equals(fieldType) && !this.conventionService.isNullOrEmpty(persist.getTextValue())) throw new NotImplementedException("descriptions not supported"); + if (FieldType.TAGS.equals(fieldType) && !this.conventionService.isNullOrEmpty(persist.getTextValue())) throw new NotImplementedException("tags not supported"); + data.setTextValue(persist.getTextValue()); } - else if (FieldType.isTextListType(fieldType)) { - if (FieldType.INTERNAL_ENTRIES_DMPS.equals(fieldType) && !this.conventionService.isListNullOrEmpty(persist.getTextListValue())) throw new NotImplementedException("dmps not supported"); - if (FieldType.INTERNAL_ENTRIES_DESCRIPTIONS.equals(fieldType) && !this.conventionService.isListNullOrEmpty(persist.getTextListValue())) throw new NotImplementedException("descriptions not supported"); - if (FieldType.TAGS.equals(fieldType) && !this.conventionService.isListNullOrEmpty(persist.getTextListValue())) throw new NotImplementedException("tags not supported"); - data.setTextListValue(persist.getTextListValue()); - } else if (FieldType.isReferenceType(fieldType) ) { throw new NotImplementedException("reference not supported"); } @@ -419,16 +417,14 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic DefaultValueEntity data = new DefaultValueEntity(); if (persist == null) return data; - if (FieldType.isTextType(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.INTERNAL_ENTRIES_DMPS.equals(fieldType) && !this.conventionService.isNullOrEmpty(persist.getTextValue())) throw new NotImplementedException("dmps not supported"); + if (FieldType.INTERNAL_ENTRIES_DESCRIPTIONS.equals(fieldType) && !this.conventionService.isNullOrEmpty(persist.getTextValue())) throw new NotImplementedException("descriptions not supported"); + if (FieldType.TAGS.equals(fieldType) && !this.conventionService.isNullOrEmpty(persist.getTextValue())) throw new NotImplementedException("tags not supported"); + data.setTextValue(persist.getTextValue()); } - else if (FieldType.isTextListType(fieldType)) { - if (FieldType.INTERNAL_ENTRIES_DMPS.equals(fieldType) && !this.conventionService.isListNullOrEmpty(persist.getTextListValue())) throw new NotImplementedException("dmps not supported"); - if (FieldType.INTERNAL_ENTRIES_DESCRIPTIONS.equals(fieldType) && !this.conventionService.isListNullOrEmpty(persist.getTextListValue())) throw new NotImplementedException("descriptions not supported"); - if (FieldType.TAGS.equals(fieldType) && !this.conventionService.isListNullOrEmpty(persist.getTextListValue())) throw new NotImplementedException("tags not supported"); - data.setTextListValue(persist.getTextListValue()); - } else if (FieldType.isReferenceType(fieldType) ) { throw new NotImplementedException("reference not supported"); } @@ -876,7 +872,6 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic ruleEntity.setBooleanValue(importExport.getBooleanValue()); //ruleEntity.setReferences(importExport.get()); //TODO ruleEntity.setTextValue(importExport.getTextValue()); - ruleEntity.setTextListValue(importExport.getTextListValue()); return ruleEntity; } @@ -886,7 +881,6 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic ruleEntity.setDateValue(importExport.getDateValue()); ruleEntity.setBooleanValue(importExport.getBooleanValue()); ruleEntity.setTextValue(importExport.getTextValue()); - ruleEntity.setTextListValue(importExport.getTextListValue()); return ruleEntity; } @@ -1036,7 +1030,6 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic DescriptionTemplateDefaultValueImportExport xml = new DescriptionTemplateDefaultValueImportExport(); xml.setDateValue(entity.getDateValue()); xml.setBooleanValue(entity.getBooleanValue()); - xml.setTextListValue(entity.getTextListValue()); xml.setTextValue(entity.getTextValue()); return xml; } @@ -1046,7 +1039,6 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic xml.setTarget(entity.getTarget()); xml.setDateValue(entity.getDateValue()); xml.setBooleanValue(entity.getBooleanValue()); - xml.setTextListValue(entity.getTextListValue()); xml.setTextValue(entity.getTextValue()); return xml; } diff --git a/backend/core/src/main/java/org/opencdmp/service/visibility/RuleWithTarget.java b/backend/core/src/main/java/org/opencdmp/service/visibility/RuleWithTarget.java index 7dd61fbda..b7a961615 100644 --- a/backend/core/src/main/java/org/opencdmp/service/visibility/RuleWithTarget.java +++ b/backend/core/src/main/java/org/opencdmp/service/visibility/RuleWithTarget.java @@ -4,13 +4,11 @@ import org.opencdmp.commons.types.descriptiontemplate.FieldEntity; import org.opencdmp.commons.types.descriptiontemplate.RuleEntity; import java.time.Instant; -import java.util.List; public class RuleWithTarget{ private final String target; private final String source; private final String textValue; - private final List textListValue; private final Instant dateValue; private final Boolean booleanValue; private final FieldEntity fieldEntity; @@ -20,7 +18,6 @@ public class RuleWithTarget{ this.source = source; this.fieldEntity = fieldEntity; this.textValue = rule.getTextValue(); - this.textListValue = rule.getTextListValue(); this.dateValue = rule.getDateValue(); this.booleanValue = rule.getBooleanValue(); } @@ -37,10 +34,6 @@ public class RuleWithTarget{ return this.textValue; } - public List getTextListValue() { - return this.textListValue; - } - public Instant getDateValue() { return this.dateValue; } diff --git a/backend/core/src/main/java/org/opencdmp/service/visibility/VisibilityServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/visibility/VisibilityServiceImpl.java index 08d3e8106..e778c4e30 100644 --- a/backend/core/src/main/java/org/opencdmp/service/visibility/VisibilityServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/visibility/VisibilityServiceImpl.java @@ -1,6 +1,7 @@ package org.opencdmp.service.visibility; import org.apache.commons.lang3.NotImplementedException; +import org.opencdmp.commons.enums.FieldType; import org.opencdmp.commons.types.description.PropertyDefinitionEntity; import org.opencdmp.commons.types.descriptiontemplate.*; import org.opencdmp.model.persist.descriptionproperties.PropertyDefinitionPersist; @@ -347,20 +348,19 @@ public class VisibilityServiceImpl implements VisibilityService { private boolean ruleIsTrue(RuleWithTarget rule, Field field){ if (field != null){ org.opencdmp.commons.enums.FieldType fieldType = rule.getFieldEntity() != null && rule.getFieldEntity().getData() != null ? rule.getFieldEntity().getData().getFieldType() : org.opencdmp.commons.enums.FieldType.FREE_TEXT; - if (org.opencdmp.commons.enums.FieldType.isTextType(fieldType) && field.getTextValue() != null && !field.getTextValue().isBlank()) { - if (org.opencdmp.commons.enums.FieldType.UPLOAD.equals(fieldType)){ - throw new NotImplementedException("Upload file rule not supported"); - } else { - return field.getTextValue().equals(rule.getTextValue()); - } + if ((org.opencdmp.commons.enums.FieldType.isTextType(fieldType) || org.opencdmp.commons.enums.FieldType.isTextListType(fieldType)) && field.getTextValue() != null && !field.getTextValue().isBlank()) { + if (org.opencdmp.commons.enums.FieldType.UPLOAD.equals(fieldType)) throw new NotImplementedException("Upload file rule not supported"); + return field.getTextValue().equals(rule.getTextValue()); } - else if (org.opencdmp.commons.enums.FieldType.isTextListType(fieldType) && field.getTextListValue() != null && !field.getTextListValue().isEmpty()) { - return rule.getTextListValue() != null && - new HashSet<>(field.getTextListValue()).containsAll(rule.getTextListValue()); + else if (rule.getTextValue() != null &&org.opencdmp.commons.enums.FieldType.isTextListType(fieldType) && field.getTextListValue() != null && !field.getTextListValue().isEmpty()) { + if (FieldType.INTERNAL_ENTRIES_DMPS.equals(fieldType)) throw new NotImplementedException("dmps not supported"); + if (FieldType.INTERNAL_ENTRIES_DESCRIPTIONS.equals(fieldType)) throw new NotImplementedException("descriptions not supported"); + if (FieldType.TAGS.equals(fieldType)) throw new NotImplementedException("tags not supported"); + + return new HashSet<>(field.getTextListValue()).contains(rule.getTextValue()); } else if (org.opencdmp.commons.enums.FieldType.isReferenceType(fieldType)) { - return rule.getTextListValue() != null && - new HashSet<>(field.getTextListValue()).containsAll(rule.getTextListValue()); + throw new NotImplementedException("Reference rule not supported"); } else if (org.opencdmp.commons.enums.FieldType.isDateType(fieldType) && field.getDateValue() != null) return field.getDateValue().equals(rule.getDateValue()); else if (org.opencdmp.commons.enums.FieldType.isBooleanType(fieldType) && field.getBooleanValue() != null) return field.getBooleanValue().equals(rule.getBooleanValue()); diff --git a/backend/web/src/main/java/org/opencdmp/controllers/publicapi/PublicDatasetsDescriptionDocumentation.java b/backend/web/src/main/java/org/opencdmp/controllers/publicapi/PublicDatasetsDescriptionDocumentation.java index 045ecd8ef..c766e120c 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/publicapi/PublicDatasetsDescriptionDocumentation.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/publicapi/PublicDatasetsDescriptionDocumentation.java @@ -186,14 +186,12 @@ public class PublicDatasetsDescriptionDocumentation { String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._fields, Field._schematics), String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._fields, Field._defaultValue, DefaultValue._dateValue), String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._fields, Field._defaultValue, DefaultValue._booleanValue), - String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._fields, Field._defaultValue, DefaultValue._textListValue), String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._fields, Field._defaultValue, DefaultValue._textValue), String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._fields, Field._includeInExport), String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._fields, Field._validations), String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._fields, Field._visibilityRules, Rule._target), String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._fields, Field._visibilityRules, Rule._dateValue), String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._fields, Field._visibilityRules, Rule._booleanValue), - String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._fields, Field._visibilityRules, Rule._textListValue), String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._fields, Field._visibilityRules, Rule._textValue), Description._createdAt, Description._updatedAt, diff --git a/dmp-frontend/src/app/core/model/description-template/description-template-persist.ts b/dmp-frontend/src/app/core/model/description-template/description-template-persist.ts index 7500b1559..4658479c9 100644 --- a/dmp-frontend/src/app/core/model/description-template/description-template-persist.ts +++ b/dmp-frontend/src/app/core/model/description-template/description-template-persist.ts @@ -83,7 +83,6 @@ export interface DescriptionTemplateFieldPersist { export interface DescriptionTemplateDefaultValuePersist { textValue: string; - textListValue: string[]; dateValue: Date; booleanValue: boolean; } @@ -91,7 +90,6 @@ export interface DescriptionTemplateDefaultValuePersist { export interface DescriptionTemplateRulePersist { target: string; textValue: string; - textListValue: string[]; dateValue: Date; booleanValue: boolean; } diff --git a/dmp-frontend/src/app/core/model/description-template/description-template.ts b/dmp-frontend/src/app/core/model/description-template/description-template.ts index 3af336f72..ccf163480 100644 --- a/dmp-frontend/src/app/core/model/description-template/description-template.ts +++ b/dmp-frontend/src/app/core/model/description-template/description-template.ts @@ -81,7 +81,6 @@ export interface DescriptionTemplateField { export interface DescriptionTemplateDefaultValue { textValue: string; - textListValue: string[]; dateValue: Date; booleanValue: boolean; } @@ -90,7 +89,6 @@ export interface DescriptionTemplateDefaultValue { export interface DescriptionTemplateRule { target: string; textValue: string; - textListValue: string[]; dateValue: Date; booleanValue: boolean; } diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/default-value/description-template-editor-default-value.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/default-value/description-template-editor-default-value.component.html index 416bd66d0..69a158362 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/default-value/description-template-editor-default-value.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/default-value/description-template-editor-default-value.component.html @@ -30,7 +30,7 @@ {{placeHolder}} - + {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.NONE' | translate }} {{opt.get('label').value}} diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.html index 810837903..512f46532 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.html @@ -134,7 +134,7 @@ -
+
@@ -143,9 +143,6 @@
-
- -
diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.ts index f82c7dc32..cce25cfda 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.ts @@ -112,7 +112,6 @@ export class DescriptionTemplateEditorFieldComponent extends BaseComponent imple field.defaultValue = { booleanValue: null, dateValue: null, - textListValue: null, textValue: null, }; if (!this.canApplyVisibility) { diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/visibility-rule/description-template-editor-visibility-rule.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/visibility-rule/description-template-editor-visibility-rule.component.html index 16316a9e7..5a60847bd 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/visibility-rule/description-template-editor-visibility-rule.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/visibility-rule/description-template-editor-visibility-rule.component.html @@ -1,7 +1,7 @@
{{i + 1}}
-
+
@@ -10,9 +10,6 @@
-
- -
diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.model.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.model.ts index 6b2271352..88f05214b 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.model.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.model.ts @@ -889,7 +889,6 @@ export class DescriptionTemplateFieldEditorModel implements DescriptionTemplateF export class DescriptionTemplateDefaultValueEditorModel implements DescriptionTemplateDefaultValuePersist { target: string; textValue: string; - textListValue: string[]; dateValue: Date; booleanValue: boolean; @@ -902,7 +901,6 @@ export class DescriptionTemplateDefaultValueEditorModel implements DescriptionTe fromModel(item: DescriptionTemplateDefaultValue | DescriptionTemplateDefaultValueEditorModel): DescriptionTemplateDefaultValueEditorModel { if (item) { this.textValue = item.textValue; - this.textListValue = item.textListValue; this.dateValue = item.dateValue; this.booleanValue = item.booleanValue; } @@ -924,7 +922,6 @@ export class DescriptionTemplateDefaultValueEditorModel implements DescriptionTe return this.formBuilder.group({ textValue: [{ value: this.textValue, disabled: disabled }, context.getValidation('textValue').validators], - textListValue: [{ value: this.textListValue, disabled: disabled }, context.getValidation('textListValue').validators], dateValue: [{ value: this.dateValue, disabled: disabled }, context.getValidation('dateValue').validators], booleanValue: [{ value: this.booleanValue, disabled: disabled }, context.getValidation('booleanValue').validators] }); @@ -939,7 +936,6 @@ export class DescriptionTemplateDefaultValueEditorModel implements DescriptionTe const baseContext: ValidationContext = new ValidationContext(); const baseValidationArray: Validation[] = new Array(); baseValidationArray.push({ key: 'textValue', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}textValue`)] }); - baseValidationArray.push({ key: 'textListValue', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}textListValue`)] }); baseValidationArray.push({ key: 'dateValue', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}dateValue`)] }); baseValidationArray.push({ key: 'booleanValue', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}booleanValue`)] }); @@ -959,7 +955,7 @@ export class DescriptionTemplateDefaultValueEditorModel implements DescriptionTe validationErrorModel }); - ['target', 'textValue', 'textListValue', 'dateValue', 'booleanValue'].forEach(keyField => { + ['target', 'textValue', 'dateValue', 'booleanValue'].forEach(keyField => { const control = formGroup?.get(keyField); control?.clearValidators(); control?.addValidators(context.getValidation(keyField).validators); @@ -970,7 +966,6 @@ export class DescriptionTemplateDefaultValueEditorModel implements DescriptionTe export class DescriptionTemplateRuleEditorModel implements DescriptionTemplateRulePersist { target: string; textValue: string; - textListValue: string[]; dateValue: Date; booleanValue: boolean; @@ -984,7 +979,6 @@ export class DescriptionTemplateRuleEditorModel implements DescriptionTemplateRu if (item) { this.target = item.target; this.textValue = item.textValue; - this.textListValue = item.textListValue; this.dateValue = item.dateValue; this.booleanValue = item.booleanValue; } @@ -1007,7 +1001,6 @@ export class DescriptionTemplateRuleEditorModel implements DescriptionTemplateRu return this.formBuilder.group({ target: [{ value: this.target, disabled: disabled }, context.getValidation('target').validators], textValue: [{ value: this.textValue, disabled: disabled }, context.getValidation('textValue').validators], - textListValue: [{ value: this.textListValue, disabled: disabled }, context.getValidation('textListValue').validators], dateValue: [{ value: this.dateValue, disabled: disabled }, context.getValidation('dateValue').validators], booleanValue: [{ value: this.booleanValue, disabled: disabled }, context.getValidation('booleanValue').validators] }); @@ -1023,7 +1016,6 @@ export class DescriptionTemplateRuleEditorModel implements DescriptionTemplateRu const baseValidationArray: Validation[] = new Array(); baseValidationArray.push({ key: 'target', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}target`)] }); baseValidationArray.push({ key: 'textValue', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}textValue`)] }); - baseValidationArray.push({ key: 'textListValue', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}textListValue`)] }); baseValidationArray.push({ key: 'dateValue', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}dateValue`)] }); baseValidationArray.push({ key: 'booleanValue', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}booleanValue`)] }); @@ -1043,7 +1035,7 @@ export class DescriptionTemplateRuleEditorModel implements DescriptionTemplateRu validationErrorModel }); - ['target', 'textValue', 'textListValue', 'dateValue', 'booleanValue'].forEach(keyField => { + ['target', 'textValue', 'dateValue', 'booleanValue'].forEach(keyField => { const control = formGroup?.get(keyField); control?.clearValidators(); control?.addValidators(context.getValidation(keyField).validators); diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.resolver.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.resolver.ts index 67be5b0a3..068863e57 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.resolver.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.resolver.ts @@ -62,7 +62,6 @@ export class DescriptionTemplateEditorResolver extends BaseEditorResolver { [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.numbering)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.schematics)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.defaultValue), nameof(x => x.textValue)].join('.'), - [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.defaultValue), nameof(x => x.textListValue)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.defaultValue), nameof(x => x.dateValue)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.defaultValue), nameof(x => x.booleanValue)].join('.'), // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.fieldType)].join('.'), @@ -71,7 +70,6 @@ export class DescriptionTemplateEditorResolver extends BaseEditorResolver { [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.visibilityRules), nameof(x => x.target)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.visibilityRules), nameof(x => x.textValue)].join('.'), - [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.visibilityRules), nameof(x => x.textListValue)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.visibilityRules), nameof(x => x.dateValue)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.visibilityRules), nameof(x => x.booleanValue)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.label)].join('.'), diff --git a/dmp-frontend/src/app/ui/description/editor/description-editor.model.ts b/dmp-frontend/src/app/ui/description/editor/description-editor.model.ts index 0852d8cef..7c82915c3 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-editor.model.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-editor.model.ts @@ -221,7 +221,7 @@ export class DescriptionPropertyDefinitionEditorModel implements DescriptionProp definitionFieldSet.fields.forEach(definitionField => { fields.set(definitionField.id, { textValue: definitionField.defaultValue ? definitionField.defaultValue.textValue : undefined, - textListValue: definitionField.defaultValue ? definitionField.defaultValue.textListValue : undefined, + textListValue: definitionField.defaultValue && definitionField.defaultValue.textValue && definitionField.defaultValue.textValue.length > 0 ? [definitionField.defaultValue.textValue] : undefined, dateValue: definitionField.defaultValue ? definitionField.defaultValue.dateValue : undefined, booleanValue: definitionField.defaultValue ? definitionField.defaultValue.booleanValue : undefined, externalIdentifier: undefined, diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/models/rule.ts b/dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/models/rule.ts index 4d392ba7f..7e3fbdfc4 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/models/rule.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/models/rule.ts @@ -4,7 +4,6 @@ export class RuleWithTarget { source: string; target: string; textValue: string; - textListValue: string[]; dateValue: Date; booleanValue: boolean; field: DescriptionTemplateField; @@ -14,7 +13,6 @@ export class RuleWithTarget { this.source = source; this.field = fieldEntity; this.textValue = rule.textValue; - this.textListValue = rule.textListValue; this.dateValue = rule.dateValue; this.booleanValue = rule.booleanValue; } diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/visibility-rules.service.ts b/dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/visibility-rules.service.ts index 12b241343..8ebea87e0 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/visibility-rules.service.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/visibility-rules.service.ts @@ -271,28 +271,24 @@ export class VisibilityRulesService { if (field != null){ const fieldType: DescriptionTemplateFieldType = rule.field != null && rule.field.data != null ? rule.field.data.fieldType : DescriptionTemplateFieldType.FREE_TEXT; if ([DescriptionTemplateFieldType.FREE_TEXT, DescriptionTemplateFieldType.RADIO_BOX, DescriptionTemplateFieldType.TEXT_AREA, - DescriptionTemplateFieldType.RICH_TEXT_AREA, DescriptionTemplateFieldType.UPLOAD].includes(fieldType) && field.textValue != null && field.textValue.length > 0) { + DescriptionTemplateFieldType.RICH_TEXT_AREA].includes(fieldType) && field.textValue != null && field.textValue.length > 0) { if (DescriptionTemplateFieldType.UPLOAD == fieldType){ return false; //not apply visibility logic } else { return field.textValue == rule.textValue; } } - else if ([DescriptionTemplateFieldType.SELECT, DescriptionTemplateFieldType.TAGS, DescriptionTemplateFieldType.INTERNAL_ENTRIES_DMPS, - DescriptionTemplateFieldType.INTERNAL_ENTRIES_DESCRIPTIONS].includes(fieldType) && field.textListValue != null && field.textListValue.length > 0) { - return rule.textListValue != null && - rule.textListValue.every(x=> field.textListValue.includes(x)); + else if ([DescriptionTemplateFieldType.SELECT].includes(fieldType) && field.textListValue != null && field.textListValue.length > 0) { + return rule.textValue != null && rule.textValue.length > 0 && field.textListValue.includes(rule.textValue); } - else if (DescriptionTemplateFieldType.REFERENCE_TYPES == fieldType) { + else if ([DescriptionTemplateFieldType.REFERENCE_TYPES, DescriptionTemplateFieldType.UPLOAD, DescriptionTemplateFieldType.TAGS, DescriptionTemplateFieldType.INTERNAL_ENTRIES_DMPS, + DescriptionTemplateFieldType.INTERNAL_ENTRIES_DESCRIPTIONS, DescriptionTemplateFieldType.VALIDATION, DescriptionTemplateFieldType.DATASET_IDENTIFIER].includes(fieldType)) { return false; //not implemented visibility logic } else if ([DescriptionTemplateFieldType.CHECK_BOX, DescriptionTemplateFieldType.BOOLEAN_DECISION].includes(fieldType)) { return field.booleanValue == rule.booleanValue; } else if (DescriptionTemplateFieldType.DATE_PICKER == fieldType && field.dateValue != null) return field.dateValue == rule.dateValue; - else if ([DescriptionTemplateFieldType.VALIDATION, DescriptionTemplateFieldType.DATASET_IDENTIFIER].includes(fieldType) && field.externalIdentifier != null) { - return false; //not implemented visibility logic - } } return false; } diff --git a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DescriptionTemplateXmlMigrationService.java b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DescriptionTemplateXmlMigrationService.java index ac36962d7..3a58464af 100644 --- a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DescriptionTemplateXmlMigrationService.java +++ b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DescriptionTemplateXmlMigrationService.java @@ -434,7 +434,7 @@ public class DescriptionTemplateXmlMigrationService { case SELECT -> { if(!this.conventionService.isNullOrEmpty(textValue)) { String[] valuesParsed = migrationTools.tryParseJsonAsObjectString(String[].class, textValue); - data.setTextListValue(valuesParsed == null ? List.of(textValue) : Arrays.stream(valuesParsed).toList()); + data.setTextValue(valuesParsed != null && valuesParsed.length > 0 ? valuesParsed[0] : null); } } case DATASET_IDENTIFIER, VALIDATION -> { @@ -481,7 +481,7 @@ public class DescriptionTemplateXmlMigrationService { case SELECT -> { if(!this.conventionService.isNullOrEmpty(textValue)) { String[] valuesParsed = migrationTools.tryParseJsonAsObjectString(String[].class, textValue); - data.setTextListValue(valuesParsed == null ? List.of(textValue) : Arrays.stream(valuesParsed).toList()); + data.setTextValue(valuesParsed != null && valuesParsed.length > 0 ? valuesParsed[0] : null); } } case DATASET_IDENTIFIER -> {