/*
 * <!--
 *   ~ Copyright 2015-2017 OpenCB
 *   ~
 *   ~ Licensed under the Apache License, Version 2.0 (the "License");
 *   ~ you may not use this file except in compliance with the License.
 *   ~ You may obtain a copy of the License at
 *   ~
 *   ~     http://www.apache.org/licenses/LICENSE-2.0
 *   ~
 *   ~ Unless required by applicable law or agreed to in writing, software
 *   ~ distributed under the License is distributed on an "AS IS" BASIS,
 *   ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   ~ See the License for the specific language governing permissions and
 *   ~ limitations under the License.
 *   -->
 *
 */

package org.opencb.biodata.models.core.pedigree;

import org.codehaus.jackson.map.ObjectMapper;
import org.opencb.biodata.models.commons.Phenotype;

import java.util.*;

/**
 * Created by imedina on 10/10/16.
 */
public class Pedigree {
    private String name;

    private List<Phenotype> phenotypes;
    private List<Individual> members;

    private Map<String, Object> attributes;

    /**
     * Empty constructor.
     */
    public Pedigree() {
    }

    /**
     * Constructor.
     *
     * @param name          Family name
     * @param members       Individuals belonging to this family
     * @param attributes    Family attributes
     */
    public Pedigree(String name, List<Individual> members, Map<String, Object> attributes) {
        this(name, members, new ArrayList<>(), attributes);
    }

    /**
     * Constructor.
     *
     * @param name          Family name
     * @param members       Individuals belonging to this family
     * @param phenotypes    List of phenotypes present in the members of the family
     * @param attributes    Family attributes
     */
    public Pedigree(String name, List<Individual> members, List<Phenotype> phenotypes, Map<String, Object> attributes) {
        this.name = name;
        this.members = members;
        this.phenotypes = phenotypes;
        this.attributes = attributes;
    }

    public String getName() {
        return name;
    }

    public Pedigree setName(String name) {
        this.name = name;
        return this;
    }

    public List<Phenotype> getPhenotypes() {
        return phenotypes;
    }

    public Pedigree setPhenotypes(List<Phenotype> phenotypes) {
        this.phenotypes = phenotypes;
        return this;
    }

    public List<Individual> getMembers() {
        return members;
    }

    public Pedigree setMembers(List<Individual> members) {
        this.members = members;
        return this;
    }

    public Map<String, Object> getAttributes() {
        return attributes;
    }

    public Pedigree setAttributes(Map<String, Object> attributes) {
        this.attributes = attributes;
        return this;
    }

    public String toJSON() {
        try {
            ObjectMapper mapper = new ObjectMapper();
            return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(this).toString();
        } catch (Exception e) {
            return "";
        }
    }
}

@@ -999,24 +999,57 @@
 %3E members;%0A%0A
+    private Individual proband;%0A%0A
     private 
@@ -1080,16 +1080,16 @@
 ibutes;%0A
-
 %0A    /**
@@ -1468,16 +1468,22 @@
 members,
+ null,
  new Arr
@@ -1905,32 +1905,564 @@
 %3E attributes) %7B%0A
+        this(name, members, null, phenotypes, attributes);%0A    %7D%0A%0A    /**%0A     * Constructor.%0A     *%0A     * @param name          Family name%0A     * @param members       Individuals belonging to this family%0A     * @param proband       Proband individual%0A     * @param phenotypes    List of phenotypes present in the members of the family%0A     * @param attributes    Family attributes%0A     */%0A    public Pedigree(String name, List%3CIndividual%3E members, Individual proband, List%3CPhenotype%3E phenotypes, Map%3CString, Object%3E attributes) %7B%0A
         this.nam
@@ -2495,32 +2495,64 @@
 bers = members;%0A
+        this.proband = proband;%0A
         this.phe
@@ -3111,24 +3111,24 @@
  members) %7B%0A
-
         this
@@ -3167,32 +3167,213 @@
 rn this;%0A    %7D%0A%0A
+    public Individual getProband() %7B%0A        return proband;%0A    %7D%0A%0A    public Pedigree setProband(Individual proband) %7B%0A        this.proband = proband;%0A        return this;%0A    %7D%0A%0A
     public Map%3CS

add proband to Pedigree data model