package cn.edu.whu.boot.xml.xmlreader.bean;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * @author Li Bozhao
 */
public class Config implements Serializable {
    private static final long serialVersionUID = -4357709582704153333L;
    private Meta meta = null;
    /**
     * 有 geometry 的是根表
     */
    private Map<String,Table> rootTables = null;//一个rootTable相当于是一种采集的类型
    private Map<String,Table> tables = null;

    public Meta getMeta() {
        return meta;
    }

    public void setMeta(Meta meta) {
        this.meta = meta;
    }

    public Map<String, Table> getTables() {
        return tables;
    }

    public void setTables(Map<String, Table> tables) {
        this.tables = tables;
        this.rootTables = new HashMap<>();
        for(String key:tables.keySet()){
            Table table = tables.get(key);
            if(table!=null && table.isRoot())
                this.rootTables.put(key,table);
        }
    }

    public void addTable(Table table){
        this.tables.put(table.getKey(),table);
        if(table.isRoot())
            this.rootTables.put(table.getKey(),table);
    }
    public Map<String,Table> getRootTables(){
        return rootTables;
    }
}
