From c06253bb206225e53a8e84b95456513583c90bbf Mon Sep 17 00:00:00 2001 From: sgiannopoulos Date: Mon, 30 Oct 2023 15:07:59 +0200 Subject: [PATCH] DescriptionTemplate refactor --- .../eu/eudat/commons/enums/FieldType.java | 9 +- .../descriptiontemplate/FieldEntity.java | 44 +++--- .../descriptiontemplate/FieldSetEntity.java | 2 +- .../fielddata/AutoCompleteDataEntity.java | 12 ++ .../fielddata/BaseFieldDataEntity.java | 22 +-- .../fielddata/BooleanDecisionDataEntity.java | 18 +-- .../fielddata/CheckBoxDataEntity.java | 15 +- .../fielddata/ComboBoxDataEntity.java | 20 +-- .../fielddata/CurrencyDataEntity.java | 19 +-- .../fielddata/DataRepositoryDataEntity.java | 11 +- .../DatasetAutoCompleteDataEntity.java | 13 ++ .../DatasetIdentifierDataEntity.java | 18 +-- .../fielddata/DatePickerDataEntity.java | 18 +-- .../fielddata/DmpAutoCompleteDataEntity.java | 11 ++ .../fielddata/ExternalDatasetDataEntity.java | 5 + .../fielddata/FieldDataHelper.java | 6 +- .../fielddata/FreeTextDataEntity.java | 20 +-- .../fielddata/InternalDmpBaseDataEntity.java | 17 +-- .../JournalRepositoryDataEntity.java | 63 ++++++++ .../fielddata/LicenseDataEntity.java | 10 +- .../fielddata/OrganizationDataEntity.java | 10 +- .../fielddata/PublicationDataEntity.java | 10 +- .../PublicationRepositoryDataEntity.java | 63 ++++++++ .../fielddata/RadioBoxDataEntity.java | 12 +- .../fielddata/RegistryDataEntity.java | 10 +- .../ResearcherAutoCompleteDataEntity.java | 12 ++ .../fielddata/ResearcherDataEntity.java | 10 +- .../fielddata/RichTextAreaDataEntity.java | 18 +-- .../fielddata/ServiceDataEntity.java | 10 +- .../fielddata/TagDataEntity.java | 17 +-- .../fielddata/TaxonomyDataEntity.java | 10 +- .../fielddata/TextAreaDataEntity.java | 18 +-- .../fielddata/UploadDataEntity.java | 10 +- .../fielddata/ValidationDataEntity.java | 17 +-- .../fielddata/WordListDataEntity.java | 12 ++ .../FieldBuilder.java | 4 +- .../fielddata/AutoCompleteDataBuilder.java | 5 +- .../fielddata/BaseFieldDataBuilder.java | 1 + .../fielddata/ComboBoxDataBuilder.java | 22 --- .../DatasetAutoCompleteDataBuilder.java | 4 +- .../fielddata/DmpAutoCompleteDataBuilder.java | 5 +- .../fielddata/ExternalDatasetDataBuilder.java | 1 - .../fielddata/InternalDmpBaseDataBuilder.java | 22 --- .../JournalRepositoryDataBuilder.java | 31 ++++ .../PublicationRepositoryDataBuilder.java | 31 ++++ .../ResearcherAutoCompleteDataBuilder.java | 4 +- .../fielddata/WordListDataBuilder.java | 5 +- .../deleter/DescriptionTemplateDeleter.java | 81 +++++++++++ .../descriptiontemplatedefinition/Field.java | 13 +- .../descriptiontemplatedefinition/Page.java | 2 +- .../Section.java | 6 +- .../fielddata/AutoCompleteData.java | 2 +- .../fielddata/BaseFieldData.java | 13 ++ .../fielddata/ComboBoxData.java | 20 --- .../fielddata/DatasetAutoCompleteData.java | 2 +- .../fielddata/DmpAutoCompleteData.java | 2 +- .../fielddata/InternalDmpBaseData.java | 15 -- .../fielddata/JournalRepositoryData.java | 14 ++ .../fielddata/PublicationRepositoryData.java | 14 ++ .../fielddata/ResearcherAutoCompleteData.java | 2 +- .../fielddata/WordListData.java | 2 +- .../persist/DescriptionTemplatePersist.java | 137 ++++++++++++++++++ .../DefinitionPersist.java | 33 +++++ .../FieldPersist.java | 99 +++++++++++++ .../FieldSetPersist.java | 129 +++++++++++++++++ .../MultiplicityPersist.java | 52 +++++++ .../PagePersist.java | 44 ++++++ .../RulePersist.java | 33 +++++ .../SectionPersist.java | 118 +++++++++++++++ .../AuthAutoCompleteDataPersist.java | 66 +++++++++ .../fielddata/AutoCompleteDataPersist.java | 27 ++++ .../AutoCompleteSingleDataPersist.java | 88 +++++++++++ .../fielddata/BaseFieldDataPersist.java | 71 +++++++++ .../fielddata/BooleanDecisionDataPersist.java | 5 + .../fielddata/CheckBoxDataPersist.java | 6 + .../fielddata/ComboBoxOptionPersist.java | 53 +++++++ .../fielddata/CurrencyDataPersist.java | 5 + .../fielddata/DataRepositoryDataPersist.java | 16 ++ .../DatasetAutoCompleteDataPersist.java | 15 ++ .../DatasetIdentifierDataPersist.java | 6 + .../fielddata/DatePickerDataPersist.java | 4 + .../fielddata/DmpAutoCompleteDataPersist.java | 16 ++ .../fielddata/ExternalDatasetDataPersist.java | 29 ++++ .../fielddata/FreeTextDataPersist.java | 4 + .../JournalRepositoryDataPersist.java | 16 ++ .../fielddata/LicenseDataPersist.java | 17 +++ .../fielddata/OrganizationDataPersist.java | 17 +++ .../fielddata/PublicationDataPersist.java | 18 +++ .../PublicationRepositoryDataPersist.java | 16 ++ .../fielddata/RadioBoxDataPersist.java | 21 +++ .../fielddata/RadioBoxOptionPersist.java | 29 ++++ .../fielddata/RegistryDataPersist.java | 18 +++ .../ResearcherAutoCompleteDataPersist.java | 15 ++ .../fielddata/ResearcherDataPersist.java | 18 +++ .../fielddata/RichTextAreaDataPersist.java | 6 + .../fielddata/ServiceDataPersist.java | 17 +++ .../fielddata/TagDataPersist.java | 5 + .../fielddata/TaxonomyDataPersist.java | 18 +++ .../fielddata/TextAreaDataPersist.java | 5 + .../fielddata/UploadDataPersist.java | 34 +++++ .../fielddata/UploadOptionPersist.java | 31 ++++ .../fielddata/ValidationDataPersist.java | 5 + .../fielddata/WordListDataPersist.java | 30 ++++ .../DescriptionTemplateService.java | 20 +++ .../DescriptionTemplateServiceImpl.java | 121 ++++++++++++++++ .../AutoCompleteFieldDataHelperService.java | 59 ++++++++ .../ComboBoxFieldDataHelperService.java | 96 ------------ ...setAutoCompleteFieldDataHelperService.java | 59 ++++++++ ...DmpAutoCompleteFieldDataHelperService.java | 59 ++++++++ .../FieldDataHelperServiceProvider.java | 42 ++++-- ...InternalDmpBaseFieldDataHelperService.java | 100 ------------- ...urnalRepositoryFieldDataHelperService.java | 62 ++++++++ ...ationRepositoryFieldDataHelperService.java | 62 ++++++++ ...herAutoCompleteFieldDataHelperService.java | 59 ++++++++ .../WordListFieldDataHelperService.java | 62 ++++++++ .../main/java/eu/eudat/controllers/Admin.java | 26 ++-- .../v2/DescriptionTemplateController.java | 58 ++++---- .../eu/eudat/logic/managers/AdminManager.java | 14 -- .../utilities/documents/word/WordBuilder.java | 2 +- .../ExportXmlBuilderDatasetProfile.java | 12 +- .../components/datasetprofile/Field.java | 3 +- .../user/components/datasetprofile/Field.java | 3 +- .../src/main/resources/config/permissions.yml | 3 + 123 files changed, 2627 insertions(+), 602 deletions(-) create mode 100644 dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/JournalRepositoryDataEntity.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/PublicationRepositoryDataEntity.java delete mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/builder/descriptiontemplatedefinition/fielddata/ComboBoxDataBuilder.java delete mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/builder/descriptiontemplatedefinition/fielddata/InternalDmpBaseDataBuilder.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/builder/descriptiontemplatedefinition/fielddata/JournalRepositoryDataBuilder.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/builder/descriptiontemplatedefinition/fielddata/PublicationRepositoryDataBuilder.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/deleter/DescriptionTemplateDeleter.java delete mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/descriptiontemplatedefinition/fielddata/ComboBoxData.java delete mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/descriptiontemplatedefinition/fielddata/InternalDmpBaseData.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/descriptiontemplatedefinition/fielddata/JournalRepositoryData.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/descriptiontemplatedefinition/fielddata/PublicationRepositoryData.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionTemplatePersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/DefinitionPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/FieldPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/FieldSetPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/MultiplicityPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/PagePersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/RulePersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/SectionPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/AuthAutoCompleteDataPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/AutoCompleteDataPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/AutoCompleteSingleDataPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/BaseFieldDataPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/BooleanDecisionDataPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/CheckBoxDataPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/ComboBoxOptionPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/CurrencyDataPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/DataRepositoryDataPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/DatasetAutoCompleteDataPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/DatasetIdentifierDataPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/DatePickerDataPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/DmpAutoCompleteDataPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/ExternalDatasetDataPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/FreeTextDataPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/JournalRepositoryDataPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/LicenseDataPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/OrganizationDataPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/PublicationDataPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/PublicationRepositoryDataPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/RadioBoxDataPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/RadioBoxOptionPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/RegistryDataPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/ResearcherAutoCompleteDataPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/ResearcherDataPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/RichTextAreaDataPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/ServiceDataPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/TagDataPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/TaxonomyDataPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/TextAreaDataPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/UploadDataPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/UploadOptionPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/ValidationDataPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/WordListDataPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/service/descriptiontemplate/DescriptionTemplateService.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/service/descriptiontemplate/DescriptionTemplateServiceImpl.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/AutoCompleteFieldDataHelperService.java delete mode 100644 dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/ComboBoxFieldDataHelperService.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/DatasetAutoCompleteFieldDataHelperService.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/DmpAutoCompleteFieldDataHelperService.java delete mode 100644 dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/InternalDmpBaseFieldDataHelperService.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/JournalRepositoryFieldDataHelperService.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/PublicationRepositoryFieldDataHelperService.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/ResearcherAutoCompleteFieldDataHelperService.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/service/fielddatahelper/WordListFieldDataHelperService.java 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