package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel;



import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlValue;
import java.util.UUID;

@XmlRootElement(name = "field")
public class Field {

    private String id;

    private String label;

    private int dataType;

    private boolean required;

    private int type;

//    private Object value;

    @XmlAttribute(name = "id")
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @XmlAttribute(name = "label")
    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    @XmlAttribute(name = "dataType")
    public int getDataType() {
        return dataType;
    }

    public void setDataType(int dataType) {
        this.dataType = dataType;
    }

    @XmlAttribute(name = "required")
    public boolean isRequired() {
        return required;
    }

    public void setRequired(boolean required) {
        this.required = required;
    }

    @XmlAttribute(name = "type")
    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

//    @XmlValue
//    public Object getValue() {
//        return value;
//    }
//
//    public void setValue(Object value) {
//        this.value = value;
//    }

    public eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.Field toDmpProfileCompositeModel() {
        eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.Field field = new eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.Field();
        field.setId(UUID.fromString(this.id));
        field.setDataType(eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.DMPProfileFieldDataType.fromInteger(this.dataType));
        field.setLabel(this.label);
        field.setRequired(this.required);
        field.setType(eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.DMPProfileType.fromInteger(this.type));
      //  field.setValue(this.value);
        return field;
    }

}
