package models;

import java.io.IOException;
import java.util.HashMap;

import com.fasterxml.jackson.databind.ObjectMapper;

public class OrgConfig {
    public String name;
    public String short_name;
    public String people_url;
    public String str_manual_title;
    public String str_manual_title_short;
    public String str_res_plan_short;
    public String str_res_plan;
    public String str_res_plan_cap;
    public String str_res_plans;
    public String str_res_plans_cap;

    public boolean show_no_contest_plea = false;
    public boolean show_severity = false;
    public boolean use_minor_referrals = false;
    public boolean show_checkbox_for_res_plan = true;

    public Organization org;

    public static OrgConfig get() {
        Organization org = Organization.getByHost();
        OrgConfig result = configs.get(org.name);
        result.org = org;
        return result;
    }

    static HashMap<String, OrgConfig> configs = new HashMap<String, OrgConfig>();
    static void register(String name, OrgConfig config) {
        configs.put(name, config);
    }

    public String toJson() {
        ObjectMapper m = new ObjectMapper();
        try
        {
            return m.writeValueAsString(this);
        }
        catch (IOException e) {
            e.printStackTrace();
            return "";
        }
    }
}

class ThreeRiversVillageSchool extends OrgConfig {
    private static final ThreeRiversVillageSchool INSTANCE = new ThreeRiversVillageSchool();

    public ThreeRiversVillageSchool() {
        name = "Three Rivers Village School";
        short_name = "TRVS";
        people_url = "http://people.threeriversvillageschool.org";

        str_manual_title = "Management Manual";
        str_manual_title_short = "Manual";
        str_res_plan_short = "RP";
        str_res_plan = "resolution plan";
        str_res_plan_cap = "Resolution plan";
        str_res_plans = "resolution plans";
        str_res_plans_cap = "Resolution plans";

        show_checkbox_for_res_plan = false;

        OrgConfig.register(name, this);
    }

    public static ThreeRiversVillageSchool getInstance() {
        return INSTANCE;
    }
}

class PhillyFreeSchool extends OrgConfig {
    private static final PhillyFreeSchool INSTANCE = new PhillyFreeSchool();

    public PhillyFreeSchool() {
        name = "Philly Free School";
        short_name = "PFS";
        people_url = "http://people-pfs.threeriversvillageschool.org";

        str_manual_title = "Lawbook";
        str_manual_title_short = "Lawbook";
        str_res_plan_short = "sentence";
        str_res_plan = "sentence";
        str_res_plan_cap = "Sentence";
        str_res_plans = "sentences";
        str_res_plans_cap = "Sentences";

        show_no_contest_plea = true;
        show_severity = true;
        use_minor_referrals = true;

        OrgConfig.register(name, this);
    }

    public static PhillyFreeSchool getInstance() {
        return INSTANCE;
    }
}

@@ -3048,28 +3048,747 @@
 return INSTANCE;%0D%0A    %7D%0D%0A%7D%0D%0A
+%0D%0Aclass Fairhaven extends OrgConfig %7B%0D%0A    private static final Fairhaven INSTANCE = new Fairhaven();%0D%0A%0D%0A    public Fairhaven() %7B%0D%0A        name = %22Fairhaven School%22;%0D%0A        short_name = %22Fairhaven%22;%0D%0A        people_url = %22http://fairhaven.demschooltools.com%22;%0D%0A%0D%0A        str_manual_title = %22Lawbook%22;%0D%0A        str_manual_title_short = %22Lawbook%22;%0D%0A        str_res_plan_short = %22sentence%22;%0D%0A        str_res_plan = %22sentence%22;%0D%0A        str_res_plan_cap = %22Sentence%22;%0D%0A        str_res_plans = %22sentences%22;%0D%0A        str_res_plans_cap = %22Sentences%22;%0D%0A%0D%0A        use_minor_referrals = true;%0D%0A%0D%0A        OrgConfig.register(name, this);%0D%0A    %7D%0D%0A%0D%0A    public static Fairhaven getInstance() %7B%0D%0A        return INSTANCE;%0D%0A    %7D%0D%0A%7D%0D%0A

Add Fairhaven OrgConfig.