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 Table implements Serializable {
    private static final long serialVersionUID = -3856096401850481429L;
    /**
     * 在数据库中表现为表名
     */
    private String key;

    /**
     * 表的中文名称，在数据库中表现为注释
     */
    private String name;
    /**
     * 原本是包含geometry的叫根表，现在是有root=true的是根表
     */
    private boolean root = false;
    private boolean useMap = false;//是否包含geometry
    private String drawTool = null;
    private Map<String, Field> fields = new HashMap<>();

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getName() {
        return name;
    }

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

    public void setFields(Map<String, Field> fields) {
        this.fields = fields;
        for(Field field:fields.values()){
            if(field.isGeometry()) {
//                root = true;
                useMap = true;
                break;
            }
        }
    }

    public Map<String, Field> getFields() {
        return fields;
    }

    public boolean isRoot() {
        return root;
    }

    public void setRoot(boolean root) {
        this.root = root;
    }

    public String getDrawTool() {
        return drawTool;
    }

    public void setDrawTool(String drawTool) {
        this.drawTool = drawTool;
    }

    public boolean isUseMap() {
        return useMap;
    }
    private boolean isRootTable;
    public void setIsRootTable(boolean isRootTable) {
        this.isRootTable = isRootTable;
    }
    public void setUseMap(boolean useMap) {
        this.useMap = useMap;
    }
}
