Revision 43920 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
BaseExporttoJDBCProvider.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
package org.gvsig.exportto.swing.prov.jdbc; |
25 | 25 |
|
26 |
import java.util.ArrayList; |
|
27 |
import java.util.List; |
|
28 |
import org.cresques.cts.IProjection; |
|
29 | 26 |
import org.gvsig.exportto.ExporttoService; |
30 |
import org.gvsig.exportto.swing.prov.jdbc.panel.CheckGeometriesPanel; |
|
31 | 27 |
import org.gvsig.exportto.swing.prov.jdbc.panel.GeometryIndexPanel; |
32 | 28 |
import org.gvsig.exportto.swing.prov.jdbc.panel.IdentifiersOptionsPanel; |
33 | 29 |
import org.gvsig.exportto.swing.prov.jdbc.panel.JDBCConnectionPanel; |
... | ... | |
36 | 32 |
import org.gvsig.exportto.swing.prov.jdbc.panel.PostCreatingStatementPanel; |
37 | 33 |
import org.gvsig.exportto.swing.prov.jdbc.panel.SelectPkPanel; |
38 | 34 |
import org.gvsig.exportto.swing.prov.jdbc.panel.SelectTableNamePanel; |
35 |
import org.gvsig.exportto.swing.spi.AbstractExporttoSwingProvider; |
|
39 | 36 |
import org.gvsig.exportto.swing.spi.ExporttoSwingProvider; |
40 |
import org.gvsig.exportto.swing.spi.ExporttoSwingProviderPanel;
|
|
37 |
import org.gvsig.exportto.swing.spi.panels.CheckGeometriesPanel;
|
|
41 | 38 |
import org.gvsig.fmap.dal.DALLocator; |
42 | 39 |
import org.gvsig.fmap.dal.DataManager; |
43 | 40 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
44 | 41 |
import org.gvsig.fmap.dal.feature.FeatureType; |
45 | 42 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorer; |
46 | 43 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
47 |
import org.gvsig.tools.service.spi.AbstractProvider; |
|
48 | 44 |
import org.gvsig.tools.service.spi.ProviderServices; |
49 | 45 |
import org.slf4j.Logger; |
50 | 46 |
import org.slf4j.LoggerFactory; |
... | ... | |
55 | 51 |
* @author gvSIG Team |
56 | 52 |
* @version $Id$ |
57 | 53 |
*/ |
58 |
public class BaseExporttoJDBCProvider extends AbstractProvider |
|
59 |
implements ExporttoJDBCOptions, ExporttoSwingProvider { |
|
54 |
public class BaseExporttoJDBCProvider |
|
55 |
extends AbstractExporttoSwingProvider |
|
56 |
implements ExporttoSwingProvider { |
|
60 | 57 |
|
61 |
private static Logger logger = LoggerFactory.getLogger( |
|
58 |
private static final Logger logger = LoggerFactory.getLogger(
|
|
62 | 59 |
BaseExporttoJDBCProvider.class); |
63 | 60 |
|
64 |
protected List<ExporttoSwingProviderPanel> panels = new ArrayList<ExporttoSwingProviderPanel>(); |
|
65 |
|
|
66 |
protected FeatureStore sourceStore; |
|
67 |
protected IProjection projection; |
|
68 |
private final JDBCConnectionPanel connectionPanel; |
|
69 |
private final SelectPkPanel selectPkPanel; |
|
70 |
private final SelectTableNamePanel selectTableNamePanel; |
|
71 |
private final CheckGeometriesPanel checkGeometriesPanel; |
|
72 |
private final IdentifiersOptionsPanel identifiersOptionsPanel; |
|
73 |
|
|
74 |
private final GeometryIndexPanel geometryIndexPanel; |
|
75 |
private final UpdateTableStatisticsPanel updateTableStatistics; |
|
76 |
private final PermissionsPanel permissionsPanel; |
|
77 |
private final PostCreatingStatementPanel postCreatingStatementPanel; |
|
78 |
|
|
79 | 61 |
private String storeName = null; |
80 | 62 |
|
81 |
public BaseExporttoJDBCProvider(ProviderServices providerServices, |
|
82 |
FeatureStore sourceStore, IProjection projection) { |
|
83 |
super(providerServices); |
|
84 |
this.sourceStore = sourceStore; |
|
85 |
this.projection = projection; |
|
63 |
@SuppressWarnings("OverridableMethodCallInConstructor") |
|
64 |
public BaseExporttoJDBCProvider( |
|
65 |
ProviderServices providerServices, |
|
66 |
FeatureStore sourceStore |
|
67 |
) { |
|
68 |
super(providerServices, sourceStore); |
|
86 | 69 |
|
87 | 70 |
FeatureType ftype = null; |
88 | 71 |
try { |
... | ... | |
91 | 74 |
logger.warn("Can't retrieve the feature type to use in the export to JDBC panel.", exc); |
92 | 75 |
|
93 | 76 |
} |
94 |
this.connectionPanel = new JDBCConnectionPanel(this); |
|
95 |
this.selectTableNamePanel = new SelectTableNamePanel(this); |
|
96 |
this.selectPkPanel = new SelectPkPanel(this); |
|
97 |
this.checkGeometriesPanel = new CheckGeometriesPanel(this); |
|
98 |
this.identifiersOptionsPanel = new IdentifiersOptionsPanel(this); |
|
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())); |
|
99 | 86 |
|
100 |
this.geometryIndexPanel = new GeometryIndexPanel(this); |
|
101 |
this.updateTableStatistics = new UpdateTableStatisticsPanel(this); |
|
102 |
this.permissionsPanel = new PermissionsPanel(this); |
|
103 |
this.postCreatingStatementPanel = new PostCreatingStatementPanel(this); |
|
104 |
|
|
105 |
this.panels.add(this.identifiersOptionsPanel); |
|
106 |
this.panels.add(this.connectionPanel); |
|
107 |
this.panels.add(this.selectTableNamePanel); |
|
108 |
this.panels.add(this.selectPkPanel); |
|
109 |
this.panels.add(this.geometryIndexPanel); |
|
110 |
this.panels.add(this.checkGeometriesPanel); |
|
111 |
|
|
112 |
this.panels.add(this.permissionsPanel); |
|
113 |
this.panels.add(this.updateTableStatistics); |
|
114 |
this.panels.add(this.postCreatingStatementPanel); |
|
115 |
|
|
116 | 87 |
} |
117 | 88 |
|
118 |
|
|
119 |
|
|
120 |
public int getPanelCount() { |
|
121 |
return this.panels.size(); |
|
89 |
|
|
90 |
@Override |
|
91 |
public ExporttoJDBCOptions getOptions() { |
|
92 |
if( this.options == null ) { |
|
93 |
this.options = new BaseExporttoJDBCOptions(); |
|
94 |
} |
|
95 |
return (ExporttoJDBCOptions) this.options; |
|
122 | 96 |
} |
123 | 97 |
|
124 |
public ExporttoSwingProviderPanel getPanelAt(int index) { |
|
125 |
return this.panels.get(index); |
|
126 |
} |
|
127 |
|
|
128 |
public FeatureStore getSource() { |
|
129 |
return this.sourceStore; |
|
130 |
} |
|
131 |
|
|
98 |
@Override |
|
132 | 99 |
public ExporttoService createExporttoService() { |
133 |
JDBCServerExplorerParameters explorerParameters = this.getExplorerParameters(); |
|
134 |
explorerParameters.setSchema(this.getSchema()); |
|
135 |
return new ExporrtoJDBCService(this); |
|
100 |
ExporttoJDBCOptions theOptions = this.getOptions(); |
|
101 |
JDBCServerExplorerParameters explorerParameters = theOptions.getExplorerParameters(); |
|
102 |
explorerParameters.setSchema(theOptions.getSchema()); |
|
103 |
return new ExporrtoJDBCService(theOptions); |
|
136 | 104 |
} |
137 | 105 |
|
138 |
@Override |
|
139 |
public boolean getTranslateIdentifiersToLowerCase() { |
|
140 |
return this.identifiersOptionsPanel.getTranslateToLowerCase(); |
|
141 |
} |
|
142 | 106 |
|
143 |
public boolean getTranslateHyphens() { |
|
144 |
return this.identifiersOptionsPanel.getTranslateHyphens(); |
|
145 |
} |
|
146 |
|
|
147 |
public boolean getRemoveSpacesInIdentifiers() { |
|
148 |
return this.identifiersOptionsPanel.getRemoveSpacesInTableName(); |
|
149 |
} |
|
150 |
|
|
151 |
public JDBCServerExplorerParameters getExplorerParameters() { |
|
152 |
return this.connectionPanel.getServerExplorerParameters(); |
|
153 |
} |
|
154 |
|
|
155 |
public String getSchema() { |
|
156 |
return this.selectTableNamePanel.getSchema(); |
|
157 |
} |
|
158 |
|
|
159 |
public String getTableName() { |
|
160 |
return this.selectTableNamePanel.getTableName(); |
|
161 |
} |
|
162 |
|
|
163 |
public boolean canCreatetable() { |
|
164 |
return this.selectTableNamePanel.canCreateTable(); |
|
165 |
} |
|
166 |
|
|
167 |
public String getPrimaryKey() { |
|
168 |
return this.selectPkPanel.getPrimaryKeyName(); |
|
169 |
} |
|
170 |
|
|
171 |
public int getGeometryChecks() { |
|
172 |
return this.checkGeometriesPanel.getGeometryChecks(); |
|
173 |
} |
|
174 |
|
|
175 |
public int getGeometryChecksAction() { |
|
176 |
return this.checkGeometriesPanel.getGeometryChecksAction(); |
|
177 |
} |
|
178 |
|
|
179 |
public boolean getTryToFixGeometry() { |
|
180 |
return this.checkGeometriesPanel.getTryToFixGeometry(); |
|
181 |
} |
|
182 |
|
|
183 |
public String getExplorerName() { |
|
184 |
return this.connectionPanel.getServerExplorerParameters().getExplorerName(); |
|
185 |
} |
|
186 |
|
|
187 | 107 |
public String getStoreName() { |
188 | 108 |
if ( this.storeName == null ) { |
189 | 109 |
try { |
190 |
JDBCServerExplorerParameters explorerParameters = this.getExplorerParameters(); |
|
110 |
JDBCServerExplorerParameters explorerParameters = this.getOptions().getExplorerParameters();
|
|
191 | 111 |
if ( explorerParameters == null ) { |
192 | 112 |
return null; |
193 | 113 |
} |
... | ... | |
205 | 125 |
return this.storeName; |
206 | 126 |
} |
207 | 127 |
|
208 |
public IProjection getTargetProjection() { |
|
209 |
return this.projection; |
|
210 |
} |
|
211 |
|
|
212 |
public String getSelectRole() { |
|
213 |
return this.permissionsPanel.getSelectRole(); |
|
214 |
} |
|
215 |
|
|
216 |
public String getInsertRole() { |
|
217 |
return this.permissionsPanel.getInsertRole(); |
|
218 |
} |
|
219 |
|
|
220 |
public String getUpdateRole() { |
|
221 |
return this.permissionsPanel.getUpdateRole(); |
|
222 |
} |
|
223 |
|
|
224 |
public String getDeleteRole() { |
|
225 |
return this.permissionsPanel.getDeleteRole(); |
|
226 |
} |
|
227 |
|
|
228 |
public String getTruncateRole() { |
|
229 |
return this.permissionsPanel.getTruncateRole(); |
|
230 |
} |
|
231 |
|
|
232 |
public String getReferenceRole() { |
|
233 |
return this.permissionsPanel.getReferenceRole(); |
|
234 |
} |
|
235 |
|
|
236 |
public String getTriggerRole() { |
|
237 |
return this.permissionsPanel.getTriggerRole(); |
|
238 |
} |
|
239 |
|
|
240 |
public String getAllRole() { |
|
241 |
return this.permissionsPanel.getAllRole(); |
|
242 |
} |
|
243 |
|
|
244 |
public String getPostCreatingStatement() { |
|
245 |
return this.postCreatingStatementPanel.getPostCreatingStatement(); |
|
246 |
} |
|
247 |
|
|
248 |
public boolean getCreateIndexInGeometryRow() { |
|
249 |
return this.geometryIndexPanel.getCreateIndexInGeometryRow(); |
|
250 |
} |
|
251 |
|
|
252 |
public boolean getUpdateTableStatistics() { |
|
253 |
return this.updateTableStatistics.getUpdateTableStatistics(); |
|
254 |
} |
|
255 |
|
|
256 | 128 |
/** |
257 |
* Sets the target projection to which should be exported |
|
258 |
* @param targetProjection |
|
259 |
*/ |
|
260 |
public void setTargetProjection(IProjection targetProjection){ |
|
261 |
this.projection=targetProjection; |
|
262 |
} |
|
263 |
|
|
264 |
/** |
|
265 | 129 |
* Informs if it needs to ask for a target projection, |
266 | 130 |
* or if it is not needed or provided through its own wizard panel. |
267 | 131 |
* @return |
268 | 132 |
*/ |
133 |
@Override |
|
269 | 134 |
public boolean needsPanelTargetProjection(){ |
270 | 135 |
return true; |
271 | 136 |
} |
Also available in: Unified diff