package eu.eudat.commons.types.descriptiontemplate.fielddata; import eu.eudat.commons.enums.FieldDataExternalDatasetType; import eu.eudat.commons.enums.FieldType; import org.w3c.dom.Document; import org.w3c.dom.Element; import java.util.HashMap; import java.util.Map; public class ExternalDatasetDataEntity extends BaseFieldDataEntity { @Override public FieldType getFieldType() { return FieldType.EXTERNAL_DATASETS; } private Boolean multiAutoComplete; private FieldDataExternalDatasetType type; public Boolean getMultiAutoComplete() { return multiAutoComplete; } public void setMultiAutoComplete(Boolean multiAutoComplete) { this.multiAutoComplete = multiAutoComplete; } public FieldDataExternalDatasetType getType() { return type; } public void setType(FieldDataExternalDatasetType type) { this.type = type; } @Override public Element toXml(Document doc) { Element root = doc.createElement("data"); root.setAttribute("label", this.getLabel()); if (this.getMultiAutoComplete() != null) { root.setAttribute("multiAutoComplete", this.getMultiAutoComplete().toString()); } if (this.getType() != null) { root.setAttribute("type", this.getType().getValue()); } return root; } @Override public ExternalDatasetDataEntity fromXml(Element item) { this.setLabel(item != null ? item.getAttribute("label") : ""); this.setMultiAutoComplete(Boolean.parseBoolean(item.getAttribute("multiAutoComplete"))); this.setType(item.getAttribute("type") != null ? FieldDataExternalDatasetType.of(item.getAttribute("type")): FieldDataExternalDatasetType.Other); return this; } }