package weaver.conn.constant;

import com.google.common.collect.Maps;

import java.util.HashMap;
import java.util.Map;

public class DBConstant {
	public static final String DB_TYPE_ORACLE = "oracle";
	public static final String DB_TYPE_MYSQL = "mysql";
	public static final String DB_TYPE_SQLSERVER = "sqlserver";
	public static final String DB_TYPE_POSTGRESQL = "postgresql";
	public static final String DB_TYPE_DB2 = "db2";
	public static final String DB_TYPE_HANA = "hana";

	public static final String COLUMN_TYPE_VARCHAR = "varchar";
	public static final String COLUMN_TYPE_INT = "int";
	public static final String COLUMN_TYPE_ID = "id";

	public static final Map<String, Map<String, String>> COLUMN_TYPES = Maps.newHashMap();
	static {
		COLUMN_TYPES.put(DB_TYPE_ORACLE, new HashMap<String, String>());
		COLUMN_TYPES.put(DB_TYPE_SQLSERVER, new HashMap<String, String>());
		COLUMN_TYPES.put(DB_TYPE_MYSQL, new HashMap<String, String>());
		COLUMN_TYPES.put(DB_TYPE_POSTGRESQL, new HashMap<String, String>());
		
		COLUMN_TYPES.get(DB_TYPE_ORACLE).put(COLUMN_TYPE_VARCHAR, "varchar2");
		COLUMN_TYPES.get(DB_TYPE_SQLSERVER).put(COLUMN_TYPE_VARCHAR, "varchar");
		COLUMN_TYPES.get(DB_TYPE_MYSQL).put(COLUMN_TYPE_VARCHAR, "varchar");
		COLUMN_TYPES.get(DB_TYPE_POSTGRESQL).put(COLUMN_TYPE_VARCHAR, "varchar");
		
		COLUMN_TYPES.get(DB_TYPE_ORACLE).put(COLUMN_TYPE_INT, "integer");
		COLUMN_TYPES.get(DB_TYPE_SQLSERVER).put(COLUMN_TYPE_INT, "int");
		COLUMN_TYPES.get(DB_TYPE_MYSQL).put(COLUMN_TYPE_INT, "int");
		COLUMN_TYPES.get(DB_TYPE_POSTGRESQL).put(COLUMN_TYPE_INT, "int");

		COLUMN_TYPES.get(DB_TYPE_ORACLE).put(COLUMN_TYPE_ID, "id integer NOT NULL");
		COLUMN_TYPES.get(DB_TYPE_SQLSERVER).put(COLUMN_TYPE_ID, "id int IDENTITY(1,1) NOT NULL");
		COLUMN_TYPES.get(DB_TYPE_MYSQL).put(COLUMN_TYPE_ID, "id int NOT NULL auto_increment primary key");
		COLUMN_TYPES.get(DB_TYPE_POSTGRESQL).put(COLUMN_TYPE_ID, "id serial PRIMARY KEY");
	}
}