diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/DefinitionEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/DefinitionEntity.java index 8d4a8b12f..492495a74 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/DefinitionEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/DefinitionEntity.java @@ -7,6 +7,7 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import java.util.ArrayList; import java.util.LinkedList; import java.util.List; @@ -76,6 +77,15 @@ public class DefinitionEntity implements XmlSerializable { } return this; } - + public List getFieldById(String id){ + List fieldEntities = new ArrayList<>(); + if (id == null || id.isBlank()) return fieldEntities; + if (this.getSections() != null){ + for (SectionEntity sectionEntity: this.getSections()) { + fieldEntities.addAll(sectionEntity.getFieldById(id)); + } + } + return fieldEntities; + } } 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 cde8964f1..fb005a2cb 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 @@ -199,7 +199,8 @@ 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, fieldType, dataElement); + String subType = dataElement != null ? dataElement.getAttribute("type") : null; + this.data = new FieldDataHelper().create(fieldType, subType); 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 7cfd8dd04..85ff4c7c2 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 @@ -8,6 +8,7 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import java.util.ArrayList; import java.util.LinkedList; import java.util.List; @@ -190,4 +191,10 @@ public class FieldSetEntity implements DatabaseViewStyleDefinition, XmlSerializa return this; } + + public List getFieldById(String id){ + if (this.getFields() == null || id == null || id.isBlank()) return new ArrayList<>(); + + return this.getFields().stream().filter(x-> id.equals(x.getId())).toList(); + } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/SectionEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/SectionEntity.java index a38831b5b..72a4bf5e0 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/SectionEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/SectionEntity.java @@ -8,6 +8,7 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import java.util.ArrayList; import java.util.LinkedList; import java.util.List; @@ -208,5 +209,19 @@ public class SectionEntity implements DatabaseViewStyleDefinition, XmlSerializab return this; } - + public List getFieldById(String id){ + List fieldEntities = new ArrayList<>(); + if (id == null || id.isBlank()) return fieldEntities; + if (this.getFieldSets() != null){ + for (FieldSetEntity fieldSetEntity: this.getFieldSets()) { + fieldEntities.addAll(fieldSetEntity.getFieldById(id)); + } + } + if (this.getSections() != null){ + for (SectionEntity sectionEntity: this.getSections()) { + fieldEntities.addAll(sectionEntity.getFieldById(id)); + } + } + return fieldEntities; + } } 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 8c4076222..971e8ae31 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 @@ -231,144 +231,6 @@ public class AutoCompleteDataEntity extends ComboBoxDataEntity(); - - - - if (data != null) { - this.multiAutoComplete = (Boolean) ((Map) data).get("multiAutoComplete"); - - List> dataList = (List>) ((Map) data).get("autocompleteSingle"); - if (dataList == null) { - dataList = (List>) ((Map) data).get("autoCompleteSingleDataList"); - } - - this.autoCompleteSingleDataList = new ArrayList<>(); - - int i = 0; - for (Map singleData: dataList) { - this.autoCompleteSingleDataList.add(new AutoCompleteSingleData()); - this.autoCompleteSingleDataList.get(i).autoCompleteOptions = new Option(); - this.autoCompleteSingleDataList.get(i).url = (String) singleData.get("url"); - this.autoCompleteSingleDataList.get(i).optionsRoot = (String) singleData.get("optionsRoot"); - this.autoCompleteSingleDataList.get(i).hasAuth = (Boolean) singleData.get("hasAuth"); - this.autoCompleteSingleDataList.get(i).method = singleData.containsKey("method") ? (String) singleData.get("method") : "GET"; - - if (singleData.get("autoCompleteType") == null) { - this.autoCompleteSingleDataList.get(i).autocompleteType = AutocompleteType.UNCACHED; - } else { - this.autoCompleteSingleDataList.get(i).autocompleteType = AutocompleteType.of((Integer) singleData.get("autoCompleteType")); - } - Map options = (Map) singleData.get("autoCompleteOptions"); - if (options != null) { - this.autoCompleteSingleDataList.get(i).autoCompleteOptions.setLabel(options.get("label")); - this.autoCompleteSingleDataList.get(i).autoCompleteOptions.setValue(options.get("value")); - this.autoCompleteSingleDataList.get(i).autoCompleteOptions.setSource(options.get("source")); - this.autoCompleteSingleDataList.get(i).autoCompleteOptions.setUri(options.get("uri")); - } - if (this.autoCompleteSingleDataList.get(i).hasAuth) { - Map auth = (Map) singleData.get("auth"); - if (auth != null) { - this.autoCompleteSingleDataList.get(i).auth = new AuthAutoCompleteData(); - this.autoCompleteSingleDataList.get(i).auth.setUrl(auth.get("url")); - this.autoCompleteSingleDataList.get(i).auth.setType(auth.get("type")); - this.autoCompleteSingleDataList.get(i).auth.setPath(auth.get("path")); - this.autoCompleteSingleDataList.get(i).auth.setBody(auth.get("body")); - this.autoCompleteSingleDataList.get(i).auth.setMethod(auth.get("method")); - } - } - i++; - } - } - - return this; - } - - @Override - public Object toData() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Map toMap(Element item) { - HashMap dataMap = new HashMap(); - dataMap.put("label", item != null ? item.getAttribute("label") : ""); - //dataMap.put("url", item != null ? item.getAttribute("url") : ""); - dataMap.put("type", item != null ? item.getAttribute("type") : "autocomplete"); - dataMap.put("multiAutoComplete", item != null ? Boolean.valueOf(item.getAttribute("multiAutoComplete")) : false); - List> autoCompletes = new ArrayList<>(); - NodeList autoCompleteSingles = item.getChildNodes(); - for (int i = 0; i < autoCompleteSingles.getLength(); i++) { - if (autoCompleteSingles.item(i) instanceof Element) { - if (!((Element) autoCompleteSingles.item(i)).getTagName().equals("option")) { - Element node = (Element) autoCompleteSingles.item(i); - if (!node.hasChildNodes()) { - node.appendChild(node); - } - - autoCompletes.add(singleToMap(node)); - } else { - Element node = item.getOwnerDocument().createElement("autocompleteSingle"); - node.appendChild(autoCompleteSingles.item(i)); - node.setAttribute("url", item.getAttribute("url")); - node.setAttribute("optionsRoot", item.getAttribute("optionsRoot")); - node.setAttribute("hasAuth", item.getAttribute("hasAuth")); - node.setAttribute("method", item.hasAttribute("method") ? item.getAttribute("method") : "GET"); - autoCompletes.add(singleToMap(node)); - } - } - } - dataMap.put("autocompleteSingle", autoCompletes); - //dataMap.put("optionsRoot", item != null ? item.getAttribute("optionsRoot") : ""); - //Element optionElement = (Element) item.getElementsByTagName("option").item(0); -// if (optionElement != null) { -// this.autoCompleteOptions = new Option(); -// this.autoCompleteOptions.setLabel(optionElement.getAttribute("label")); -// this.autoCompleteOptions.setValue(optionElement.getAttribute("value")); -// } - // dataMap.put("autoCompleteOptions", item != null ? optionToMap(optionElement) : null); - return dataMap; - } - - private Map optionToMap(Element item){ - HashMap dataMap = new HashMap(); - dataMap.put("label", item != null ? item.getAttribute("label") : ""); - dataMap.put("value", item != null ? item.getAttribute("value") : ""); - dataMap.put("source", item != null ? item.getAttribute("source") : ""); - return dataMap; - } - - private Map authToMap(Element item){ - HashMap dataMap = new HashMap(); - dataMap.put("url", item != null ? item.getAttribute("url") : ""); - dataMap.put("method", item != null ? item.getAttribute("method") : ""); - dataMap.put("body", item != null ? item.getAttribute("body") : ""); - dataMap.put("path", item != null ? item.getAttribute("path") : ""); - dataMap.put("type", item != null ? item.getAttribute("type") : ""); - return dataMap; - } - - private Map singleToMap(Element item) { - Map dataMap = new HashMap<>(); - if (!item.getAttribute("autoCompleteType").isEmpty()) { - dataMap.put("autoCompleteType", Integer.parseInt(item.getAttribute("autoCompleteType"))); - } - dataMap.put("optionsRoot", item != null ? item.getAttribute("optionsRoot") : ""); - dataMap.put("url", item != null ? item.getAttribute("url") : ""); - dataMap.put("hasAuth", item != null ? item.getAttribute("hasAuth") : "false"); - Element optionElement = (Element) item.getElementsByTagName("option").item(0); - dataMap.put("autoCompleteOptions", item != null ? optionToMap(optionElement) : null); - Element authElement = (Element) item.getElementsByTagName("auth").item(0); - dataMap.put("auth", item != null ? authToMap(authElement) : null); - dataMap.put("method", item != null && item.hasAttribute("method") ? item.getAttribute("method") : "GET"); - return dataMap; - } - public enum AutocompleteType implements DatabaseEnum { UNCACHED(0), CACHED(1); diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/BaseFieldDataEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/BaseFieldDataEntity.java index 9d3d91489..291a5b2d5 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/BaseFieldDataEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/BaseFieldDataEntity.java @@ -20,16 +20,6 @@ public abstract class BaseFieldDataEntity implements XmlSerializable { this.label = label; } - - public T fromData(Object data) { - return null; - } - - public Object toData() { - return null; - } - - public Element toXml(Document doc) { Element root = doc.createElement("data"); root.setAttribute("label", this.getLabel()); @@ -41,6 +31,4 @@ public abstract class BaseFieldDataEntity implements XmlSerializable { 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 74e008f71..b92b2c7d1 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 @@ -13,26 +13,4 @@ public class BooleanDecisionDataEntity extends BaseFieldDataEntity) data).get("label")); - } - return this; - } - - @Override - public Object toData() { - return null; - } - - - @Override - public Map toMap(Element item) { - HashMap dataMap = new HashMap(); - dataMap.put("label", item != null ? item.getAttribute("label") : ""); - return dataMap; - } - } 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 7c52326c1..b45af367e 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 @@ -13,25 +13,4 @@ public class CheckBoxDataEntity extends BaseFieldDataEntity public FieldType getFieldType() { return FieldType.CHECK_BOX; } - - @Override - public CheckBoxDataEntity fromData(Object data) { - if (data != null) { - this.setLabel((String) ((Map) data).get("label")); - } - return this; - } - - @Override - public Object toData() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Map toMap(Element item) { - HashMap dataMap = new HashMap(); - dataMap.put("label", item != null ? item.getAttribute("label") : ""); - return dataMap; - } } 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 53ead3180..2551604ce 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 @@ -80,28 +80,4 @@ public abstract class ComboBoxDataEntity extends BaseFieldDataEntity { super.fromXml(item); return (T) this; } - - @Override - public T fromData(Object data) { - - if (data != null) { - this.setLabel((String) ((Map) data).get("label")); - } - - return (T) this; - } - - @Override - public Object toData() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Map toMap(Element item) { - HashMap dataMap = new HashMap(); - dataMap.put("label", item != null ? item.getAttribute("label") : ""); - dataMap.put("type", item != null ? item.getAttribute("type") : ""); - return dataMap; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/CurrencyDataEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/CurrencyDataEntity.java index 65ccaf9b3..b015d1d45 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/CurrencyDataEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/CurrencyDataEntity.java @@ -12,24 +12,4 @@ public class CurrencyDataEntity extends BaseFieldDataEntity public FieldType getFieldType() { return FieldType.CURRENCY; } - - @Override - public CurrencyDataEntity fromData(Object data) { - if (data != null) { - this.setLabel((String) ((Map) data).get("label")); - } - return this; - } - - @Override - public Object toData() { - return null; - } - - @Override - public Map toMap(Element item) { - HashMap dataMap = new HashMap(); - dataMap.put("label", item != null ? item.getAttribute("label") : ""); - return dataMap; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/DataRepositoryDataEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/DataRepositoryDataEntity.java index 5b3347c0c..f481f67b1 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/DataRepositoryDataEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/DataRepositoryDataEntity.java @@ -22,21 +22,7 @@ public class DataRepositoryDataEntity extends BaseFieldDataEntity) data).get("label")); - this.setMultiAutoComplete(((Map) data).get("multiAutoComplete") != null && !((Map) data).get("multiAutoComplete").toString().isEmpty()? Boolean.parseBoolean(((Map) data).get("multiAutoComplete").toString()) : false); - } - return this; - } - - @Override - public Object toData() { - return null; - } - + @Override public Element toXml(Document doc) { Element root = super.toXml(doc); @@ -52,12 +38,4 @@ public class DataRepositoryDataEntity extends BaseFieldDataEntity toMap(Element item) { - HashMap dataMap = new HashMap(); - dataMap.put("label", item != null && item.getAttributes().getLength() > 0? item.getAttribute("label") : ""); - dataMap.put("multiAutoComplete", item != null && item.getAttributes().getLength() > 0 ? item.getAttribute("multiAutocomplete") : false); - return dataMap; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/DatasetAutoCompleteDataEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/DatasetAutoCompleteDataEntity.java index d3e580b6a..1776ea64a 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/DatasetAutoCompleteDataEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/DatasetAutoCompleteDataEntity.java @@ -44,30 +44,4 @@ public class DatasetAutoCompleteDataEntity extends InternalDmpBaseDataEntity) data).get("multiAutoComplete"); - } - - return this; - } - - @Override - public Object toData() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Map toMap(Element item) { - HashMap dataMap = new HashMap(); - dataMap.put("label", item != null ? item.getAttribute("label") : ""); - dataMap.put("type", item != null ? item.getAttribute("type") : "datasets"); - dataMap.put("multiAutoComplete", item != null ? Boolean.parseBoolean(item.getAttribute("multiAutocomplete")) : false); - - return dataMap; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/DatasetIdentifierDataEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/DatasetIdentifierDataEntity.java index 27ebc4581..7f5004f71 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/DatasetIdentifierDataEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/DatasetIdentifierDataEntity.java @@ -12,23 +12,4 @@ public class DatasetIdentifierDataEntity extends BaseFieldDataEntity) data).get("label")); - } - return this; - } - - @Override - public Object toData() { - return null; - } - - @Override - public Map toMap(Element item) { - HashMap dataMap = new HashMap(); - dataMap.put("label", item != null ? item.getAttribute("label") : ""); - return dataMap; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/DatePickerDataEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/DatePickerDataEntity.java index fd53df315..16066f18b 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/DatePickerDataEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/DatePickerDataEntity.java @@ -12,23 +12,4 @@ public class DatePickerDataEntity extends BaseFieldDataEntity) data).get("label")); - } - return this; - } - - @Override - public Object toData() { - return null; - } - - @Override - public Map toMap(Element item) { - HashMap dataMap = new HashMap(); - dataMap.put("label", item != null ? item.getAttribute("label") : ""); - return dataMap; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/DmpAutoCompleteDataEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/DmpAutoCompleteDataEntity.java index ee47511a5..84adab457 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/DmpAutoCompleteDataEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/DmpAutoCompleteDataEntity.java @@ -42,30 +42,4 @@ public class DmpAutoCompleteDataEntity extends InternalDmpBaseDataEntity) data).get("multiAutoComplete"); - } - - return this; - } - - @Override - public Object toData() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Map toMap(Element item) { - HashMap dataMap = new HashMap(); - dataMap.put("label", item != null ? item.getAttribute("label") : ""); - dataMap.put("type", item != null ? item.getAttribute("type") : "dmps"); - dataMap.put("multiAutoComplete", item != null ? Boolean.parseBoolean(item.getAttribute("multiAutocomplete")) : false); - - return dataMap; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/ExternalDatasetDataEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/ExternalDatasetDataEntity.java index 8c54fe59c..938bebfae 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/ExternalDatasetDataEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/ExternalDatasetDataEntity.java @@ -32,21 +32,6 @@ public class ExternalDatasetDataEntity extends BaseFieldDataEntity) data).get("label")); - this.setMultiAutoComplete(((Map) data).get("multiAutoComplete") != null && !((Map) data).get("multiAutoComplete").toString().isEmpty()? Boolean.parseBoolean( ((Map) data).get("multiAutoComplete").toString()) : false); - this.setType(((Map) data).get("type") != null && !((Map) data).get("type").toString().isEmpty()? FieldDataExternalDatasetType.of(((Map) data).get("type").toString()) : FieldDataExternalDatasetType.Other); - } - return this; - } - - @Override - public Object toData() { - return null; - } - @Override public Element toXml(Document doc) { Element root = doc.createElement("data"); @@ -67,13 +52,4 @@ public class ExternalDatasetDataEntity extends BaseFieldDataEntity toMap(Element item) { - HashMap dataMap = new HashMap(); - dataMap.put("label", item != null && item.getAttributes().getLength() > 0? item.getAttribute("label") : ""); - dataMap.put("multiAutoComplete", item != null && item.getAttributes().getLength() > 0? Boolean.parseBoolean(item.getAttribute("multiAutocomplete")) : false); - dataMap.put("type", item != null && item.getAttributes().getLength() > 0? item.getAttribute("type") : "other"); - return dataMap; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/FieldDataHelper.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/FieldDataHelper.java index e44d26921..64f9eeac8 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/FieldDataHelper.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/FieldDataHelper.java @@ -66,19 +66,4 @@ public class FieldDataHelper { return null; } - - public BaseFieldDataEntity toFieldData(Object data, FieldType type, Element dataElement) { - String subType = dataElement != null ? dataElement.getAttribute("type") : null; - BaseFieldDataEntity baseFieldData = this.create(type, subType); - if (baseFieldData == null) return baseFieldData; - return (BaseFieldDataEntity) baseFieldData.fromData(data); - } - - public BaseFieldDataEntity toFieldData(Object data, FieldType type) { - Map dataAsMap = (Map) data; - String subType = dataAsMap != null ? (String) dataAsMap.getOrDefault("type", null) : null; - BaseFieldDataEntity baseFieldData = this.create(type, subType); - if (baseFieldData == null) return baseFieldData; - return (BaseFieldDataEntity) baseFieldData.fromData(data); - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/FreeTextDataEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/FreeTextDataEntity.java index 1096961b9..eec9ebb89 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/FreeTextDataEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/FreeTextDataEntity.java @@ -13,24 +13,4 @@ public class FreeTextDataEntity extends BaseFieldDataEntity public FieldType getFieldType() { return FieldType.FREE_TEXT; } - - @Override - public FreeTextDataEntity fromData(Object data) { - if (data != null) { - this.setLabel(((Map) data).get("label")); - } - return this; - } - - @Override - public Object toData() { - return null; - } - - @Override - public Map toMap(Element item) { - HashMap dataMap = new HashMap(); - dataMap.put("label", item != null ? item.getAttribute("label") : ""); - return dataMap; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/InternalDmpBaseDataEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/InternalDmpBaseDataEntity.java index d92a5eac2..8c6b3f95f 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/InternalDmpBaseDataEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/InternalDmpBaseDataEntity.java @@ -23,29 +23,4 @@ public abstract class InternalDmpBaseDataEntity extends BaseFieldDataEntity) data).get("label")); - } - - return (T) this; - } - - @Override - public Object toData() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Map toMap(Element item) { - HashMap dataMap = new HashMap(); - dataMap.put("label", item != null ? item.getAttribute("label") : ""); - dataMap.put("type", item != null ? item.getAttribute("type") : ""); - dataMap.put("type", item != null ? item.getAttribute("type") : "researchers"); - return dataMap; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/JournalRepositoryDataEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/JournalRepositoryDataEntity.java index bc5966e9e..bf085865a 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/JournalRepositoryDataEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/JournalRepositoryDataEntity.java @@ -23,20 +23,6 @@ public class JournalRepositoryDataEntity extends BaseFieldDataEntity) data).get("label")); - this.setMultiAutoComplete(((Map) data).get("multiAutoComplete") != null && !((Map) data).get("multiAutoComplete").toString().isEmpty()? Boolean.parseBoolean(((Map) data).get("multiAutoComplete").toString()) : false); - } - return this; - } - - @Override - public Object toData() { - return null; - } - @Override public Element toXml(Document doc) { Element root = super.toXml(doc); @@ -52,12 +38,4 @@ public class JournalRepositoryDataEntity extends BaseFieldDataEntity toMap(Element item) { - HashMap dataMap = new HashMap(); - dataMap.put("label", item != null && item.getAttributes().getLength() > 0? item.getAttribute("label") : ""); - dataMap.put("multiAutoComplete", item != null && item.getAttributes().getLength() > 0 ? item.getAttribute("multiAutocomplete") : false); - return dataMap; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/LicenseDataEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/LicenseDataEntity.java index 8a748c72b..94f1bd0ac 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/LicenseDataEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/LicenseDataEntity.java @@ -21,21 +21,7 @@ public class LicenseDataEntity extends BaseFieldDataEntity { public void setMultiAutoComplete(Boolean multiAutoComplete) { this.multiAutoComplete = multiAutoComplete; } - - @Override - public LicenseDataEntity fromData(Object data) { - if (data != null) { - this.setLabel((String) ((Map) data).get("label")); - this.setMultiAutoComplete(((Map) data).get("multiAutoComplete") != null && !((Map) data).get("multiAutoComplete").toString().isEmpty()? Boolean.parseBoolean(((Map) data).get("multiAutoComplete").toString()) : false); - } - return this; - } - - @Override - public Object toData() { - return null; - } - + @Override public Element toXml(Document doc) { Element root = super.toXml(doc); @@ -51,12 +37,4 @@ public class LicenseDataEntity extends BaseFieldDataEntity { this.setMultiAutoComplete(Boolean.parseBoolean(item.getAttribute("multiAutoComplete"))); return this; } - - @Override - public Map toMap(Element item) { - HashMap dataMap = new HashMap(); - dataMap.put("label", item != null && item.getAttributes().getLength() > 0? item.getAttribute("label") : ""); - dataMap.put("multiAutoComplete", item != null && item.getAttributes().getLength() > 0 ? item.getAttribute("multiAutocomplete") : false); - return dataMap; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/OrganizationDataEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/OrganizationDataEntity.java index 22fc29d28..e175f54e9 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/OrganizationDataEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/OrganizationDataEntity.java @@ -22,20 +22,6 @@ public class OrganizationDataEntity extends BaseFieldDataEntity) data).get("label")); - this.setMultiAutoComplete(((Map) data).get("multiAutoComplete") != null && !((Map) data).get("multiAutoComplete").toString().isEmpty()? Boolean.parseBoolean( ((Map) data).get("multiAutoComplete").toString()) : false); - } - return this; - } - - @Override - public Object toData() { - return null; - } - @Override public Element toXml(Document doc) { Element root = super.toXml(doc); @@ -51,12 +37,4 @@ public class OrganizationDataEntity extends BaseFieldDataEntity toMap(Element item) { - HashMap dataMap = new HashMap(); - dataMap.put("label", item != null && item.getAttributes().getLength() > 0? item.getAttribute("label") : ""); - dataMap.put("multiAutoComplete", item != null && item.getAttributes().getLength() > 0? Boolean.parseBoolean(item.getAttribute("multiAutocomplete")) : false); - return dataMap; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/PublicationDataEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/PublicationDataEntity.java index c3a6a16b7..4f7aaaecf 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/PublicationDataEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/PublicationDataEntity.java @@ -21,21 +21,6 @@ public class PublicationDataEntity extends BaseFieldDataEntity) data).get("label")); - this.setMultiAutoComplete(((Map) data).get("multiAutoComplete") != null && !((Map) data).get("multiAutoComplete").toString().isEmpty()? Boolean.parseBoolean(((Map) data).get("multiAutoComplete").toString()) : false); - } - return this; - } - - @Override - public Object toData() { - return null; - } - @Override public Element toXml(Document doc) { Element root = super.toXml(doc); @@ -51,12 +36,4 @@ public class PublicationDataEntity extends BaseFieldDataEntity toMap(Element item) { - HashMap dataMap = new HashMap(); - dataMap.put("label", item != null && item.getAttributes().getLength() > 0? item.getAttribute("label") : ""); - dataMap.put("multiAutoComplete", item != null && item.getAttributes().getLength() > 0 ? item.getAttribute("multiAutocomplete") : false); - return dataMap; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/PublicationRepositoryDataEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/PublicationRepositoryDataEntity.java index 0d3ac8bb5..0e5a2d472 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/PublicationRepositoryDataEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/PublicationRepositoryDataEntity.java @@ -22,21 +22,7 @@ public class PublicationRepositoryDataEntity extends BaseFieldDataEntity) data).get("label")); - this.setMultiAutoComplete(((Map) data).get("multiAutoComplete") != null && !((Map) data).get("multiAutoComplete").toString().isEmpty()? Boolean.parseBoolean(((Map) data).get("multiAutoComplete").toString()) : false); - } - return this; - } - - @Override - public Object toData() { - return null; - } - + @Override public Element toXml(Document doc) { Element root = super.toXml(doc); @@ -52,12 +38,4 @@ public class PublicationRepositoryDataEntity extends BaseFieldDataEntity toMap(Element item) { - HashMap dataMap = new HashMap(); - dataMap.put("label", item != null && item.getAttributes().getLength() > 0? item.getAttribute("label") : ""); - dataMap.put("multiAutoComplete", item != null && item.getAttributes().getLength() > 0 ? item.getAttribute("multiAutocomplete") : false); - return dataMap; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/RadioBoxDataEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/RadioBoxDataEntity.java index 248b2988b..1c057016d 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/RadioBoxDataEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/RadioBoxDataEntity.java @@ -64,29 +64,7 @@ public class RadioBoxDataEntity extends BaseFieldDataEntity public void setOptions(List