Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_daldb / src / org / gvsig / fmap / dal / store / mysql / MySQLServerExplorerParameters.java @ 32880

History | View | Annotate | Download (2.83 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
* MA  02110-1301, USA.
20
*
21
*/
22

    
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 IVER T.I   {{Task}}
26
*/
27

    
28
/**
29
 *
30
 */
31
package org.gvsig.fmap.dal.store.mysql;
32

    
33
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
34
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters;
35

    
36
/**
37
 * @author jmvivo
38
 *
39
 */
40
public class MySQLServerExplorerParameters extends
41
                JDBCServerExplorerParameters implements MySQLConnectionParameters {
42

    
43

    
44
        public static final String PARAMETERS_DEFINITION_NAME = "MySQLServerExplorerParameters";
45

    
46
        public MySQLServerExplorerParameters() {
47
                super(PARAMETERS_DEFINITION_NAME, MySQLServerExplorer.NAME);
48
        }
49
        
50
        public Boolean getUseSSL() {
51
                return (Boolean) this.getDynValue(USESSL_PARAMTER_NAME);
52
        }
53

    
54
        public void setUseSSL(Boolean useSSL) {
55
                this.setDynValue(USESSL_PARAMTER_NAME, useSSL);
56
        }
57

    
58
        public void setUseSSL(boolean useSSL) {
59
                this.setDynValue(USESSL_PARAMTER_NAME, new Boolean(useSSL));
60
        }
61

    
62
        public void validate() throws ValidateDataParametersException {
63
                if (getJDBCDriverClassName() == null) {
64
                        setJDBCDriverClassName(MySQLLibrary.DEFAULT_JDCB_DRIVER_NAME);
65
                }
66
                if (getUrl() == null) {
67
                        setUrl(MySQLLibrary.getJdbcUrl(getHost(), getPort(),
68
                                        getDBName()));
69
                }
70

    
71
                if (getPort() == null) {
72
                        setPort(new Integer(3306));
73
                }
74
                super.validate();
75
        }
76

    
77

    
78
        protected String getSQLForList(int mode, boolean showInformationDBTables) {
79
                StringBuffer sqlBuf = new StringBuffer();
80
                sqlBuf
81
                                .append("SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, false as ISVIEW ");
82
                sqlBuf.append(" FROM INFORMATION_SCHEMA.TABLES ");
83
                sqlBuf.append(" xxWHERExx ");
84
                sqlBuf.append(" union ");
85
                sqlBuf
86
                                .append("SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, true as ISVIEW ");
87
                sqlBuf.append(" FROM INFORMATION_SCHEMA.VIEWS ");
88
                sqlBuf.append(" xxWHERExx ");
89

    
90
                if (showInformationDBTables) {
91
                        return sqlBuf.toString().replaceAll("xxWHERExx", "");
92
                } else {
93
                        return sqlBuf.toString().replaceAll("xxWHERExx",
94
                                        "WHERE TABLE_SCHEMA NOT IN ('information_schema','mysql')");
95

    
96
                }
97

    
98
        }
99

    
100

    
101
}