argos/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/fielddata/ExternalDatasetDataEntity.java

56 lines
1.8 KiB
Java
Raw Normal View History

2023-10-27 17:46:34 +02:00
package eu.eudat.commons.types.descriptiontemplate.fielddata;
2023-10-27 17:46:34 +02:00
import eu.eudat.commons.enums.FieldDataExternalDatasetType;
2023-10-30 14:07:59 +01:00
import eu.eudat.commons.enums.FieldType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
2023-10-27 17:46:34 +02:00
public class ExternalDatasetDataEntity extends BaseFieldDataEntity<ExternalDatasetDataEntity> {
2023-10-30 14:07:59 +01:00
@Override
public FieldType getFieldType() {
return FieldType.EXTERNAL_DATASETS;
}
private Boolean multiAutoComplete;
2023-10-27 17:46:34 +02:00
private FieldDataExternalDatasetType type;
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
public void setMultiAutoComplete(Boolean multiAutoComplete) {
this.multiAutoComplete = multiAutoComplete;
}
2023-10-27 17:46:34 +02:00
public FieldDataExternalDatasetType getType() {
2021-06-22 17:29:58 +02:00
return type;
}
2023-10-27 17:46:34 +02:00
public void setType(FieldDataExternalDatasetType type) {
2021-06-22 17:29:58 +02:00
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());
}
2021-06-22 17:29:58 +02:00
if (this.getType() != null) {
2023-10-27 17:46:34 +02:00
root.setAttribute("type", this.getType().getValue());
2021-06-22 17:29:58 +02:00
}
return root;
}
@Override
2023-10-27 17:46:34 +02:00
public ExternalDatasetDataEntity fromXml(Element item) {
this.setLabel(item != null ? item.getAttribute("label") : "");
this.setMultiAutoComplete(Boolean.parseBoolean(item.getAttribute("multiAutoComplete")));
2023-10-27 17:46:34 +02:00
this.setType(item.getAttribute("type") != null ? FieldDataExternalDatasetType.of(item.getAttribute("type")): FieldDataExternalDatasetType.Other);
return this;
}
}