Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_daldb / src / org / gvsig / fmap / dal / store / postgesql / PostgreSQLStoreParameters.java @ 27753

History | View | Annotate | Download (3.7 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.exception.ValidateDataParametersException;
32
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters;
33
import org.gvsig.tools.ToolsLocator;
34
import org.gvsig.tools.dynobject.DelegatedDynObject;
35
import org.gvsig.tools.dynobject.DynClass;
36
import org.gvsig.tools.dynobject.DynField;
37
import org.gvsig.tools.dynobject.DynObjectManager;
38

    
39
public class PostgreSQLStoreParameters extends JDBCStoreParameters {
40
    public static final String DYNCLASS_NAME = "PostgreSQLStoreParameters";
41

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

    
44

    
45
    protected static void registerDynClass() {
46
                DynObjectManager dynman = ToolsLocator.getDynObjectManager();
47
                DynClass dynClass = dynman.get(DYNCLASS_NAME);
48
                DynField field;
49
                if (dynClass == null) {
50
                        dynClass = dynman.add(DYNCLASS_NAME);
51

    
52
                        dynClass.extend(JDBCStoreParameters.DYNCLASS_NAME);
53

    
54
                        field = dynClass.addDynField(DYNFIELDNAME_USESSL);
55
                        field.setTheTypeOfAvailableValues(DynField.SINGLE);
56
                        field.setDescription("Use SSL");
57
                        field.setType(DataTypes.BOOLEAN);
58

    
59
                }
60

    
61
        }
62

    
63
        public PostgreSQLStoreParameters() {
64
                super();
65
                initialize();
66
        }
67

    
68
        protected void initialize() {
69
                DynObjectManager dynman = ToolsLocator.getDynObjectManager();
70
                DynClass dynClass = dynman.get(DYNCLASS_NAME);
71
                this.delegatedDynObject = (DelegatedDynObject) dynman
72
                                .createDynObject(dynClass);
73
        }
74

    
75

    
76
        public String getDataStoreName() {
77
                return PostgreSQLStoreProvider.NAME;
78
        }
79

    
80
        public String getDescription() {
81
                return PostgreSQLStoreProvider.DESCRIPTION;
82
        }
83

    
84
        public Boolean getUseSSL() {
85
                return (Boolean) this.getDynValue(DYNFIELDNAME_USESSL);
86
        }
87

    
88
        public void setUseSSL(Boolean useSSL) {
89
                this.setDynValue(DYNFIELDNAME_USESSL, useSSL);
90
        }
91

    
92
        public void setUseSSL(boolean useSSL) {
93
                this.setDynValue(DYNFIELDNAME_USESSL, new Boolean(useSSL));
94
        }
95

    
96

    
97

    
98
        public String tableID() {
99
                if (this.getSchema() == null || this.getSchema() == "") {
100
                        return this.getTable();
101
                }
102
                return this.getSchema() + "." + this.getTable();
103
        }
104

    
105

    
106
        public String getDefaultGeometry() {
107
                // TODO Auto-generated method stub
108
                return null;
109
        }
110

    
111
        public void setDefaultGeometry(String geomName) {
112
                this.setDynValue(DYNFIELDNAME_DEFAULTGEOMETRY, geomName);
113
        }
114

    
115
        public String getSourceId() {
116
                // FIXME Arreglar
117
                StringBuilder str = new StringBuilder();
118
                str.append(this.getDataStoreName());
119
                str.append(':');
120
                str.append(getHost());
121
                str.append(':');
122
                str.append(getPort());
123
                str.append(getTable());
124
                return str.toString();
125
        }
126

    
127
        public void validate() throws ValidateDataParametersException {
128
                if (getJDBCDriverClassName() == null) {
129
                        setJDBCDriverClassName(PostgreSQLLibrary.DEFAULT_JDCB_DRIVER_NAME);
130
                }
131
                if (getPort() == null) {
132
                        setPort(new Integer(5432));
133
                }
134
                super.validate();
135
        }
136

    
137
}