/*
 * <!--
 *   ~ 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 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 "";
        }
    }
}

@@ -1117,24 +1117,378 @@
 () %7B%0A    %7D%0A%0A
+    /**%0A     * Constructor.%0A     *%0A     * @param name          Family name%0A     * @param members       Individuals belonging to this family%0A     * @param attributes    Family attributes%0A     */%0A    public Pedigree(String name, List%3CIndividual%3E members, Map%3CString, Object%3E attributes) %7B%0A        this(name, members, new ArrayList%3C%3E(), attributes);%0A    %7D%0A%0A
     /**%0A    

add another constructor for Pedigree