Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / extensions / org.gvsig.oracle / src / org / gvsig / fmap / dal / store / oracle / OracleStoreParameters.java @ 30231

History | View | Annotate | Download (3.57 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 Prodevelop S.L. main development
26
 */
27

    
28
package org.gvsig.fmap.dal.store.oracle;
29

    
30
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
31
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters;
32
import org.gvsig.tools.ToolsLocator;
33
import org.gvsig.tools.dynobject.DelegatedDynObject;
34
import org.gvsig.tools.dynobject.DynClass;
35
import org.gvsig.tools.dynobject.DynField;
36
import org.gvsig.tools.dynobject.DynObjectManager;
37

    
38
public class OracleStoreParameters extends JDBCStoreParameters implements
39
                OracleConnectionParameters {
40

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

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

    
53
                        dynClass.extend(JDBCStoreParameters.DYNCLASS_NAME);
54

    
55
                        dynClass.extend(OracleResourceParameters.DYNCLASS_NAME);
56

    
57
                }
58

    
59
        }
60

    
61
        /**
62
         * constructor oracle store parameters
63
         */
64
        public OracleStoreParameters() {
65
                super();
66
                initialize();
67
        }
68

    
69
        /**
70
         * initilize
71
         */
72
        protected void initialize() {
73
                DynObjectManager dynman = ToolsLocator.getDynObjectManager();
74
                DynClass dynClass = dynman.get(DYNCLASS_NAME);
75
                this.delegatedDynObject = (DelegatedDynObject) dynman
76
                                .createDynObject(dynClass);
77
        }
78

    
79
        public String getDataStoreName() {
80
                return OracleStoreProvider.NAME;
81
        }
82

    
83
        public String getDescription() {
84
                return OracleStoreProvider.DESCRIPTION;
85
        }
86

    
87
        public Boolean getUseSSL() {
88
                return (Boolean) this.getDynValue(DYNFIELDNAME_USESSL);
89
        }
90

    
91
        public String getOraDriverType() {
92
                return (String) this.getDynValue(DYNFIELDNAME_ORADRIVERTYPE);
93
        }
94

    
95
        public void setUseSSL(Boolean useSSL) {
96
                this.setDynValue(DYNFIELDNAME_USESSL, useSSL);
97
        }
98

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

    
103
        public void setOraDriverType(String oraDriverType) {
104
                this.setDynValue(DYNFIELDNAME_ORADRIVERTYPE, oraDriverType);
105
        }
106

    
107
        public void validate() throws ValidateDataParametersException {
108
                if (getJDBCDriverClassName() == null) {
109
                        setJDBCDriverClassName(OracleLibrary.DEFAULT_JDCB_DRIVER_NAME);
110
                }
111
                if (getUrl() == null) {
112
                        setUrl(OracleLibrary.getJdbcUrl(getOraDriverType(), getHost(),
113
                                        getPort(), getDBName()));
114
                }
115

    
116
                if (getPort() == null) {
117
                        setPort(new Integer(1521));
118
                }
119

    
120
                String oraDriverType = getOraDriverType();
121
                if (oraDriverType.compareToIgnoreCase("THIN") == 0
122
                                || oraDriverType.compareToIgnoreCase("OCI") == 0) {
123
                        this.setOraDriverType(oraDriverType);
124
                } else {
125
                        this.setOraDriverType("THIN");
126
                }
127

    
128
                super.validate();
129
        }
130

    
131
}