diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/enums/FieldType.java b/dmp-backend/core/src/main/java/eu/eudat/commons/enums/FieldType.java index 04efa40c0..0c8d40bb9 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/enums/FieldType.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/enums/FieldType.java @@ -6,10 +6,15 @@ import eu.eudat.data.converters.enums.DatabaseEnum; import java.util.Map; public enum FieldType implements DatabaseEnum { - COMBO_BOX("combobox"), + COMBO_BOX("combobox"), //TODO remove from xml an keep subtypes only AUTO_COMPLETE, WORD_LIST + AUTO_COMPLETE("autocomplete"), + WORD_LIST("wordlist"), BOOLEAN_DECISION("booleanDecision"), RADIO_BOX("radiobox"), - INTERNAL_DMP_ENTRIES("internalDmpEntities"), + INTERNAL_DMP_ENTRIES("internalDmpEntities"), //TODO remove from xml an keep subtypes only INTERNAL_DMP_ENTRIES_RESEARCHERS. INTERNAL_DMP_ENTRIES_DMPS, INTERNAL_DMP_ENTRIES_DATASETS + INTERNAL_DMP_ENTRIES_RESEARCHERS("internalDmpResearchers"), + INTERNAL_DMP_ENTRIES_DMPS("internalDmpDmps"), + INTERNAL_DMP_ENTRIES_DATASETS("internalDmpDatasets"), CHECK_BOX("checkBox"), FREE_TEXT("freetext"), TEXT_AREA("textarea"), diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/FieldEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/FieldEntity.java index 9f3ec2064..25635b74c 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/FieldEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/FieldEntity.java @@ -3,8 +3,7 @@ package eu.eudat.commons.types.descriptiontemplate; import eu.eudat.commons.enums.FieldValidationType; import eu.eudat.commons.enums.FieldType; import eu.eudat.commons.types.common.DatabaseViewStyleDefinition; -import eu.eudat.commons.types.descriptiontemplate.fielddata.BaseFieldDataEntity; -import eu.eudat.commons.types.descriptiontemplate.fielddata.FieldDataHelper; +import eu.eudat.commons.types.descriptiontemplate.fielddata.*; import eu.eudat.commons.types.xml.XmlSerializable; import eu.eudat.commons.types.xml.XmlBuilder; import org.w3c.dom.Document; @@ -24,7 +23,6 @@ public class FieldEntity implements DatabaseViewStyleDefinition, XmlSerializable private List visibilityRules; private BaseFieldDataEntity data; private List validations; - private FieldType fieldType; private Boolean includeInExport; public String getId() { @@ -55,14 +53,6 @@ public class FieldEntity implements DatabaseViewStyleDefinition, XmlSerializable this.data = data; } - public FieldType getFieldType() { - return fieldType; - } - - public void setFieldType(FieldType fieldType) { - this.fieldType = fieldType; - } - public String getDefaultValue() { return defaultValue; } @@ -117,8 +107,25 @@ public class FieldEntity implements DatabaseViewStyleDefinition, XmlSerializable } Element viewStyle = doc.createElement("viewStyle"); - viewStyle.setAttribute("renderstyle", this.getFieldType().getValue()); - + if (this.data != null) { + switch (this.data.getFieldType()){ + case COMBO_BOX: + case AUTO_COMPLETE: + case WORD_LIST:{ + viewStyle.setAttribute("renderstyle", FieldType.COMBO_BOX.getValue()); + break; + } + case INTERNAL_DMP_ENTRIES: + case INTERNAL_DMP_ENTRIES_DMPS: + case INTERNAL_DMP_ENTRIES_DATASETS: + case INTERNAL_DMP_ENTRIES_RESEARCHERS:{ + viewStyle.setAttribute("renderstyle", FieldType.INTERNAL_DMP_ENTRIES.getValue()); + break; + } + case BOOLEAN_DECISION: viewStyle.setAttribute("renderstyle", this.data.getFieldType().getValue());; + } + + } Element visibilityRulesElement = doc.createElement("visible"); if (this.visibilityRules != null && !this.visibilityRules.isEmpty()) { for (RuleEntity rule : this.visibilityRules) { @@ -144,7 +151,10 @@ public class FieldEntity implements DatabaseViewStyleDefinition, XmlSerializable rootElement.appendChild(defaultValue); rootElement.appendChild(visibilityRulesElement); rootElement.appendChild(viewStyle); - if (this.data != null) rootElement.appendChild(this.data.toXml(doc)); + if (this.data != null) { + rootElement.appendChild(this.data.toXml(doc)); + + } rootElement.setAttribute("export", this.includeInExport == null || this.includeInExport ? "true" : "false"); return rootElement; } @@ -157,8 +167,8 @@ public class FieldEntity implements DatabaseViewStyleDefinition, XmlSerializable Element viewStyle = (Element) XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "viewStyle"); - this.fieldType = FieldType.of(viewStyle.getAttribute("renderstyle")); - + FieldType fieldType = FieldType.of(viewStyle.getAttribute("renderstyle")); + Element visibility = (Element) XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "visible"); NodeList rulesElements = visibility.getChildNodes(); this.visibilityRules = new LinkedList(); @@ -189,7 +199,7 @@ public class FieldEntity implements DatabaseViewStyleDefinition, XmlSerializable Element defaultValue = (Element) XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "defaultValue"); this.defaultValue = defaultValue.getAttribute("value"); - this.data = new FieldDataHelper().toFieldData(null, this.getFieldType(), dataElement); + this.data = new FieldDataHelper().toFieldData(null, fieldType, dataElement); if (this.data != null) this.data.fromXml(dataElement); this.validations = new LinkedList<>(); diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/FieldSetEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/FieldSetEntity.java index 49ebbb054..7cfd8dd04 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/FieldSetEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/FieldSetEntity.java @@ -22,7 +22,7 @@ public class FieldSetEntity implements DatabaseViewStyleDefinition, XmlSerializa private String additionalInformation; private MultiplicityEntity multiplicity; private boolean hasCommentField; - private String commentFieldValue; //TODO: DescriptionTemplate +// private String commentFieldValue; //TODO: DescriptionTemplate public List getFields() { return fields; diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/AutoCompleteDataEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/AutoCompleteDataEntity.java index ae7213b8f..8c4076222 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/AutoCompleteDataEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/AutoCompleteDataEntity.java @@ -2,6 +2,8 @@ package eu.eudat.commons.types.descriptiontemplate.fielddata; import com.fasterxml.jackson.annotation.JsonValue; import eu.eudat.commons.enums.EnumUtils; +import eu.eudat.commons.enums.FieldDataComboBoxType; +import eu.eudat.commons.enums.FieldType; import eu.eudat.data.converters.enums.DatabaseEnum; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -138,6 +140,16 @@ public class AutoCompleteDataEntity extends ComboBoxDataEntity implements XmlSerializable { private String label; - private String subType; + + public abstract FieldType getFieldType(); public String getLabel() { return label; @@ -18,13 +20,6 @@ public abstract class BaseFieldDataEntity implements XmlSerializable { this.label = label; } - public String getSubType() { - return subType; - } - - public void setSubType(String subType) { - this.subType = subType; - } public T fromData(Object data) { return null; @@ -34,8 +29,17 @@ public abstract class BaseFieldDataEntity implements XmlSerializable { return null; } + public Element toXml(Document doc) { - return null; + Element root = doc.createElement("data"); + root.setAttribute("label", this.getLabel()); + return root; + } + + public T fromXml(Element item) { + + this.setLabel(item.getAttribute("label")); + return (T) this; } public abstract Map toMap(Element item); diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/BooleanDecisionDataEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/BooleanDecisionDataEntity.java index ee37fbcd9..74e008f71 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/BooleanDecisionDataEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/BooleanDecisionDataEntity.java @@ -1,5 +1,6 @@ package eu.eudat.commons.types.descriptiontemplate.fielddata; +import eu.eudat.commons.enums.FieldType; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -8,6 +9,11 @@ import java.util.Map; public class BooleanDecisionDataEntity extends BaseFieldDataEntity { + @Override + public FieldType getFieldType() { + return FieldType.BOOLEAN_DECISION; + } + @Override public BooleanDecisionDataEntity fromData(Object data) { if (data != null) { @@ -21,18 +27,6 @@ public class BooleanDecisionDataEntity extends BaseFieldDataEntity toMap(Element item) { diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/CheckBoxDataEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/CheckBoxDataEntity.java index b6cdb3c04..7c52326c1 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/CheckBoxDataEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/CheckBoxDataEntity.java @@ -1,5 +1,6 @@ package eu.eudat.commons.types.descriptiontemplate.fielddata; +import eu.eudat.commons.enums.FieldType; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -9,18 +10,10 @@ import java.util.Map; public class CheckBoxDataEntity extends BaseFieldDataEntity { @Override - public Element toXml(Document doc) { - Element root = doc.createElement("data"); - root.setAttribute("label", this.getLabel()); - return root; + public FieldType getFieldType() { + return FieldType.CHECK_BOX; } - - @Override - public CheckBoxDataEntity fromXml(Element item) { - this.setLabel(item != null ? item.getAttribute("label") : ""); - return this; - } - + @Override public CheckBoxDataEntity fromData(Object data) { if (data != null) { diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/ComboBoxDataEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/ComboBoxDataEntity.java index 3695a68c9..53ead3180 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/ComboBoxDataEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/ComboBoxDataEntity.java @@ -9,6 +9,9 @@ import java.util.HashMap; import java.util.Map; public abstract class ComboBoxDataEntity extends BaseFieldDataEntity { + + public abstract FieldDataComboBoxType getFieldSubType(); + public static class Option implements XmlSerializable