svn-gvsig-desktop / 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 / exportto / swing / prov / jdbc / BaseExporttoJDBCProvider.java @ 43920
History | View | Annotate | Download (5.21 KB)
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.exportto.swing.prov.jdbc; |
25 |
|
26 |
import org.gvsig.exportto.ExporttoService; |
27 |
import org.gvsig.exportto.swing.prov.jdbc.panel.GeometryIndexPanel; |
28 |
import org.gvsig.exportto.swing.prov.jdbc.panel.IdentifiersOptionsPanel; |
29 |
import org.gvsig.exportto.swing.prov.jdbc.panel.JDBCConnectionPanel; |
30 |
import org.gvsig.exportto.swing.prov.jdbc.panel.UpdateTableStatisticsPanel; |
31 |
import org.gvsig.exportto.swing.prov.jdbc.panel.PermissionsPanel; |
32 |
import org.gvsig.exportto.swing.prov.jdbc.panel.PostCreatingStatementPanel; |
33 |
import org.gvsig.exportto.swing.prov.jdbc.panel.SelectPkPanel; |
34 |
import org.gvsig.exportto.swing.prov.jdbc.panel.SelectTableNamePanel; |
35 |
import org.gvsig.exportto.swing.spi.AbstractExporttoSwingProvider; |
36 |
import org.gvsig.exportto.swing.spi.ExporttoSwingProvider; |
37 |
import org.gvsig.exportto.swing.spi.panels.CheckGeometriesPanel; |
38 |
import org.gvsig.fmap.dal.DALLocator; |
39 |
import org.gvsig.fmap.dal.DataManager; |
40 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
41 |
import org.gvsig.fmap.dal.feature.FeatureType; |
42 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorer; |
43 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
44 |
import org.gvsig.tools.service.spi.ProviderServices; |
45 |
import org.slf4j.Logger; |
46 |
import org.slf4j.LoggerFactory; |
47 |
|
48 |
/**
|
49 |
* Exporto provider which gets Exporto from a file.
|
50 |
*
|
51 |
* @author gvSIG Team
|
52 |
* @version $Id$
|
53 |
*/
|
54 |
public class BaseExporttoJDBCProvider |
55 |
extends AbstractExporttoSwingProvider
|
56 |
implements ExporttoSwingProvider {
|
57 |
|
58 |
private static final Logger logger = LoggerFactory.getLogger( |
59 |
BaseExporttoJDBCProvider.class); |
60 |
|
61 |
private String storeName = null; |
62 |
|
63 |
@SuppressWarnings("OverridableMethodCallInConstructor") |
64 |
public BaseExporttoJDBCProvider(
|
65 |
ProviderServices providerServices, |
66 |
FeatureStore sourceStore |
67 |
) { |
68 |
super(providerServices, sourceStore);
|
69 |
|
70 |
FeatureType ftype = null;
|
71 |
try {
|
72 |
ftype = sourceStore.getDefaultFeatureType(); |
73 |
} catch (Exception exc) { |
74 |
logger.warn("Can't retrieve the feature type to use in the export to JDBC panel.", exc);
|
75 |
|
76 |
} |
77 |
this.panelAdd(new IdentifiersOptionsPanel(this.getOptions())); |
78 |
this.panelAdd(new JDBCConnectionPanel(this.getOptions())); |
79 |
this.panelAdd(new SelectTableNamePanel(this.getOptions())); |
80 |
this.panelAdd(new SelectPkPanel(this.getOptions())); |
81 |
this.panelAdd(new GeometryIndexPanel(this.getOptions())); |
82 |
this.panelAdd(new CheckGeometriesPanel(this.getOptions())); |
83 |
this.panelAdd(new PermissionsPanel(this.getOptions())); |
84 |
this.panelAdd(new UpdateTableStatisticsPanel(this.getOptions())); |
85 |
this.panelAdd(new PostCreatingStatementPanel(this.getOptions())); |
86 |
|
87 |
} |
88 |
|
89 |
|
90 |
@Override
|
91 |
public ExporttoJDBCOptions getOptions() {
|
92 |
if( this.options == null ) { |
93 |
this.options = new BaseExporttoJDBCOptions(); |
94 |
} |
95 |
return (ExporttoJDBCOptions) this.options; |
96 |
} |
97 |
|
98 |
@Override
|
99 |
public ExporttoService createExporttoService() {
|
100 |
ExporttoJDBCOptions theOptions = this.getOptions();
|
101 |
JDBCServerExplorerParameters explorerParameters = theOptions.getExplorerParameters(); |
102 |
explorerParameters.setSchema(theOptions.getSchema()); |
103 |
return new ExporrtoJDBCService(theOptions); |
104 |
} |
105 |
|
106 |
|
107 |
public String getStoreName() { |
108 |
if ( this.storeName == null ) { |
109 |
try {
|
110 |
JDBCServerExplorerParameters explorerParameters = this.getOptions().getExplorerParameters();
|
111 |
if ( explorerParameters == null ) { |
112 |
return null; |
113 |
} |
114 |
DataManager dataManager = DALLocator.getDataManager(); |
115 |
|
116 |
JDBCServerExplorer explorer = (JDBCServerExplorer) dataManager.openServerExplorer( |
117 |
explorerParameters.getExplorerName(), |
118 |
explorerParameters |
119 |
); |
120 |
this.storeName = explorer.getStoreName();
|
121 |
} catch (Exception ex) { |
122 |
return null; |
123 |
} |
124 |
} |
125 |
return this.storeName; |
126 |
} |
127 |
|
128 |
/**
|
129 |
* Informs if it needs to ask for a target projection,
|
130 |
* or if it is not needed or provided through its own wizard panel.
|
131 |
* @return
|
132 |
*/
|
133 |
@Override
|
134 |
public boolean needsPanelTargetProjection(){ |
135 |
return true; |
136 |
} |
137 |
|
138 |
} |