Revision 46542

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/pom.xml
5 5
    <parent>
6 6
        <groupId>org.gvsig</groupId>
7 7
        <artifactId>org.gvsig.expressionevaluator.lib</artifactId>
8
        <version>2.0.381-SNAPSHOT</version>
8
        <version>2.0.380-SNAPSHOT</version>
9 9
    </parent>
10 10
    <groupId>org.gvsig</groupId>
11 11
    <dependencies>
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.swing/org.gvsig.exportto.swing.prov/org.gvsig.exportto.swing.prov.jdbc/pom.xml
43 43
    </dependency>
44 44
    <dependency>
45 45
      <groupId>org.gvsig</groupId>
46
      <artifactId>org.gvsig.fmap.dal.db.jdbc</artifactId>    
47
      <scope>compile</scope>        
48
    </dependency>
49
    <dependency>
50
      <groupId>org.gvsig</groupId>
51 46
      <artifactId>org.gvsig.fmap.geometry.api</artifactId>    
52 47
      <scope>compile</scope>        
53 48
    </dependency>
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.swing/org.gvsig.exportto.swing.prov/org.gvsig.exportto.swing.prov.jdbc/src/main/java/org/gvsig/export/jdbc/swing/panels/IdentifiersOptionsPanel.java
10 10
import org.gvsig.export.swing.JExportProcessPanel;
11 11
import org.gvsig.export.swing.spi.ExportPanel;
12 12
import org.gvsig.export.swing.spi.ExportPanelValidationException;
13
import static org.gvsig.fmap.dal.store.jdbc2.impl.JDBCStoreProviderFactory.CASE_IDENTIFIERS_INDIFERENT;
14
import static org.gvsig.fmap.dal.store.jdbc2.impl.JDBCStoreProviderFactory.CASE_IDENTIFIERS_LOWERCASE;
15
import static org.gvsig.fmap.dal.store.jdbc2.impl.JDBCStoreProviderFactory.CASE_IDENTIFIERS_UPPERCASE;
13
import static org.gvsig.fmap.dal.store.jdbc2.JDBCStoreProviderFactory.CASE_IDENTIFIERS_INDIFERENT;
14
import static org.gvsig.fmap.dal.store.jdbc2.JDBCStoreProviderFactory.CASE_IDENTIFIERS_LOWERCASE;
15
import static org.gvsig.fmap.dal.store.jdbc2.JDBCStoreProviderFactory.CASE_IDENTIFIERS_UPPERCASE;
16 16
import org.gvsig.tools.ToolsLocator;
17 17
import org.gvsig.tools.i18n.I18nManager;
18 18
import org.gvsig.tools.swing.api.ToolsSwingLocator;
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.swing/org.gvsig.exportto.swing.prov/org.gvsig.exportto.swing.prov.jdbc/src/main/java/org/gvsig/export/jdbc/service/ExportJDBCAttributeNamesTranslator.java
6 6
package org.gvsig.export.jdbc.service;
7 7

  
8 8
import org.apache.commons.lang3.StringUtils;
9
import static org.gvsig.fmap.dal.store.jdbc2.impl.JDBCStoreProviderFactory.CASE_IDENTIFIERS_LOWERCASE;
10
import static org.gvsig.fmap.dal.store.jdbc2.impl.JDBCStoreProviderFactory.CASE_IDENTIFIERS_UPPERCASE;
9
import static org.gvsig.fmap.dal.store.jdbc2.JDBCStoreProviderFactory.CASE_IDENTIFIERS_LOWERCASE;
10
import static org.gvsig.fmap.dal.store.jdbc2.JDBCStoreProviderFactory.CASE_IDENTIFIERS_UPPERCASE;
11 11
import org.gvsig.tools.ToolsLocator;
12 12
import org.gvsig.tools.dynobject.DynStruct;
13 13
import org.gvsig.tools.namestranslator.BaseNamesTranslator;
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.swing/org.gvsig.exportto.swing.prov/org.gvsig.exportto.swing.prov.jdbc/src/main/java/org/gvsig/export/jdbc/service/ExportJDBCParametersImpl.java
10 10
import org.gvsig.expressionevaluator.Expression;
11 11
import org.gvsig.fmap.dal.DALLocator;
12 12
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters;
13
import org.gvsig.fmap.dal.store.jdbc2.impl.JDBCStoreProviderFactory;
14
import static org.gvsig.fmap.dal.store.jdbc2.impl.JDBCStoreProviderFactory.CASE_IDENTIFIERS_UPPERCASE;
13
import org.gvsig.fmap.dal.store.jdbc2.JDBCStoreProviderFactory;
14
import static org.gvsig.fmap.dal.store.jdbc2.JDBCStoreProviderFactory.CASE_IDENTIFIERS_UPPERCASE;
15 15
import org.gvsig.tools.ToolsLocator;
16 16
import org.gvsig.tools.dynobject.DynStruct;
17 17
import org.gvsig.tools.persistence.PersistenceManager;
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.newlayer/org.gvsig.newlayer.prov/org.gvsig.newlayer.prov.jdbc/src/main/java/org/gvsig/newlayer/prov/jdbc/NewLayerJDBCProvider.java
185 185

  
186 186
    @Override
187 187
    public String getStoreName() {
188
        return this.parameters.getExplorerParameters().getDataStoreName();
188
        return this.parameters.getExplorerParameters().getProviderName();
189 189
    }
190 190

  
191 191
}
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.newlayer/org.gvsig.newlayer.prov/org.gvsig.newlayer.prov.jdbc/pom.xml
41 41
        </dependency>
42 42
        <dependency>
43 43
            <groupId>org.gvsig</groupId>
44
            <artifactId>org.gvsig.fmap.dal.db.jdbc</artifactId>
45
            <type>jar</type>
46
        </dependency>
47
        <dependency>
48
            <groupId>org.gvsig</groupId>
49 44
            <artifactId>org.gvsig.fmap.dal.swing.api</artifactId>
50 45
            <type>jar</type>
51 46
        </dependency>
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.fmap.control/pom.xml
17 17
      
18 18
     <dependency>
19 19
        <groupId>org.gvsig</groupId>
20
        <artifactId>org.gvsig.fmap.dal.db.jdbc</artifactId>
21
        <scope>compile</scope>
22
    </dependency>
23
     <dependency>
24
        <groupId>org.gvsig</groupId>
25 20
        <artifactId>org.gvsig.projection.cresques.ui</artifactId>
26 21
        <scope>compile</scope>
27 22
    </dependency>
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/spi/DataTransactionServices.java
1
/*
2
 * gvSIG. Desktop Geographic Information System.
3
 * 
4
 * Copyright (C) 2007-2020 gvSIG Association.
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 3
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, see <https://www.gnu.org/licenses/>. 
18
 * 
19
 * For any additional information, do not hesitate to contact us
20
 * at info AT gvsig.com, or visit our website www.gvsig.com.
21
 */
22

  
23
package org.gvsig.fmap.dal.spi;
24

  
25
import org.gvsig.fmap.dal.DataTransaction;
26
import org.gvsig.fmap.dal.exception.DataException;
27
import org.gvsig.tools.dispose.Disposable;
28

  
29
/**
30
 *
31
 * @author gvSIG Team
32
 */
33
public interface DataTransactionServices extends DataTransaction {
34
    
35
    public interface ConnectionService<T> extends Disposable {
36
        public String getId();
37
        
38
//        public void begin() throws DataException;
39

  
40
        public void finish() throws DataException;
41

  
42
        public void abort() throws DataException;
43

  
44
        public T get();
45
    }
46
   
47
    public static ConnectionService getConnection(DataTransactionServices transaction, String id) {
48
        if( transaction==null ) {
49
            return null;
50
        }
51
        return transaction.getConnection(id);
52
    }
53
    
54
    public void addConnection(ConnectionService connection);
55
    
56
    public ConnectionService getConnection(String id);
57
    
58
    public void removeConnection(String id);
59
    
60
    public boolean existsConnection(String id);
61
    
62
}
63
    
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultEditableFeatureAttributeDescriptor.java
648 648
            case "availablevaluesfilter":
649 649
                this.setAvailableValuesFilter(DataTypeUtils.toString(value, null));
650 650
                break;
651
            case "format":
652
            case "defaultformat":
653
                this.setDefaultFormat(DataTypeUtils.toString(value, null));
651 654
            default:
652 655
                throw new IllegalArgumentException("Name attribute '" + name + "' not valid.");
653 656
        }
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeatureAttributeDescriptor.java
2365 2365

  
2366 2366
    @Override
2367 2367
    public String format(Object value) {
2368
        if(value == null){
2369
            return "";
2370
        }
2368 2371
        try {
2369 2372
            if( StringUtils.isBlank(this.defaultFormat)) {
2370 2373
                if( this.locale==null ) { // !this.hasLocale()
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/pom.xml
84 84
        <artifactId>${org.gvsig.proj.lib.impl}</artifactId>
85 85
        <scope>test</scope>
86 86
    </dependency>
87
    <dependency>
87
<!--    <dependency>
88 88
        <groupId>org.gvsig</groupId>
89 89
        <artifactId>${org.gvsig.proj.lib.impl}</artifactId>
90 90
        <scope>test</scope>
91
    </dependency>-->
92
    <dependency>
93
      <groupId>org.gvsig</groupId>
94
      <artifactId>org.gvsig.fmap.dal.swing.api</artifactId>
95
      <scope>test</scope>
91 96
    </dependency>
97
    <dependency>
98
      <groupId>org.gvsig</groupId>
99
      <artifactId>org.gvsig.fmap.dal.swing.impl</artifactId>
100
      <scope>test</scope>
101
    </dependency>
92 102
  </dependencies>
93 103

  
94 104

  
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.fmap.dal.store.jdbc.JDBCLibrary
2 1
org.gvsig.fmap.dal.store.jdbc2.JDBCLibrary
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc/JDBCServerExplorer.java
1
package org.gvsig.fmap.dal.store.jdbc;
2

  
3
import java.util.List;
4
import org.gvsig.fmap.dal.DataServerExplorer_v2;
5
import org.gvsig.fmap.dal.DataStore;
6
import org.gvsig.fmap.dal.DataStoreParameters;
7
import org.gvsig.fmap.dal.NewDataStoreParameters;
8
import org.gvsig.fmap.dal.exception.DataException;
9
import org.gvsig.fmap.dal.exception.RemoveException;
10
import org.gvsig.fmap.dal.feature.FeatureType;
11
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCExecuteSQLException;
12

  
13
public interface JDBCServerExplorer extends DataServerExplorer_v2 {
14

  
15
    @Override
16
    boolean add(String providerName, NewDataStoreParameters ndsp, boolean overwrite) throws DataException;
17

  
18
    @Override
19
    boolean canAdd();
20

  
21
    @Override
22
    JDBCStoreParameters get(String name) throws DataException;
23

  
24
    JDBCNewStoreParameters getAddParameters() throws DataException;
25

  
26
    @Override
27
    List<String> getDataStoreProviderNames();
28

  
29
    FeatureType getFeatureType(DataStoreParameters dsp) throws DataException;
30

  
31
    DataStoreParameters getOpenParameters() throws DataException;
32

  
33
    @Override
34
    String getProviderName();
35

  
36
    String getStoreName();
37

  
38
    @Override
39
    List<DataStoreParameters> list(int mode) throws DataException;
40

  
41
    DataStore open(DataStoreParameters dsp) throws DataException;
42

  
43
    @Override
44
    void remove(DataStoreParameters dsp) throws RemoveException;
45

  
46
    void updateTableStatistics(String database, String schema, String table) throws JDBCExecuteSQLException;
47
    
48
    public Object execute(String sql);
49
  
50
}
51

  
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc/JDBCResource.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or modify it under
7
 * the terms of the GNU General Public License as published by the Free Software
8
 * Foundation; either version 3 of the License, or (at your option) any later
9
 * version.
10
 *
11
 * This program is distributed in the hope that it will be useful, but WITHOUT
12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14
 * details.
15
 *
16
 * You should have received a copy of the GNU General Public License along with
17
 * this program; if not, write to the Free Software Foundation, Inc., 51
18
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us at info AT
21
 * gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.fmap.dal.store.jdbc;
24

  
25
import java.sql.Connection;
26
import java.sql.SQLException;
27
import java.text.MessageFormat;
28

  
29
import javax.sql.DataSource;
30

  
31
import org.apache.commons.dbcp.BasicDataSource;
32
import org.apache.commons.lang3.StringUtils;
33
import org.gvsig.fmap.dal.exception.DataException;
34
import org.gvsig.fmap.dal.exception.InitializeException;
35
import org.gvsig.fmap.dal.resource.ResourceParameters;
36
import org.gvsig.fmap.dal.resource.db.AbstractDBResourceNoBlocker;
37
import org.gvsig.fmap.dal.resource.exception.AccessResourceException;
38
import org.gvsig.fmap.dal.resource.exception.ResourceException;
39
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCDriverClassNotFoundException;
40
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCSQLException;
41
import org.slf4j.Logger;
42
import org.slf4j.LoggerFactory;
43

  
44
public class JDBCResource extends AbstractDBResourceNoBlocker {
45

  
46
    final static private Logger logger = LoggerFactory.getLogger(JDBCResource.class);
47

  
48
    public final static String NAME = "JDBCResource";
49
    public static final String DESCRIPTION = "JDBC Connection";
50

  
51
    protected DataSource dataSource = null;
52

  
53
    public JDBCResource(
54
            JDBCResourceParameters parameters
55
    ) throws InitializeException {
56
        super(parameters);
57
        registerJDBCDriver();
58
    }
59

  
60
    /**
61
     * Registra/Carga el driver de JDBC.
62
     * 
63
     * Debe ser sobreescrita en cada proveedor de datos para asegurar que se
64
     * tegna acceso al driver.
65
     * 
66
     * @throws InitializeException 
67
     */
68
    protected void registerJDBCDriver() throws InitializeException {
69
        String className = this.getParameters().getJDBCDriverClassName();
70
        if (className == null) {
71
            return;
72
        }
73
        try {
74
            Class theClass = Class.forName(className);
75
            if (theClass == null) {
76
                throw new JDBCDriverClassNotFoundException(this.getName(), className);
77
            }
78
        } catch (Exception e) {
79
            throw new InitializeException(e);
80
        }
81
    }
82

  
83
    /**
84
     * Crea el JDBC DataSource a partir de la informacion de los parametros
85
     * del recurso.
86
     * 
87
     * Debe ser sobreescrita en cada proveedor de datos para asegurar que se
88
     * tenga acceso al driver.
89
     * 
90
     * @return 
91
     */
92
    protected DataSource createDataSource() {
93
        JDBCResourceParameters jdbcParams = this.getParameters();
94
        BasicDataSource dataSource = new BasicDataSource();
95
        dataSource.setDriverClassName(jdbcParams.getJDBCDriverClassName());
96
        dataSource.setUsername(jdbcParams.getUser());
97
        dataSource.setPassword(jdbcParams.getPassword());
98
        dataSource.setUrl(jdbcParams.getUrl());
99

  
100
        dataSource.setMaxWait(60L * 1000); // FIXME
101

  
102
//                FIXME Set Pool parameters:
103
//		dataSource.setMaxActive(maxActive);
104
//		dataSource.setMaxIdle(maxActive);
105
//		dataSource.setMaxOpenPreparedStatements(maxActive);
106
//		dataSource.setMaxWait(maxActive);
107
//		dataSource.setInitialSize(initialSize);
108
//		dataSource.setDefaultReadOnly(defaultReadOnly);
109
//		dataSource.setDefaultTransactionIsolation(defaultTransactionIsolation);
110
//		dataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
111
//		dataSource.setMinIdle(minIdle);
112
//		dataSource.setTestOnBorrow(testOnBorrow);
113
//		dataSource.setTestOnReturn(testOnReturn);
114
//		dataSource.setTestWhileIdle(testOnReturn);
115
//		dataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
116
//
117
//		dataSource.setAccessToUnderlyingConnectionAllowed(allow);
118
//		dataSource.setLoginTimeout(seconds);
119
//		dataSource.setLogWriter(out);
120
        return dataSource;
121
    }
122

  
123

  
124
    @Override
125
    public JDBCResourceParameters getParameters() {
126
        return (JDBCResourceParameters) super.getParameters();
127
    }
128

  
129
    @Override
130
    public String getName() throws AccessResourceException {
131
        JDBCResourceParameters params = this.getParameters();
132
        return MessageFormat.format("JDBCResource({0},{1},{2},{3},{4})",
133
                new Object[]{
134
                    params.getJDBCDriverClassName(),
135
                    params.getHost(),
136
                    params.getPort(),
137
                    params.getUser(),
138
                    params.getDBName()
139
                }
140
        );
141
    }
142
    
143
    public Connection getJDBCConnection() throws AccessResourceException {
144
        return (Connection) get();
145
    }
146

  
147
    public void closeConnection(Connection connection) {
148
        try {
149
            logger.trace("before-close connection" + this.getStatusInformation());
150
            connection.close();
151
            logger.trace("after close connection " + this.getStatusInformation());
152
        } catch (Exception ex) {
153
            logger.warn("Problems closing connection.", ex);
154
        }
155
    }
156

  
157
    protected void debugPoolStatus(String src) {
158
        if (logger.isTraceEnabled()) {
159
            logger.trace(src + "  " + this.getStatusInformation());
160
        }
161
    }
162

  
163
    public String getStatusInformation() {
164
        if (!(dataSource instanceof BasicDataSource)) {
165
            return "Connected: " + this.isConnected();
166
        }
167
        BasicDataSource ds = (BasicDataSource) dataSource;
168
        String s = MessageFormat.format("Conneted {0}, actives {1}/{2}, idle {3}/{4}",
169
            this.isConnected(),
170
            ds.getNumActive(),
171
            ds.getMaxActive(),
172
            ds.getNumIdle(),
173
            ds.getMaxIdle()
174
        );
175
        return s;
176
    }
177

  
178
    @Override
179
    protected synchronized Object getTheConnection() throws DataException {
180
        try {
181
            Object conn = this.dataSource.getConnection();
182
            debugPoolStatus("getTheConnection");
183
            return conn;
184
        } catch (SQLException e) {
185
            throw new JDBCSQLException(e);
186
        }
187
    }
188

  
189
    @Override
190
    public boolean isThis(ResourceParameters parameters)
191
            throws ResourceException {
192
        if (!super.isThis(parameters)) {
193
            return false;
194
        }
195
        JDBCResourceParameters params = (JDBCResourceParameters) parameters;
196
        String dbName = params.getDBName();
197
        String myDbName = this.getParameters().getDBName();
198
        if ( !StringUtils.equals(dbName, myDbName) ) {
199
            return false;
200
        }
201

  
202
        String driver = params.getJDBCDriverClassName();
203
        String myDriver = getParameters().getJDBCDriverClassName();
204
        if ( !StringUtils.equals(driver, myDriver) ) {
205
            return false;
206
        }
207
        return true;
208
    }
209

  
210
    @Override
211
    public boolean isConnected() {
212
        if (dataSource == null) {
213
            return false;
214
        }
215
        if (dataSource instanceof BasicDataSource) {
216
            return ((BasicDataSource) dataSource).getNumActive() > 0
217
                    || ((BasicDataSource) dataSource).getNumIdle() > 0;
218
        }
219
        return true;
220
    }
221

  
222
    @Override
223
    protected void connectToDB() throws DataException {
224
        if (this.dataSource != null) {
225
            return;
226
        }
227
        this.dataSource = this.createDataSource();
228
    }
229

  
230
    public void beginUse() {
231
        this.executeBegins();
232
    }
233

  
234
    public void endUse() {
235
        this.executeEnds();
236
    }
237
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc/JDBCNewStoreParameters.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or modify it under
7
 * the terms of the GNU General Public License as published by the Free Software
8
 * Foundation; either version 3 of the License, or (at your option) any later
9
 * version.
10
 *
11
 * This program is distributed in the hope that it will be useful, but WITHOUT
12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14
 * details.
15
 *
16
 * You should have received a copy of the GNU General Public License along with
17
 * this program; if not, write to the Free Software Foundation, Inc., 51
18
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us at info AT
21
 * gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.fmap.dal.store.jdbc;
24

  
25
import org.apache.commons.lang3.StringUtils;
26
import org.gvsig.fmap.dal.store.db.DBNewStoreParameters;
27
import static org.gvsig.fmap.dal.store.jdbc.JDBCConnectionParameters.CATALOG_PARAMTER_NAME;
28
import static org.gvsig.fmap.dal.store.jdbc.JDBCConnectionParameters.JDBC_DRIVER_CLASS_PARAMTER_NAME;
29
import static org.gvsig.fmap.dal.store.jdbc.JDBCConnectionParameters.SCHEMA_PARAMTER_NAME;
30

  
31
public class JDBCNewStoreParameters extends DBNewStoreParameters implements
32
        JDBCConnectionParameters {
33

  
34
    public static final String PARAMETERS_DEFINITION_NAME = "JDBCNewStoreParameters";
35

  
36
    public JDBCNewStoreParameters() {
37
        super(PARAMETERS_DEFINITION_NAME, JDBCStoreProvider.NAME);
38
    }
39

  
40
    protected JDBCNewStoreParameters(String parametersDefinitionName, String providerName) {
41
        super(parametersDefinitionName, providerName);
42
    }
43

  
44
    /**
45
     * Set <code>JDBC Driver class name</code> parameter
46
     *
47
     * @param className
48
     */
49
    public void setJDBCDriverClassName(String className) {
50
        this.setDynValue(JDBC_DRIVER_CLASS_PARAMTER_NAME, className);
51
    }
52

  
53
    public String getJDBCDriverClassName() {
54
        return (String) this.getDynValue(JDBC_DRIVER_CLASS_PARAMTER_NAME);
55
    }
56

  
57
    public String getCatalog() {
58
        return (String) this.getDynValue(CATALOG_PARAMTER_NAME);
59
    }
60

  
61
    /**
62
     * Set <code>catalog</code> parameter
63
     *
64
     * @param className
65
     */
66
    public void setCatalog(String catalog) {
67
        this.setDynValue(CATALOG_PARAMTER_NAME, catalog);
68
    }
69

  
70
    public String getSchema() {
71
        return (String) this.getDynValue(SCHEMA_PARAMTER_NAME);
72
    }
73

  
74
    /**
75
     * Set <code>schema</code> parameter
76
     *
77
     * @param className
78
     */
79
    public void setSchema(String schema) {
80
        this.setDynValue(SCHEMA_PARAMTER_NAME, schema);
81
    }
82

  
83
    public String getUrl() {
84
        return (String) this.getDynValue(URL_PARAMTER_NAME);
85
    }
86

  
87
    @Override
88
    public int getBatchSize() {
89
        try {
90
            return (int) this.getDynValue(BATCH_SIZE_PARAMETER_NAME);
91
        } catch(Exception ex) {
92
            return DEFAULT_BATCH_SIZE;
93
        }
94
    }
95

  
96
    /**
97
     * Set <code>JDBC connection url</code> parameter
98
     *
99
     * @param url
100
     */
101
    public void setUrl(String url) {
102
        this.setDynValue(URL_PARAMTER_NAME, url);
103
    }
104

  
105
    /**
106
     * Return table <code>name</code> or <code>schema.tableName</code> if
107
     * <code>schema</code> parameter is set.
108
     *
109
     * @return
110
     */
111
    public String tableID() {
112
        if (this.getSchema() == null || this.getSchema() == "") {
113
            return escapeName(this.getTable());
114
        }
115
        return escapeName(this.getSchema()) + "." + escapeName(this.getTable());
116
    }
117

  
118
    protected String escapeName(String name) {
119
        return "\"".concat(name).concat("\"");
120
    }
121

  
122
    public String getSelectRole() {
123
        String value = (String) this.getDynValue("SelectRole");
124
        return StringUtils.defaultIfBlank(value, null);
125
    }
126
    
127
    public String getInsertRole() {
128
        String value = (String) this.getDynValue("InsertRole");
129
        return StringUtils.defaultIfBlank(value, null);
130
    }
131
    
132
    
133
    public String getUpdateRole() {
134
        String value = (String) this.getDynValue("UpdateRole");
135
        return StringUtils.defaultIfBlank(value, null);
136
    }
137
    
138
    
139
    public String getDeleteRole() {
140
        String value = (String) this.getDynValue("DeleteRole");
141
        return StringUtils.defaultIfBlank(value, null);
142
    }
143
    
144
    
145
    public String getTruncateRole() {
146
        String value = (String) this.getDynValue("TruncateRole");
147
        return StringUtils.defaultIfBlank(value, null);
148
    }
149
    
150
    
151
    public String getReferenceRole() {
152
        String value = (String) this.getDynValue("ReferenceRole");
153
        return StringUtils.defaultIfBlank(value, null);
154
    }
155
    
156
    
157
    public String getTriggerRole() {
158
        String value = (String) this.getDynValue("TriggerRole");
159
        return StringUtils.defaultIfBlank(value, null);
160
    }
161
    
162
    
163
    public String getAllRole() {
164
        String value = (String) this.getDynValue("AllRole");
165
        return StringUtils.defaultIfBlank(value, null);
166
    }
167
    
168
    
169
    public String getPostCreatingStatement() {
170
        String value = (String) this.getDynValue("PostCreatingStatement");
171
        return StringUtils.defaultIfBlank(value, null);
172
    }
173

  
174
    
175
    public void setSelectRole(String role) {
176
        this.setDynValue("SelectRole", role);
177
    }
178
    
179
    public void setInsertRole(String role) {
180
        this.setDynValue("InsertRole", role);
181
    }
182
    
183
    public void setUpdateRole(String role) {
184
        this.setDynValue("UpdateRole", role);
185
    }
186
    
187
    public void setDeleteRole(String role) {
188
        this.setDynValue("DeleteRole", role);
189
    }
190
    
191
    public void setTruncateRole(String role) {
192
        this.setDynValue("TruncateRole", role);
193
    }
194
    
195
    public void setReferenceRole(String role) {
196
        this.setDynValue("ReferenceRole", role);
197
    }
198
    
199
    public void setTriggerRole(String role) {
200
        this.setDynValue("TriggerRole", role);
201
    }
202
    
203
    public void setAllRole(String role) {
204
        this.setDynValue("AllRole", role);
205
    }
206
    
207
    public void setPostCreatingStatement(String statement) {
208
        this.setDynValue("PostCreatingStatement", statement);
209
    }
210
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc/JDBCResourceParameters.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24

  
25
package org.gvsig.fmap.dal.store.jdbc;
26

  
27
import org.gvsig.fmap.dal.resource.db.DBResourceParameters;
28

  
29
public class JDBCResourceParameters extends DBResourceParameters
30
		implements JDBCConnectionParameters {
31

  
32
    protected static final String PARAMETERS_DEFINITION_NAME = "JDBCResourceParameters";
33

  
34
	protected JDBCResourceParameters(String parametersDefinitionName, String providerName) {
35
		super(parametersDefinitionName,providerName);
36
	}
37
	
38
	public JDBCResourceParameters() {
39
		this(PARAMETERS_DEFINITION_NAME, JDBCResource.NAME);
40
	}
41

  
42
    public JDBCResourceParameters(String parametersDefinitionName, String providerName, 
43
    		String url, String host, Integer port,
44
			String dbName, String user, String password, 
45
			String jdbcDriverClassName) {
46
		this(parametersDefinitionName,providerName);
47

  
48
		this.setUrl(url);
49
		this.setHost(host);
50
		this.setPort(port);
51
		this.setDBName(dbName);
52
		this.setUser(user);
53
		this.setPassword(password);
54
		this.setJDBCDriverClassName(jdbcDriverClassName);
55
	}
56

  
57
    public JDBCResourceParameters(String url, String host, Integer port,
58
			String dbName,
59
			String user, String password, String jdbcDriverClassName) {
60
		this(PARAMETERS_DEFINITION_NAME, JDBCResource.NAME, url, host, port, dbName, user, password, jdbcDriverClassName);
61
	}
62

  
63
	public void setJDBCDriverClassName(String className) {
64
		this.setDynValue(JDBC_DRIVER_CLASS_PARAMTER_NAME, className);
65
	}
66

  
67
	public String getJDBCDriverClassName() {
68
		return (String) this.getDynValue(JDBC_DRIVER_CLASS_PARAMTER_NAME);
69
	}
70

  
71
	public String getCatalog() {
72
		return (String) this.getDynValue(CATALOG_PARAMTER_NAME);
73
	}
74

  
75
	public void setCatalog(String catalog) {
76
		this.setDynValue(CATALOG_PARAMTER_NAME, catalog);
77
	}
78

  
79
	public String getSchema() {
80
		return (String) this.getDynValue(SCHEMA_PARAMTER_NAME);
81
	}
82

  
83
	public void setSchema(String schema) {
84
		this.setDynValue(SCHEMA_PARAMTER_NAME, schema);
85
	}
86

  
87
	public String getUrl() {
88
		return (String) this.getDynValue(URL_PARAMTER_NAME);
89
	}
90

  
91
	public void setUrl(String url) {
92
		this.setDynValue(URL_PARAMTER_NAME, url);
93
	}
94

  
95
        @Override
96
        public int getBatchSize() {
97
            try {
98
                return (int) this.getDynValue(BATCH_SIZE_PARAMETER_NAME);
99
            } catch(Exception ex) {
100
                return DEFAULT_BATCH_SIZE;
101
            }
102
        }
103

  
104
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc/JDBCServerExplorerParameters.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.dal.store.jdbc;
25

  
26
import org.apache.commons.lang3.StringUtils;
27
import org.gvsig.fmap.dal.DataServerExplorerParameters;
28
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorerParameters;
29

  
30
public class JDBCServerExplorerParameters extends
31
		DBServerExplorerParameters implements JDBCConnectionParameters {
32
	
33
	public static final String PARAMETERS_DEFINITION_NAME = "JDBCServerExplorerParameters";
34

  
35
	public static final String SHOWINFORMATIONDBTABLES_PARAMTER_NAME = "showInformationDBTables";
36

  
37
	public JDBCServerExplorerParameters() {
38
		super(PARAMETERS_DEFINITION_NAME, JDBCServerExplorerBase.NAME);
39
	}
40
	
41
	public JDBCServerExplorerParameters(String parametersDefinitionName, String name) {
42
		super(parametersDefinitionName, name);
43
	}
44

  
45
	public void setJDBCDriverClassName(String className) {
46
		this.setDynValue(JDBC_DRIVER_CLASS_PARAMTER_NAME, className);
47
	}
48

  
49
	public String getJDBCDriverClassName() {
50
		return (String) this.getDynValue(JDBC_DRIVER_CLASS_PARAMTER_NAME);
51
	}
52

  
53
	public String getCatalog() {
54
		return (String) this.getDynValue(CATALOG_PARAMTER_NAME);
55
	}
56

  
57
	public void setCatalog(String catalog) {
58
		this.setDynValue(CATALOG_PARAMTER_NAME, catalog);
59
	}
60

  
61
	public String getSchema() {
62
		return (String) this.getDynValue(SCHEMA_PARAMTER_NAME);
63
	}
64

  
65
	public void setSchema(String schema) {
66
		this.setDynValue(SCHEMA_PARAMTER_NAME, schema);
67
	}
68

  
69
	public void setShowInformationDBTables(boolean show){
70
		this.setShowInformationDBTables(new Boolean(show));
71
	}
72

  
73
	public void setShowInformationDBTables(Boolean show) {
74
		this.setDynValue(SHOWINFORMATIONDBTABLES_PARAMTER_NAME, show);
75
	}
76

  
77
	public Boolean getShowInformationDBTables() {
78
		return (Boolean) this.getDynValue(SHOWINFORMATIONDBTABLES_PARAMTER_NAME);
79
	}
80

  
81
	public String getUrl() {
82
		return (String) this.getDynValue(URL_PARAMTER_NAME);
83
	}
84

  
85
	public void setUrl(String url) {
86
		this.setDynValue(URL_PARAMTER_NAME, url);
87
	}
88

  
89
        @Override
90
        public int getBatchSize() {
91
            try {
92
                return (int) this.getDynValue(BATCH_SIZE_PARAMETER_NAME);
93
            } catch(Exception ex) {
94
                return DEFAULT_BATCH_SIZE;
95
            }
96
        }
97

  
98
    @Override
99
    public boolean isTheSameServerExplorer(DataServerExplorerParameters params) {
100
        if(!(params instanceof JDBCServerExplorerParameters)){
101
            return false;
102
        }
103
        return StringUtils.equals(this.getUrl(), ((JDBCServerExplorerParameters)params).getUrl());
104
    }
105

  
106
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc/JDBCStoreParameters.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24

  
25
package org.gvsig.fmap.dal.store.jdbc;
26

  
27
import java.text.MessageFormat;
28
import org.apache.commons.lang3.StringUtils;
29
import org.gvsig.fmap.dal.DataStoreParameters;
30
import org.gvsig.fmap.dal.store.db.DBStoreParameters;
31

  
32
/**
33
 * Parameters class for JDBC generic provider
34
 *
35
 */
36
public class JDBCStoreParameters extends DBStoreParameters
37
		implements JDBCConnectionParameters {
38

  
39
	public static final String BATCHSIZE_PARAMTER_NAME = "batchSize";
40
    
41
//	public static final String PARAMETERS_DEFINITION_NAME = "JDBCStoreParameters";
42

  
43
	public JDBCStoreParameters() {
44
		super(
45
                        JDBCLibrary.NAME + "StoreParameters",
46
                        JDBCLibrary.NAME
47
                );
48
	}
49

  
50
	protected JDBCStoreParameters(String parametersDefinitionName) {
51
		super(
52
                        parametersDefinitionName,
53
                        JDBCLibrary.NAME
54
                );
55
	}
56

  
57
	public JDBCStoreParameters(String parametersDefinitionName, String providerName) {
58
		super(parametersDefinitionName,providerName);
59
	}
60

  
61
	public boolean isValid() {
62
		return this.getHost() != null;
63
	}
64

  
65
	public String getHost() {
66
		return (String) this.getDynValue(HOST_PARAMTER_NAME);
67
	}
68

  
69
	public Integer getPort() {
70
		return (Integer) this.getDynValue(PORT_PARAMTER_NAME);
71
	}
72

  
73
        @Override
74
        public int getBatchSize() {
75
            try {
76
                return (int) this.getDynValue(BATCH_SIZE_PARAMETER_NAME);
77
            } catch(Exception ex) {
78
                return DEFAULT_BATCH_SIZE;
79
            }
80
        }
81
        
82
	public String getDBName() {
83
		return (String) this.getDynValue(DBNAME_PARAMTER_NAME);
84
	}
85

  
86
	public String getUser() {
87
		return (String) this.getDynValue(USER_PARAMTER_NAME);
88
	}
89

  
90
	public String getPassword() {
91
		return (String) this.getDynValue(PASSWORD_PARAMTER_NAME);
92
	}
93

  
94
	public void setHost(String host) {
95
		this.setDynValue(HOST_PARAMTER_NAME, host);
96
	}
97

  
98
	public void setPort(int port) {
99
		this.setDynValue(PORT_PARAMTER_NAME, new Integer(port));
100
	}
101

  
102
	public void setPort(Integer port) {
103
		this.setDynValue(PORT_PARAMTER_NAME, port);
104
	}
105

  
106
	public void setDBName(String dbName) {
107
		this.setDynValue(DBNAME_PARAMTER_NAME, dbName);
108
	}
109

  
110
	public void setUser(String user) {
111
		this.setDynValue(USER_PARAMTER_NAME, user);
112
	}
113

  
114
	public void setPassword(String password) {
115
		this.setDynValue(PASSWORD_PARAMTER_NAME, password);
116
	}
117

  
118
	/**
119
	 * Set <code>JDBC Driver class name</code> parameter
120
	 *
121
	 * @param className
122
	 */
123
	public void setJDBCDriverClassName(String className) {
124
		this.setDynValue(JDBC_DRIVER_CLASS_PARAMTER_NAME, className);
125
	}
126

  
127
	public String getJDBCDriverClassName() {
128
		return (String) this.getDynValue(JDBC_DRIVER_CLASS_PARAMTER_NAME);
129
	}
130

  
131
	public String getCatalog() {
132
		return (String) this.getDynValue(CATALOG_PARAMTER_NAME);
133
	}
134

  
135

  
136
	/**
137
	 * Set <code>catalog</code> parameter
138
	 *
139
	 * @param className
140
	 */
141
	public void setCatalog(String catalog) {
142
		this.setDynValue(CATALOG_PARAMTER_NAME, catalog);
143
	}
144

  
145
	public String getSchema() {
146
		return (String) this.getDynValue(SCHEMA_PARAMTER_NAME);
147
	}
148

  
149
	/**
150
	 * Set <code>schema</code> parameter
151
	 *
152
	 * @param className
153
	 */
154
	public void setSchema(String schema) {
155
		this.setDynValue(SCHEMA_PARAMTER_NAME, schema);
156
	}
157

  
158
	public String getTable() {
159
		return (String) this.getDynValue(TABLE_PARAMTER_NAME);
160
	}
161

  
162
	public void setTable(String table) {
163
		this.setDynValue(TABLE_PARAMTER_NAME, table);
164
	}
165

  
166
	public String getFieldsString() {
167
		return (String) this.getDynValue(FIELDS_PARAMTER_NAME);
168
	}
169

  
170
	public String[] getFields() {
171
		String fields = (String) this.getDynValue(FIELDS_PARAMTER_NAME);
172
		if (fields == null) {
173
			return null;
174
		}
175
		// FIXME check for fields with spaces and special chars
176
		return fields.split(",");
177
	}
178

  
179
	public void setFields(String fields) {
180
		this.setDynValue(FIELDS_PARAMTER_NAME, fields);
181
	}
182

  
183
	public void setFields(String[] fields) {
184
		StringBuilder str = new StringBuilder();
185
		for (int i = 0; i < fields.length - 1; i++) {
186
			str.append(fields[i]);
187
			str.append(",");
188
		}
189
		str.append(fields[fields.length - 1]);
190

  
191
		this.setDynValue(FIELDS_PARAMTER_NAME, str.toString());
192
	}
193

  
194
	public String getSQL() {
195
		return (String) this.getDynValue(SQL_PARAMTER_NAME);
196
	}
197

  
198
	public void setSQL(String sql) {
199
		this.setDynValue(SQL_PARAMTER_NAME, sql);
200
	}
201

  
202
	public String getBaseFilter() {
203
		return (String) this.getDynValue(BASEFILTER_PARAMTER_NAME);
204
	}
205

  
206
	public void setBaseFilter(String initialFilter) {
207
		this.setDynValue(BASEFILTER_PARAMTER_NAME, initialFilter);
208
	}
209

  
210
	public String getBaseOrder() {
211
		return (String) this.getDynValue(BASEORDER_PARAMTER_NAME);
212
	}
213

  
214
	public void setBaseOrder(String order) {
215
		this.setDynValue(BASEORDER_PARAMTER_NAME, order);
216
	}
217

  
218
	public String getPkFieldsString() {
219
		return (String) this.getDynValue(PKFIELDS_PARAMTER_NAME);
220
	}
221

  
222
	public String[] getPkFields() {
223
		String fields = (String) this.getDynValue(PKFIELDS_PARAMTER_NAME);
224
		if (fields == null) {
225
			return null;
226
		}
227
		// FIXME check for fields with spaces and special chars
228
		return fields.split(",");
229
	}
230

  
231
	public void setPkFields(String fields) {
232
		this.setDynValue(PKFIELDS_PARAMTER_NAME, fields);
233
	}
234

  
235
	public void setPkFields(String[] fields) {
236
		StringBuilder str = new StringBuilder();
237
		for (int i = 0; i < fields.length - 1; i++) {
238
			str.append(fields[i]);
239
			str.append(",");
240
		}
241
		str.append(fields[fields.length - 1]);
242

  
243
		this.setDynValue(PKFIELDS_PARAMTER_NAME, str.toString());
244
	}
245

  
246
	/**
247
	 * Return table <code>name</code> or <code>schema.tableName</code> if
248
	 * <code>schema</code> parameter is set.
249
	 *
250
	 * @return
251
	 */
252
	public String tableID() {
253
		if (  StringUtils.isEmpty(this.getSchema()) ) {
254
            return escapeName(this.getTable());
255
		}
256
        return escapeName(this.getSchema()) + "." + escapeName(this.getTable());
257
	}
258

  
259
    protected String escapeName(String name) {
260
        return "\"".concat(name).concat("\"");
261
    }
262

  
263
	/**
264
	 * Compound a string that can identify the source
265
	 *
266
	 * @return
267
	 */
268
	public String getSourceId() {
269
		if (getTable() != null) {
270
			return MessageFormat.format(
271
					"provider={0}:url=\"{1}\":table=\"{2}\":user={3}:driverclass={4}", 
272
					this.getDataStoreName(),
273
					this.getUrl(),
274
					this.getTable(),
275
					this.getUser(),
276
					this.getJDBCDriverClassName()
277
			);
278
		}
279
		return MessageFormat.format(
280
				"provider={0}:url=\"{1}\":sql=\"{2}\":user={3}:driverclass={4}", 
281
				this.getDataStoreName(),
282
				this.getUrl(),
283
				this.getSQL(),
284
				this.getUser(),
285
				this.getJDBCDriverClassName()
286
		);
287
	}
288

  
289
	public String getUrl() {
290
		return (String) this.getDynValue(URL_PARAMTER_NAME);
291
	}
292

  
293
	/**
294
	 * Set <code>JDBC connection url</code> parameter
295
	 *
296
	 * @param url
297
	 */
298
	public void setUrl(String url) {
299
		this.setDynValue(URL_PARAMTER_NAME, url);
300
	}
301

  
302
    @Override
303
    public JDBCStoreParameters getCopy() {
304
        return (JDBCStoreParameters) super.getCopy();
305
    }
306
    
307
    public void setBatchSize(int batchSize) {
308
            this.setDynValue(BATCH_SIZE_PARAMETER_NAME, batchSize);
309
    }
310

  
311
    @Override
312
    public boolean isTheSameStore(DataStoreParameters params) {
313
        if(!(params instanceof JDBCStoreParameters)) {
314
            return false;
315
        } 
316
        if(!(StringUtils.equals(((JDBCStoreParameters)params).getTable(), this.getTable()))){
317
            return false;
318
        }
319
        if(!(StringUtils.equals(((JDBCStoreParameters)params).getSchema(), this.getSchema()))){
320
            return false;
321
        }
322
        if(!(StringUtils.equals(((JDBCStoreParameters)params).getSQL(), this.getSQL()))){
323
            return false;
324
        }
325
        return true;
326
    }
327

  
328
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc/JDBCConnectionParameters.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.dal.store.jdbc;
25

  
26
import org.gvsig.fmap.dal.serverexplorer.db.DBConnectionParameter;
27

  
28
/**
29
 * Interface JDBC Store Parameters
30
 *
31
 * @author jmvivo
32
 *
33
 */
34
public interface JDBCConnectionParameters extends DBConnectionParameter {
35

  
36
	/**
37
	 * Parameter name for <code>JDBC driver class name</code>
38
	 */
39
	public static final String JDBC_DRIVER_CLASS_PARAMTER_NAME = "jdbcdriverclass";
40

  
41
	/**
42
	 * Parameter name for <code>catalog</code> 
43
	 */
44
	public static final String CATALOG_PARAMTER_NAME = "catalog";
45

  
46
	/**
47
	 * Parameter name for <code>schema</code> 
48
	 */
49
	public static final String SCHEMA_PARAMTER_NAME = "schema";
50

  
51
	/**
52
	 * Parameter name for <code>JDBC connection URL</code>
53
	 */
54
	public static final String URL_PARAMTER_NAME = "url";
55

  
56
	public static final String BATCH_SIZE_PARAMETER_NAME = "batchSize";
57
        
58
        public static final int DEFAULT_BATCH_SIZE = 500;
59
        
60
	/**
61
	 * Return <code>JDBC driver class name</code> parameter
62
	 *
63
	 * @return
64
	 */
65
	public String getJDBCDriverClassName();
66

  
67
	/**
68
	 * Return <code>catalog</code> parameter
69
	 *
70
	 * @return
71
	 */
72
	public String getCatalog();
73

  
74
	/**
75
	 * Return <code>schema</code> parameter
76
	 *
77
	 * @return
78
	 */
79
	public String getSchema();
80

  
81
	/**
82
	 * Return <code>JDBC connection URL</code> parameter
83
	 * 
84
	 * @return
85
	 */
86
	public String getUrl();
87
        
88
        public int getBatchSize();
89
        
90

  
91
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc/JDBCResourceParametersBase.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24

  
25
package org.gvsig.fmap.dal.store.jdbc;
26

  
27
import org.gvsig.fmap.dal.resource.db.AbstractDBResourceParameters;
28
import org.gvsig.fmap.dal.store.jdbc2.JDBCLibrary;
29
import static org.gvsig.fmap.dal.store.jdbc2.JDBCLibrary.RESOURCEPARAMETERS_NAME;
30

  
31
public class JDBCResourceParametersBase extends AbstractDBResourceParameters
32
		implements JDBCResourceParameters {
33

  
34
	protected JDBCResourceParametersBase(String parametersDefinitionName, String providerName) {
35
		super(parametersDefinitionName,providerName);
36
	}
37
	
38
	public JDBCResourceParametersBase() {
39
		this(JDBCLibrary.RESOURCEPARAMETERS_NAME, JDBCLibrary.NAME);
40
	}
41

  
42
    public JDBCResourceParametersBase(String parametersDefinitionName, String providerName, 
43
    		String url, String host, Integer port,
44
			String dbName, String user, String password, 
45
			String jdbcDriverClassName) {
46
		this(parametersDefinitionName,providerName);
47

  
48
		this.setUrl(url);
49
		this.setHost(host);
50
		this.setPort(port);
51
		this.setDBName(dbName);
52
		this.setUser(user);
53
		this.setPassword(password);
54
		this.setJDBCDriverClassName(jdbcDriverClassName);
55
	}
56

  
57
    public JDBCResourceParametersBase(String url, String host, Integer port,
58
			String dbName,
59
			String user, String password, String jdbcDriverClassName) {
60
		this(PARAMETERS_DEFINITION_NAME, RESOURCEPARAMETERS_NAME, url, host, port, dbName, user, password, jdbcDriverClassName);
61
	}
62

  
63
    @Override
64
	public void setJDBCDriverClassName(String className) {
65
		this.setDynValue(JDBC_DRIVER_CLASS_PARAMTER_NAME, className);
66
	}
67

  
68
    @Override
69
	public String getJDBCDriverClassName() {
70
		return (String) this.getDynValue(JDBC_DRIVER_CLASS_PARAMTER_NAME);
71
	}
72

  
73
    @Override
74
	public String getCatalog() {
75
		return (String) this.getDynValue(CATALOG_PARAMTER_NAME);
76
	}
77

  
78
    @Override
79
	public void setCatalog(String catalog) {
80
		this.setDynValue(CATALOG_PARAMTER_NAME, catalog);
81
	}
82

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff