Statistics
| Revision:

root / tags / v2_0_0_Build_2051 / 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 @ 38749

History | View | Annotate | Download (3.91 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
package org.gvsig.exportto.swing.prov.jdbc;
23

    
24
import org.cresques.cts.IProjection;
25

    
26
import org.gvsig.exportto.ExporttoService;
27
import org.gvsig.exportto.swing.prov.jdbc.panel.JDBCConnectionPanel;
28
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
public abstract class AbstractExporttoJDBCProvider extends AbstractProvider
44
    implements ExporttoSwingProvider {
45

    
46
    protected SelectTableNamePanel selectTableNamePanel = null;
47
    protected SelectPkPanel selectPkPanel = null;
48
    protected JDBCConnectionPanel jdbcConnectionPanel = null;
49

    
50
    protected FeatureStore featureStore;
51
    protected IProjection projection;
52

    
53
    /**
54
     * Constructor.
55
     * 
56
     * @param providerServices
57
     *            the services for the provider
58
     * @param file
59
     *            to get the Exporto from
60
     */
61
    public AbstractExporttoJDBCProvider(ProviderServices providerServices,
62
        FeatureStore featureStore, IProjection projection) {
63
        super(providerServices);
64
        this.featureStore = featureStore;
65
        this.projection = projection;
66

    
67
        selectTableNamePanel = new SelectTableNamePanel();
68
        selectPkPanel = new SelectPkPanel();
69
        jdbcConnectionPanel = new JDBCConnectionPanel();
70
    }
71

    
72
    public int getPanelCount() {
73
        return 3;
74
    }
75

    
76
    public ExporttoSwingProviderPanel getPanelAt(int index) {
77
        switch (index) {
78
        case 0:
79
            return selectTableNamePanel;
80
        case 1:
81
            return selectPkPanel;
82
        case 2:
83
            return jdbcConnectionPanel;
84
        }
85
        return null;
86
    }
87

    
88
    public ExporttoService createExporttoService() {
89
        ConnectionSettings connectionSettings =
90
            jdbcConnectionPanel.getConnectionSettings();
91

    
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
    public abstract String getStoreName();
112

    
113
    public abstract String getExplorerName();
114
}