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

84 lines
2.2 KiB
Java

package eu.eudat.commons.types.descriptiontemplate.fielddata;
import eu.eudat.commons.enums.FieldDataComboBoxType;
import eu.eudat.commons.types.xml.XmlSerializable;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public abstract class ComboBoxDataEntity<T> extends BaseFieldDataEntity<T> {
public abstract FieldDataComboBoxType getFieldSubType();
public static class Option implements XmlSerializable<Option> {
private String label;
private String value;
private String source;
private String uri;
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
@Override
public Element toXml(Document doc) {
Element option = doc.createElement("option");
option.setAttribute("label", this.label);
option.setAttribute("value", this.value);
option.setAttribute("source", this.source);
option.setAttribute("uri", this.uri);
return option;
}
@Override
public ComboBoxDataEntity.Option fromXml(Element item) {
this.label = item.getAttribute("label");
this.value = item.getAttribute("value");
this.source = item.getAttribute("source");
this.uri = item.getAttribute("uri");
return this;
}
}
@Override
public Element toXml(Document doc) {
Element root = super.toXml(doc);
root.setAttribute("type", this.getFieldSubType().toString());
return root;
}
@Override
public T fromXml(Element item) {
super.fromXml(item);
return (T) this;
}
}