Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_daldb / src / org / gvsig / fmap / dal / store / postgesql / PostgreSQLResourceParameters.java @ 27753

History | View | Annotate | Download (3.23 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
package org.gvsig.fmap.dal.store.postgesql;
29

    
30
import org.gvsig.fmap.dal.DataTypes;
31
import org.gvsig.fmap.dal.store.jdbc.JDBCResourceParameters;
32
import org.gvsig.tools.ToolsLocator;
33
import org.gvsig.tools.dynobject.DynClass;
34
import org.gvsig.tools.dynobject.DynField;
35
import org.gvsig.tools.dynobject.DynObjectManager;
36

    
37
public class PostgreSQLResourceParameters extends JDBCResourceParameters {
38

    
39
        private static DynClass DYNCLASS = null;
40

    
41
        public static final String DYNCLASS_NAME = "PostgreSQLResourceParameters";
42

    
43
        public static final String DYNFIELDNAME_USESSL = "usessl";
44

    
45
        public PostgreSQLResourceParameters() {
46
                super();
47
        }
48

    
49
    public PostgreSQLResourceParameters(String host, Integer port,
50
                        String dbName, String user, String password,
51
                        String jdbcDriverClassName, Boolean ssl) {
52
                super(host, port, dbName, user, password, jdbcDriverClassName);
53
                if (ssl != null) {
54
                        this.setUseSSL(ssl.booleanValue());
55
                }
56
        }
57

    
58
        protected static void registerDynClass() {
59
                DynObjectManager dynman = ToolsLocator.getDynObjectManager();
60
                DynClass dynClass = dynman.get(DYNCLASS_NAME);
61
                DynField field;
62
                if (dynClass == null) {
63
                        dynClass = dynman.add(DYNCLASS_NAME);
64

    
65
                        dynClass.extend(JDBCResourceParameters.DYNCLASS_NAME);
66

    
67
                        field = dynClass.addDynField(DYNFIELDNAME_USESSL);
68
                        field.setTheTypeOfAvailableValues(DynField.SINGLE);
69
                        field.setDescription("use SSL connetion");
70
                        field.setType(DataTypes.BOOLEAN);
71
                        field.setDefaultValue(Boolean.FALSE);
72

    
73
                        field = dynClass.addDynField(DYNFIELDNAME_JDBC_DRIVER_CLASS_NAME);
74
                        field.setTheTypeOfAvailableValues(DynField.SINGLE);
75
                        field.setDescription("JDBC Driver class");
76
                        field.setMandatory(true);
77
                        field.setType(DataTypes.STRING);
78
                        field.setDefaultValue(PostgreSQLLibrary.DEFAULT_JDCB_DRIVER_NAME);
79

    
80

    
81
                }
82
                DYNCLASS = dynClass;
83
        }
84

    
85

    
86
        public String getUrl() {
87
                return PostgreSQLUtils.getInstance().getJdbcUrl(getHost(),
88
                                getPort(),
89
                                getDBName());
90
        }
91

    
92
        public String getTypeName() {
93
                return PostgreSQLResource.NAME;
94
        }
95

    
96
        public Boolean getUseSSL() {
97
                return (Boolean) this.getDynValue(DYNFIELDNAME_USESSL);
98
        }
99

    
100
        public void setUseSSL(Boolean useSSL) {
101
                this.setDynValue(DYNFIELDNAME_USESSL, useSSL);
102
        }
103

    
104
        public void setUseSSL(boolean useSSL) {
105
                this.setDynValue(DYNFIELDNAME_USESSL, new Boolean(useSSL));
106
        }
107

    
108
        protected String getDynClassName() {
109
                return DYNCLASS_NAME;
110
        }
111
}