Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / org.gvsig.exportto / org.gvsig.exportto.swing / org.gvsig.exportto.swing.prov / org.gvsig.exportto.swing.prov.jdbc / src / main / java / org / gvsig / exportto / swing / prov / jdbc / AbstractExporttoJDBCProvider.java @ 38557

History | View | Annotate | Download (3.91 KB)

1 34981 jpiera
/* 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
package org.gvsig.exportto.swing.prov.jdbc;
23
24
import org.cresques.cts.IProjection;
25
26
import org.gvsig.exportto.ExporttoService;
27 38557 jldominguez
import org.gvsig.exportto.swing.prov.jdbc.panel.JDBCConnectionPanel;
28 34981 jpiera
import org.gvsig.exportto.swing.prov.jdbc.panel.SelectPkPanel;
29
import org.gvsig.exportto.swing.prov.jdbc.panel.SelectTableNamePanel;
30
import org.gvsig.exportto.swing.spi.ExporttoSwingProvider;
31
import org.gvsig.exportto.swing.spi.ExporttoSwingProviderPanel;
32
import org.gvsig.fmap.dal.feature.FeatureStore;
33
import org.gvsig.geodb.vectorialdb.ConnectionSettings;
34
import org.gvsig.tools.service.spi.AbstractProvider;
35
import org.gvsig.tools.service.spi.ProviderServices;
36
37
/**
38
 * Exporto provider which gets Exporto from a file.
39
 *
40
 * @author gvSIG Team
41
 * @version $Id$
42
 */
43 37780 cordinyana
public abstract class AbstractExporttoJDBCProvider extends AbstractProvider
44
    implements ExporttoSwingProvider {
45
46 34981 jpiera
    protected SelectTableNamePanel selectTableNamePanel = null;
47
    protected SelectPkPanel selectPkPanel = null;
48 38557 jldominguez
    protected JDBCConnectionPanel jdbcConnectionPanel = null;
49 37780 cordinyana
50 34981 jpiera
    protected FeatureStore featureStore;
51
    protected IProjection projection;
52 37780 cordinyana
53 34981 jpiera
    /**
54
     * Constructor.
55
     *
56
     * @param providerServices
57
     *            the services for the provider
58
     * @param file
59
     *            to get the Exporto from
60
     */
61 37780 cordinyana
    public AbstractExporttoJDBCProvider(ProviderServices providerServices,
62
        FeatureStore featureStore, IProjection projection) {
63 34981 jpiera
        super(providerServices);
64
        this.featureStore = featureStore;
65
        this.projection = projection;
66
67 37780 cordinyana
        selectTableNamePanel = new SelectTableNamePanel();
68 34981 jpiera
        selectPkPanel = new SelectPkPanel();
69 38557 jldominguez
        jdbcConnectionPanel = new JDBCConnectionPanel();
70 34981 jpiera
    }
71
72 37780 cordinyana
    public int getPanelCount() {
73 34981 jpiera
        return 3;
74
    }
75
76
    public ExporttoSwingProviderPanel getPanelAt(int index) {
77 37780 cordinyana
        switch (index) {
78 34981 jpiera
        case 0:
79 37780 cordinyana
            return selectTableNamePanel;
80 34981 jpiera
        case 1:
81
            return selectPkPanel;
82
        case 2:
83 38557 jldominguez
            return jdbcConnectionPanel;
84 37780 cordinyana
        }
85 34981 jpiera
        return null;
86
    }
87
88
    public ExporttoService createExporttoService() {
89 37780 cordinyana
        ConnectionSettings connectionSettings =
90 38557 jldominguez
            jdbcConnectionPanel.getConnectionSettings();
91 37780 cordinyana
92
        int port = -1;
93
        if (connectionSettings.getPort() != null
94
            && connectionSettings.getPort().length() > 0) {
95
            port = Integer.valueOf(connectionSettings.getPort());
96
        }
97
98
        String schema = null;
99
        if (connectionSettings.getSchema() != null
100
            && connectionSettings.getSchema().length() > 0) {
101
            schema = connectionSettings.getSchema();
102
        }
103
104
        return new ExporrtoJDBCService(featureStore,
105
            connectionSettings.getDb(), schema, selectTableNamePanel.getText(),
106
            selectPkPanel.getText(), connectionSettings.getUser(),
107
            connectionSettings.getPassw(), connectionSettings.getHost(), port,
108
            getExplorerName(), getStoreName());
109
    }
110
111 34981 jpiera
    public abstract String getStoreName();
112 37780 cordinyana
113 34981 jpiera
    public abstract String getExplorerName();
114 37780 cordinyana
}