package eu.eudat.models.data.dmp;

import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.logic.utilities.interfaces.XmlSerializable;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

import java.util.UUID;


public class AssociatedProfile implements XmlSerializable<AssociatedProfile> {
    private UUID id;
    private String label;

    public UUID getId() {
        return id;
    }

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

    public String getLabel() {
        return label;
    }

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

    @Override
    public Element toXml(Document doc) {
        Element profile = doc.createElement("profile");
        profile.setAttribute("profileId", this.id.toString());
        profile.setAttribute("label", this.label);
        return profile;
    }

    @Override
    public AssociatedProfile fromXml(Element item) {
        this.id = UUID.fromString(item.getAttribute("profileId"));
        this.label = item.getAttribute("label");
        return this;
    }

    public DatasetProfile toData() {
        DatasetProfile profile = new DatasetProfile();
        profile.setId(this.id);
        profile.setLabel(this.label);
        return profile;
    }

    public AssociatedProfile fromData(DatasetProfile entity) {
        this.id = entity.getId();
        this.label = entity.getLabel();
        return this;
    }
}
