94 lines
2.5 KiB
Java
94 lines
2.5 KiB
Java
package eu.eudat.commons.types.dmpblueprint;
|
|
|
|
import eu.eudat.commons.enums.DmpBlueprintFieldCategory;
|
|
import eu.eudat.commons.types.xml.XmlSerializable;
|
|
import org.w3c.dom.Document;
|
|
import org.w3c.dom.Element;
|
|
|
|
import java.util.UUID;
|
|
|
|
public abstract class FieldEntity implements XmlSerializable<FieldEntity> {
|
|
private UUID id;
|
|
private DmpBlueprintFieldCategory category;
|
|
private String label;
|
|
private String placeholder;
|
|
private String description;
|
|
private Integer ordinal;
|
|
private boolean required;
|
|
|
|
public UUID getId() {
|
|
return id;
|
|
}
|
|
public void setId(UUID id) {
|
|
this.id = id;
|
|
}
|
|
|
|
public DmpBlueprintFieldCategory getCategory() {
|
|
return category;
|
|
}
|
|
public void setCategory(DmpBlueprintFieldCategory category) {
|
|
this.category = category;
|
|
}
|
|
|
|
public String getLabel() {
|
|
return label;
|
|
}
|
|
public void setLabel(String label) {
|
|
this.label = label;
|
|
}
|
|
|
|
public String getPlaceholder() {
|
|
return placeholder;
|
|
}
|
|
public void setPlaceholder(String placeholder) {
|
|
this.placeholder = placeholder;
|
|
}
|
|
|
|
public String getDescription() {
|
|
return description;
|
|
}
|
|
public void setDescription(String description) {
|
|
this.description = description;
|
|
}
|
|
|
|
public Integer getOrdinal() {
|
|
return ordinal;
|
|
}
|
|
public void setOrdinal(Integer ordinal) {
|
|
this.ordinal = ordinal;
|
|
}
|
|
|
|
public boolean isRequired() {
|
|
return required;
|
|
}
|
|
public void setRequired(boolean required) {
|
|
this.required = required;
|
|
}
|
|
protected abstract Element appendXmlChild(Element rootElement);
|
|
protected abstract FieldEntity fromXmlChild(Element item);
|
|
@Override
|
|
public Element toXml(Document doc) {
|
|
Element rootElement = doc.createElement("extraField");
|
|
rootElement.setAttribute("id", this.getId().toString());
|
|
rootElement.setAttribute("label", this.label);
|
|
rootElement.setAttribute("description", this.description);
|
|
rootElement.setAttribute("placeholder", this.placeholder);
|
|
rootElement.setAttribute("required", String.valueOf(this.required));
|
|
rootElement.setAttribute("ordinal", String.valueOf(this.ordinal));
|
|
this.appendXmlChild(rootElement);
|
|
return rootElement;
|
|
}
|
|
|
|
@Override
|
|
public FieldEntity fromXml(Element item) {
|
|
this.id = UUID.fromString(item.getAttribute("id"));
|
|
this.label = item.getAttribute("label");
|
|
this.description = item.getAttribute("description");
|
|
this.placeholder = item.getAttribute("placeholder");
|
|
this.required = Boolean.parseBoolean(item.getAttribute("required"));
|
|
this.ordinal = Integer.valueOf(item.getAttribute("ordinal"));
|
|
this.fromXmlChild(item);
|
|
return this;
|
|
}
|
|
}
|