package com.smtaiserver.smtaiserver.gismap.theme;
|
|
import java.util.HashMap;
|
import java.util.Map;
|
|
import org.dom4j.Element;
|
|
import com.smtaiserver.smtaiserver.database.SMTDatabase.DBRecord;
|
import com.smtservlet.util.SMTStatic;
|
|
public abstract class SMTMapThemeTableDef
|
{
|
public static class SMTMapThemeColumn
|
{
|
public String _name;
|
public char _type;
|
public String _op;
|
|
public SMTMapThemeColumn(Element xmlColumn) throws Exception
|
{
|
_name = SMTStatic.getXmlAttr(xmlColumn, "name");
|
_type = SMTStatic.getXmlAttr(xmlColumn, "type").charAt(0);
|
_op = SMTStatic.getXmlAttr(xmlColumn, "op");
|
}
|
|
public String convValueToSQL(String value)
|
{
|
switch(_type)
|
{
|
case 'D':
|
case 'I':
|
case 'L':
|
return value;
|
|
case 'T':
|
return "'" + value + "'::timestamp";
|
|
default:
|
return "'" + value.replace("'", "''") + "'";
|
}
|
}
|
}
|
|
|
protected String _id;
|
protected String _title;
|
protected Map<String, SMTMapThemeColumn> _mapName2ColumnDef = new HashMap<>();
|
|
public abstract void appendToSQL(Map<String, Object> mapArgValues, StringBuilder sbSQL) throws Exception;
|
public abstract String getDSId();
|
|
public void initInstance(DBRecord rec) throws Exception
|
{
|
_id = rec.getString("theme_table_id");
|
_title = rec.getString("theme_table_title");
|
}
|
|
public String getId()
|
{
|
return _id;
|
}
|
|
public SMTMapThemeColumn getColumnDef(String name) throws Exception
|
{
|
SMTMapThemeColumn columnDef = _mapName2ColumnDef.get(name);
|
if(columnDef == null)
|
throw new Exception("can't find column : " + name);
|
|
return columnDef;
|
}
|
|
|
}
|