TangCheng
2025-02-28 d787e447e95c7b897c2cc9c0e832f8d2e5084934
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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;
    }
 
 
}