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


import eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel.FieldSets;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.LinkedList;
import java.util.List;

@XmlRootElement(name = "definition")
public class DmpProfileDefinition {

    private FieldSets fieldSets;

    @XmlElement(name = "fieldSets")
    public FieldSets getFieldSets() {
        return fieldSets;
    }

    public void setFieldSets(FieldSets fieldSets) {
        this.fieldSets = fieldSets;
    }

    public eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanProfile toDmpProfileCompositeModel() {
        eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanProfile dmpProfileDefinitionModel = new eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanProfile();
        List<eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.Field> dmpProfileDefinitionFields = new LinkedList<>();
        for (Field field:this.fieldSets.fields) {
            dmpProfileDefinitionFields.add(field.toDmpProfileCompositeModel());
        }
        dmpProfileDefinitionModel.setFields(dmpProfileDefinitionFields);
        return dmpProfileDefinitionModel;
    }


}
