Statistics
| Revision:

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

History | View | Annotate | Download (3.58 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

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

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

    
88
        public Boolean getUseSSL() {
89
                return (Boolean) this.getDynValue(DYNFIELDNAME_USESSL);
90
        }
91
        
92
        public String getOraDriverType() {
93
                return (String) this.getDynValue(DYNFIELDNAME_ORADRIVERTYPE);
94
        }
95

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

    
100
        public void setUseSSL(boolean useSSL) {
101
                this.setDynValue(DYNFIELDNAME_USESSL, new Boolean(useSSL));
102
        }
103
        
104
        public void setOraDriverType(String oraDriverType) {
105
                this.setDynValue(DYNFIELDNAME_ORADRIVERTYPE, oraDriverType);
106
        }
107

    
108

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

    
118
                if (getPort() == null) {
119
                        setPort(new Integer(1521));
120
                }
121
                
122
                String oraDriverType = getOraDriverType();
123
                if (oraDriverType.compareToIgnoreCase("THIN")==0 || oraDriverType.compareToIgnoreCase("OCI")==0) {
124
                        this.setOraDriverType(oraDriverType);
125
                }
126
                else{
127
                        this.setOraDriverType("THIN");
128
                }
129
                
130
                
131
                super.validate();
132
        }
133

    
134
        
135

    
136
        
137

    
138
}