remove multi value support from rules and default values

This commit is contained in:
Efstratios Giannopoulos 2024-05-02 17:13:59 +03:00
parent 528fbcd758
commit a3fba92999
28 changed files with 63 additions and 202 deletions

View File

@ -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<String> textListValue;
@XmlElement(name="value")
private String textValue;
@ -26,14 +21,6 @@ public class DefaultValueEntity {
@XmlElement(name = "booleanValue")
private Boolean booleanValue;
public List<String> getTextListValue() {
return this.textListValue;
}
public void setTextListValue(List<String> textListValue) {
this.textListValue = textListValue;
}
public String getTextValue() {
return this.textValue;
}

View File

@ -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<String> textListValue;
@XmlElement(name = "dateValue")
@XmlJavaTypeAdapter(InstantXmlAdapter.class)
private Instant dateValue;
@ -41,14 +39,6 @@ public class RuleEntity {
this.textValue = textValue;
}
public List<String> getTextListValue() {
return this.textListValue;
}
public void setTextListValue(List<String> textListValue) {
this.textListValue = textListValue;
}
public Instant getDateValue() {
return this.dateValue;
}

View File

@ -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<String> textListValue;
@XmlElement(name = "dateValue")
@XmlJavaTypeAdapter(InstantXmlAdapter.class)
private Instant dateValue;
@ -31,14 +28,6 @@ public class DescriptionTemplateDefaultValueImportExport {
this.textValue = textValue;
}
public List<String> getTextListValue() {
return this.textListValue;
}
public void setTextListValue(List<String> textListValue) {
this.textListValue = textListValue;
}
public Instant getDateValue() {
return this.dateValue;
}

View File

@ -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<String> textListValue;
@XmlElement(name = "dateValue")
@XmlJavaTypeAdapter(InstantXmlAdapter.class)
private Instant dateValue;
@ -41,14 +40,6 @@ public class DescriptionTemplateRuleImportExport {
this.textValue = textValue;
}
public List<String> getTextListValue() {
return this.textListValue;
}
public void setTextListValue(List<String> textListValue) {
this.textListValue = textListValue;
}
public Instant getDateValue() {
return this.dateValue;
}

View File

@ -53,10 +53,9 @@ public class DefaultValueBuilder extends BaseBuilder<DefaultValue, DefaultValueE
List<DefaultValue> 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);
}

View File

@ -61,10 +61,9 @@ public class RuleBuilder extends BaseBuilder<Rule, RuleEntity> {
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));

View File

@ -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<String> 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<String> getTextListValue() {
return this.textListValue;
}
public void setTextListValue(List<String> textListValue) {
this.textListValue = textListValue;
}
public Instant getDateValue() {
return this.dateValue;
}

View File

@ -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<String> 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<String> getTextListValue() {
return this.textListValue;
}
public void setTextListValue(List<String> textListValue) {
this.textListValue = textListValue;
}
public Instant getDateValue() {
return this.dateValue;
}

View File

@ -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());

View File

@ -18,9 +18,6 @@ public class DefaultValuePersist {
private String textValue;
public static final String _textValue = "textValue";
private List<String> 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<String> getTextListValue() {
return this.textListValue;
}
public void setTextListValue(List<String> textListValue) {
this.textListValue = textListValue;
}
public Instant getDateValue() {
return this.dateValue;
}

View File

@ -26,9 +26,6 @@ public class RulePersist {
private String textValue;
public static final String _textValue = "textValue";
private List<String> 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<String> getTextListValue() {
return this.textListValue;
}
public void setTextListValue(List<String> 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)

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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<String> 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<String> getTextListValue() {
return this.textListValue;
}
public Instant getDateValue() {
return this.dateValue;
}

View File

@ -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());

View File

@ -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,

View File

@ -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;
}

View File

@ -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;
}

View File

@ -30,7 +30,7 @@
<!-- SELECT -->
<mat-form-field class="col-md-12" *ngIf="fieldType === descriptionTemplateFieldTypeEnum.SELECT">
<mat-label>{{placeHolder}}</mat-label>
<mat-select multiple [formControl]="form" [placeholder]="placeHolder">
<mat-select [formControl]="form" [placeholder]="placeHolder">
<mat-option [value]="null">{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.NONE' | translate }}</mat-option>
<mat-option *ngFor="let opt of formArrayOptions['controls']" [value]="opt.get('value').value">{{opt.get('label').value}}</mat-option>
</mat-select>

View File

@ -134,7 +134,7 @@
</div>
<ng-container *ngIf="canSetDefaultValue(form.get('data')?.get('fieldType')?.value)">
<div class="col-6" *ngIf="isTextType(form.get('data')?.get('fieldType')?.value)">
<div class="col-6" *ngIf="isTextType(form.get('data')?.get('fieldType')?.value) || isTextListType(form.get('data')?.get('fieldType')?.value)">
<app-description-template-editor-default-value-component [fieldType]="form.get('data').get('fieldType').value" [form]="this.form.get('defaultValue')?.get('textValue')" [formArrayOptions]="form.get('data')?.get('options')" placeHolder="{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.DEFAULT-VALUE' | translate}}" required="false"></app-description-template-editor-default-value-component>
</div>
<div class="col-6" *ngIf="isDateType(form.get('data')?.get('fieldType')?.value)">
@ -143,9 +143,6 @@
<div class="col-6" *ngIf="isBooleanType(form.get('data')?.get('fieldType')?.value)">
<app-description-template-editor-default-value-component [fieldType]="form.get('data').get('fieldType').value" [form]="this.form.get('defaultValue')?.get('booleanValue')" [formArrayOptions]="form.get('data')?.get('options')" placeHolder="{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.DEFAULT-VALUE' | translate}}" required="false"></app-description-template-editor-default-value-component>
</div>
<div class="col-6" *ngIf="isTextListType(form.get('data')?.get('fieldType')?.value)">
<app-description-template-editor-default-value-component [fieldType]="form.get('data').get('fieldType').value" [form]="this.form.get('defaultValue')?.get('textListValue')" [formArrayOptions]="form.get('data')?.get('options')" placeHolder="{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.DEFAULT-VALUE' | translate}}" required="false"></app-description-template-editor-default-value-component>
</div>
</ng-container>
<div class="col-12"></div>
<div class="col-auto mb-4 mt-2">

View File

@ -112,7 +112,6 @@ export class DescriptionTemplateEditorFieldComponent extends BaseComponent imple
field.defaultValue = {
booleanValue: null,
dateValue: null,
textListValue: null,
textValue: null,
};
if (!this.canApplyVisibility) {

View File

@ -1,7 +1,7 @@
<div class="row align-items-center" *ngFor="let ruleFormGroup of form['controls'] let i=index;" [formGroup]="ruleFormGroup">
<div class="col-auto mb-3"><span>{{i + 1}}</span></div>
<div class="col" *ngIf="isTextType(fieldTypeForCheck)" >
<div class="col" *ngIf="isTextType(fieldTypeForCheck) || isTextListType(fieldTypeForCheck)" >
<app-description-template-editor-default-value-component [fieldType]="fieldTypeForCheck" [form]="ruleFormGroup.get('textValue')" [formArrayOptions]="formArrayOptionsForCheck" placeHolder="{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.RULE.FIELDS.RULE-IF'| translate}}" required="true"></app-description-template-editor-default-value-component>
</div>
<div class="col" *ngIf="isDateType(fieldTypeForCheck)">
@ -10,9 +10,6 @@
<div class="col" *ngIf="isBooleanType(fieldTypeForCheck)">
<app-description-template-editor-default-value-component [fieldType]="fieldTypeForCheck" [form]="ruleFormGroup.get('booleanValue')" [formArrayOptions]="formArrayOptionsForCheck" placeHolder="{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.RULE.FIELDS.RULE-IF'| translate}}" required="true"></app-description-template-editor-default-value-component>
</div>
<div class="col" *ngIf="isTextListType(fieldTypeForCheck)">
<app-description-template-editor-default-value-component [fieldType]="fieldTypeForCheck" [form]="ruleFormGroup.get('textListValue')" [formArrayOptions]="formArrayOptionsForCheck" placeHolder="{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.RULE.FIELDS.RULE-IF'| translate}}" required="true"></app-description-template-editor-default-value-component>
</div>
<!-- SELECTION -->
<div class="col">

View File

@ -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<Validation>();
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<Validation>();
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);

View File

@ -62,7 +62,6 @@ export class DescriptionTemplateEditorResolver extends BaseEditorResolver {
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.numbering)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.schematics)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.defaultValue), nameof<DescriptionTemplateDefaultValue>(x => x.textValue)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.defaultValue), nameof<DescriptionTemplateDefaultValue>(x => x.textListValue)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.defaultValue), nameof<DescriptionTemplateDefaultValue>(x => x.dateValue)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.defaultValue), nameof<DescriptionTemplateDefaultValue>(x => x.booleanValue)].join('.'),
// [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.fieldType)].join('.'),
@ -71,7 +70,6 @@ export class DescriptionTemplateEditorResolver extends BaseEditorResolver {
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.visibilityRules), nameof<DescriptionTemplateRule>(x => x.target)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.visibilityRules), nameof<DescriptionTemplateRule>(x => x.textValue)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.visibilityRules), nameof<DescriptionTemplateRule>(x => x.textListValue)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.visibilityRules), nameof<DescriptionTemplateRule>(x => x.dateValue)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.visibilityRules), nameof<DescriptionTemplateRule>(x => x.booleanValue)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.data), nameof<DescriptionTemplateBaseFieldData>(x => x.label)].join('.'),

View File

@ -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,

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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 -> {