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 / export / jdbc / service / ExportJDBCParametersImpl.java @ 46542
History | View | Annotate | Download (15.8 KB)
1 |
/*
|
---|---|
2 |
* To change this license header, choose License Headers in Project Properties.
|
3 |
* To change this template file, choose Tools | Templates
|
4 |
* and open the template in the editor.
|
5 |
*/
|
6 |
package org.gvsig.export.jdbc.service; |
7 |
|
8 |
import java.util.List; |
9 |
import org.gvsig.export.spi.AbstractExportParametersGeometry; |
10 |
import org.gvsig.expressionevaluator.Expression; |
11 |
import org.gvsig.fmap.dal.DALLocator; |
12 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
13 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCStoreProviderFactory; |
14 |
import static org.gvsig.fmap.dal.store.jdbc2.JDBCStoreProviderFactory.CASE_IDENTIFIERS_UPPERCASE; |
15 |
import org.gvsig.tools.ToolsLocator; |
16 |
import org.gvsig.tools.dynobject.DynStruct; |
17 |
import org.gvsig.tools.persistence.PersistenceManager; |
18 |
import org.gvsig.tools.persistence.PersistentState; |
19 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
20 |
|
21 |
/**
|
22 |
*
|
23 |
* @author jjdelcerro
|
24 |
*/
|
25 |
public class ExportJDBCParametersImpl |
26 |
extends AbstractExportParametersGeometry
|
27 |
implements ExportJDBCParameters {
|
28 |
|
29 |
private JDBCServerExplorerParameters explorerParameters;
|
30 |
private String schema; |
31 |
private String tableName; |
32 |
private boolean canCreatetable; |
33 |
private String primaryKeyName; |
34 |
private String storeName; |
35 |
private String explorerName; |
36 |
private boolean removeSpacesInIdentifiers; |
37 |
private boolean translateHyphens; |
38 |
private String selectRole; |
39 |
private String insertRole; |
40 |
private String updateRole; |
41 |
private String deleteRole; |
42 |
private String truncateRole; |
43 |
private String referenceRole; |
44 |
private String triggerRole; |
45 |
private String allRole; |
46 |
private String postCreatingStatement; |
47 |
private boolean createIndexInGeometryRow; |
48 |
private boolean updateTableStatistics; |
49 |
private int caseIdentifierMode; |
50 |
private boolean deleteRows; |
51 |
private Expression deleteRowsFilter; |
52 |
|
53 |
public ExportJDBCParametersImpl(ExportJDBCServiceFactory factory) {
|
54 |
super(factory);
|
55 |
this.exportAttributes.setNamesTranslator(new ExportJDBCAttributeNamesTranslator(this)); |
56 |
|
57 |
this.canCreatetable = true; |
58 |
this.caseIdentifierMode = CASE_IDENTIFIERS_UPPERCASE;
|
59 |
this.removeSpacesInIdentifiers = true; |
60 |
this.translateHyphens = true; |
61 |
this.createIndexInGeometryRow = true; |
62 |
this.updateTableStatistics = true; |
63 |
} |
64 |
|
65 |
public ExportJDBCParametersImpl() {
|
66 |
super(null); |
67 |
} |
68 |
|
69 |
@Override
|
70 |
public String getServiceName() { |
71 |
return ExportJDBCServiceFactory.SERVICE_NAME;
|
72 |
} |
73 |
|
74 |
/**
|
75 |
* @return the explorerParameters
|
76 |
*/
|
77 |
@Override
|
78 |
public JDBCServerExplorerParameters getExplorerParameters() {
|
79 |
return explorerParameters;
|
80 |
} |
81 |
|
82 |
/**
|
83 |
* @param explorerParameters the explorerParameters to set
|
84 |
*/
|
85 |
@Override
|
86 |
public void setExplorerParameters(JDBCServerExplorerParameters explorerParameters) { |
87 |
this.explorerParameters = explorerParameters;
|
88 |
String provider = this.explorerParameters.getProviderName(); |
89 |
JDBCStoreProviderFactory providerFactory = (JDBCStoreProviderFactory)DALLocator.getDataManager().getStoreProviderFactory(provider); |
90 |
int caseMode = providerFactory.caseIndentifierPreferedMode();
|
91 |
} |
92 |
|
93 |
/**
|
94 |
* @return the schema
|
95 |
*/
|
96 |
@Override
|
97 |
public String getSchema() { |
98 |
return schema;
|
99 |
} |
100 |
|
101 |
/**
|
102 |
* @param schema the schema to set
|
103 |
*/
|
104 |
@Override
|
105 |
public void setSchema(String schema) { |
106 |
this.schema = schema;
|
107 |
} |
108 |
|
109 |
/**
|
110 |
* @return the tableName
|
111 |
*/
|
112 |
@Override
|
113 |
public String getTableName() { |
114 |
return tableName;
|
115 |
} |
116 |
|
117 |
/**
|
118 |
* @param tableName the tableName to set
|
119 |
*/
|
120 |
@Override
|
121 |
public void setTableName(String tableName) { |
122 |
this.tableName = tableName;
|
123 |
} |
124 |
|
125 |
/**
|
126 |
* @return the canCreatetable
|
127 |
*/
|
128 |
@Override
|
129 |
public boolean canCreatetable() { |
130 |
return canCreatetable;
|
131 |
} |
132 |
|
133 |
/**
|
134 |
* @param canCreatetable the canCreatetable to set
|
135 |
*/
|
136 |
@Override
|
137 |
public void setCanCreatetable(boolean canCreatetable) { |
138 |
this.canCreatetable = canCreatetable;
|
139 |
} |
140 |
|
141 |
/**
|
142 |
* @return the primaryKeyName
|
143 |
*/
|
144 |
@Override
|
145 |
public String getPrimaryKey() { |
146 |
return primaryKeyName;
|
147 |
} |
148 |
|
149 |
/**
|
150 |
* @param primaryKey the primaryKeyName to set
|
151 |
*/
|
152 |
@Override
|
153 |
public void setPrimaryKey(String primaryKey) { |
154 |
this.primaryKeyName = primaryKey;
|
155 |
} |
156 |
|
157 |
/**
|
158 |
* @return the storeName
|
159 |
*/
|
160 |
@Override
|
161 |
public String getStoreName() { |
162 |
return storeName;
|
163 |
} |
164 |
|
165 |
/**
|
166 |
* @param storeName the storeName to set
|
167 |
*/
|
168 |
@Override
|
169 |
public void setStoreName(String storeName) { |
170 |
this.storeName = storeName;
|
171 |
} |
172 |
|
173 |
/**
|
174 |
* @return the explorerName
|
175 |
*/
|
176 |
@Override
|
177 |
public String getExplorerName() { |
178 |
return explorerName;
|
179 |
} |
180 |
|
181 |
/**
|
182 |
* @param explorerName the explorerName to set
|
183 |
*/
|
184 |
@Override
|
185 |
public void setExplorerName(String explorerName) { |
186 |
this.explorerName = explorerName;
|
187 |
} |
188 |
|
189 |
@Override
|
190 |
public void setCaseIdentifiersMode(int mode) { |
191 |
if(mode != this.caseIdentifierMode){ |
192 |
this.caseIdentifierMode = mode;
|
193 |
this.exportAttributes.getNamesTranslator().rebuild();
|
194 |
} |
195 |
} |
196 |
|
197 |
/**
|
198 |
* @param removeSpacesInIdentifiers the removeSpacesInIdentifiers to set
|
199 |
*/
|
200 |
@Override
|
201 |
public void setRemoveSpacesInIdentifiers(boolean removeSpacesInIdentifiers) { |
202 |
if (removeSpacesInIdentifiers != this.removeSpacesInIdentifiers) { |
203 |
this.removeSpacesInIdentifiers = removeSpacesInIdentifiers;
|
204 |
this.exportAttributes.getNamesTranslator().rebuild();
|
205 |
} |
206 |
} |
207 |
|
208 |
/**
|
209 |
* @param translateHyphens the translateHyphens to set
|
210 |
*/
|
211 |
@Override
|
212 |
public void setTranslateHyphens(boolean translateHyphens) { |
213 |
if (translateHyphens != this.translateHyphens) { |
214 |
this.translateHyphens = translateHyphens;
|
215 |
List<String> sourceNames = this.exportAttributes.getNamesTranslator().getSourceNames(); |
216 |
this.exportAttributes.getNamesTranslator().rebuild();
|
217 |
} |
218 |
} |
219 |
|
220 |
/**
|
221 |
* @return the selectRole
|
222 |
*/
|
223 |
@Override
|
224 |
public String getSelectRole() { |
225 |
return selectRole;
|
226 |
} |
227 |
|
228 |
/**
|
229 |
* @param selectRole the selectRole to set
|
230 |
*/
|
231 |
@Override
|
232 |
public void setSelectRole(String selectRole) { |
233 |
this.selectRole = selectRole;
|
234 |
} |
235 |
|
236 |
/**
|
237 |
* @return the insertRole
|
238 |
*/
|
239 |
@Override
|
240 |
public String getInsertRole() { |
241 |
return insertRole;
|
242 |
} |
243 |
|
244 |
/**
|
245 |
* @param insertRole the insertRole to set
|
246 |
*/
|
247 |
@Override
|
248 |
public void setInsertRole(String insertRole) { |
249 |
this.insertRole = insertRole;
|
250 |
} |
251 |
|
252 |
/**
|
253 |
* @return the updateRole
|
254 |
*/
|
255 |
@Override
|
256 |
public String getUpdateRole() { |
257 |
return updateRole;
|
258 |
} |
259 |
|
260 |
/**
|
261 |
* @param updateRole the updateRole to set
|
262 |
*/
|
263 |
@Override
|
264 |
public void setUpdateRole(String updateRole) { |
265 |
this.updateRole = updateRole;
|
266 |
} |
267 |
|
268 |
/**
|
269 |
* @return the deleteRole
|
270 |
*/
|
271 |
@Override
|
272 |
public String getDeleteRole() { |
273 |
return deleteRole;
|
274 |
} |
275 |
|
276 |
/**
|
277 |
* @param deleteRole the deleteRole to set
|
278 |
*/
|
279 |
@Override
|
280 |
public void setDeleteRole(String deleteRole) { |
281 |
this.deleteRole = deleteRole;
|
282 |
} |
283 |
|
284 |
/**
|
285 |
* @return the truncateRole
|
286 |
*/
|
287 |
@Override
|
288 |
public String getTruncateRole() { |
289 |
return truncateRole;
|
290 |
} |
291 |
|
292 |
/**
|
293 |
* @param truncateRole the truncateRole to set
|
294 |
*/
|
295 |
@Override
|
296 |
public void setTruncateRole(String truncateRole) { |
297 |
this.truncateRole = truncateRole;
|
298 |
} |
299 |
|
300 |
/**
|
301 |
* @return the referenceRole
|
302 |
*/
|
303 |
@Override
|
304 |
public String getReferenceRole() { |
305 |
return referenceRole;
|
306 |
} |
307 |
|
308 |
/**
|
309 |
* @param referenceRole the referenceRole to set
|
310 |
*/
|
311 |
@Override
|
312 |
public void setReferenceRole(String referenceRole) { |
313 |
this.referenceRole = referenceRole;
|
314 |
} |
315 |
|
316 |
/**
|
317 |
* @return the triggerRole
|
318 |
*/
|
319 |
@Override
|
320 |
public String getTriggerRole() { |
321 |
return triggerRole;
|
322 |
} |
323 |
|
324 |
/**
|
325 |
* @param triggerRole the triggerRole to set
|
326 |
*/
|
327 |
@Override
|
328 |
public void setTriggerRole(String triggerRole) { |
329 |
this.triggerRole = triggerRole;
|
330 |
} |
331 |
|
332 |
/**
|
333 |
* @return the allRole
|
334 |
*/
|
335 |
@Override
|
336 |
public String getAllRole() { |
337 |
return allRole;
|
338 |
} |
339 |
|
340 |
/**
|
341 |
* @param allRole the allRole to set
|
342 |
*/
|
343 |
@Override
|
344 |
public void setAllRole(String allRole) { |
345 |
this.allRole = allRole;
|
346 |
} |
347 |
|
348 |
/**
|
349 |
* @return the postCreatingStatement
|
350 |
*/
|
351 |
@Override
|
352 |
public String getPostCreatingStatement() { |
353 |
return postCreatingStatement;
|
354 |
} |
355 |
|
356 |
/**
|
357 |
* @param postCreatingStatement the postCreatingStatement to set
|
358 |
*/
|
359 |
@Override
|
360 |
public void setPostCreatingStatement(String postCreatingStatement) { |
361 |
this.postCreatingStatement = postCreatingStatement;
|
362 |
} |
363 |
|
364 |
/**
|
365 |
* @return the createIndexInGeometryRow
|
366 |
*/
|
367 |
@Override
|
368 |
public boolean getCreateIndexInGeometryRow() { |
369 |
return createIndexInGeometryRow;
|
370 |
} |
371 |
|
372 |
/**
|
373 |
* @param createIndexInGeometryRow the createIndexInGeometryRow to set
|
374 |
*/
|
375 |
@Override
|
376 |
public void setCreateIndexInGeometryRow(boolean createIndexInGeometryRow) { |
377 |
this.createIndexInGeometryRow = createIndexInGeometryRow;
|
378 |
} |
379 |
|
380 |
/**
|
381 |
* @return the updateTableStatistics
|
382 |
*/
|
383 |
@Override
|
384 |
public boolean getUpdateTableStatistics() { |
385 |
return updateTableStatistics;
|
386 |
} |
387 |
|
388 |
/**
|
389 |
* @param updateTableStatistics the updateTableStatistics to set
|
390 |
*/
|
391 |
@Override
|
392 |
public void setUpdateTableStatistics(boolean updateTableStatistics) { |
393 |
this.updateTableStatistics = updateTableStatistics;
|
394 |
} |
395 |
|
396 |
@Override
|
397 |
public boolean getTranslateHyphens() { |
398 |
return this.translateHyphens; |
399 |
} |
400 |
|
401 |
@Override
|
402 |
public boolean getRemoveSpacesInIdentifiers() { |
403 |
return this.removeSpacesInIdentifiers; |
404 |
} |
405 |
|
406 |
@Override
|
407 |
public int getCaseIdentifiersMode() { |
408 |
return caseIdentifierMode;
|
409 |
} |
410 |
|
411 |
@Override
|
412 |
public void setDeleteRows(boolean deleteRows) { |
413 |
this.deleteRows = deleteRows;
|
414 |
} |
415 |
|
416 |
@Override
|
417 |
public boolean isDeleteRows() { |
418 |
return deleteRows;
|
419 |
} |
420 |
|
421 |
@Override
|
422 |
public void setDeleteRowsFilter(Expression deleteRowsFilter) { |
423 |
this.deleteRowsFilter = deleteRowsFilter;
|
424 |
} |
425 |
|
426 |
@Override
|
427 |
public Expression getDeleteRowsFilter() { |
428 |
return deleteRowsFilter;
|
429 |
} |
430 |
|
431 |
|
432 |
|
433 |
|
434 |
@Override
|
435 |
public ExportJDBCParameters clone() throws CloneNotSupportedException { |
436 |
ExportJDBCParameters clone = (ExportJDBCParameters) super.clone();
|
437 |
clone.setExplorerParameters((JDBCServerExplorerParameters) this.explorerParameters.getCopy());
|
438 |
return clone;
|
439 |
} |
440 |
|
441 |
public static void registerPersistence() { |
442 |
|
443 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
444 |
if (manager.getDefinition("ExportJDBCParametersImpl") == null) { |
445 |
DynStruct definition = manager.addDefinition(ExportJDBCParametersImpl.class, |
446 |
"ExportJDBCParametersImpl", "ExportJDBCParametersImpl persistence definition", null, null); |
447 |
definition.addDynFieldObject("explorerParameters").setClassOfValue(JDBCServerExplorerParameters.class);
|
448 |
definition.addDynFieldString("schema");
|
449 |
definition.addDynFieldString("tableName");
|
450 |
definition.addDynFieldBoolean("canCreatetable");
|
451 |
definition.addDynFieldString("primaryKeyName");
|
452 |
definition.addDynFieldString("storeName");
|
453 |
definition.addDynFieldString("explorerName");
|
454 |
definition.addDynFieldInt("caseIdentifierMode").setMandatory(false); |
455 |
definition.addDynFieldBoolean("removeSpacesInIdentifiers");
|
456 |
definition.addDynFieldBoolean("translateHyphens");
|
457 |
definition.addDynFieldString("selectRole");
|
458 |
definition.addDynFieldString("insertRole");
|
459 |
definition.addDynFieldString("updateRole");
|
460 |
definition.addDynFieldString("deleteRole");
|
461 |
definition.addDynFieldString("truncateRole");
|
462 |
definition.addDynFieldString("referenceRole");
|
463 |
definition.addDynFieldString("triggerRole");
|
464 |
definition.addDynFieldString("allRole");
|
465 |
definition.addDynFieldString("postCreatingStatement");
|
466 |
definition.addDynFieldBoolean("createIndexInGeometryRow");
|
467 |
definition.addDynFieldBoolean("updateTableStatistics");
|
468 |
definition.addDynFieldBoolean("deleteRows").setMandatory(false); |
469 |
definition.addDynFieldObject("deleteRowsFilter").setClassOfValue(Expression.class).setMandatory(false); |
470 |
definition.extend(manager.getDefinition("AbstractExportParametersGeometry"));
|
471 |
} |
472 |
} |
473 |
|
474 |
@Override
|
475 |
public void saveToState(PersistentState state) throws PersistenceException { |
476 |
super.saveToState(state);
|
477 |
state.set("explorerParameters", explorerParameters);
|
478 |
state.set("schema", schema);
|
479 |
state.set("tableName", tableName);
|
480 |
state.set("canCreatetable", canCreatetable);
|
481 |
state.set("primaryKeyName", primaryKeyName);
|
482 |
state.set("storeName", storeName);
|
483 |
state.set("explorerName", explorerName);
|
484 |
state.set("caseIdentifierMode", caseIdentifierMode);
|
485 |
state.set("removeSpacesInIdentifiers", removeSpacesInIdentifiers);
|
486 |
state.set("translateHyphens", translateHyphens);
|
487 |
state.set("selectRole", selectRole);
|
488 |
state.set("insertRole", insertRole);
|
489 |
state.set("updateRole", updateRole);
|
490 |
state.set("deleteRole", deleteRole);
|
491 |
state.set("truncateRole", truncateRole);
|
492 |
state.set("referenceRole", referenceRole);
|
493 |
state.set("triggerRole", triggerRole);
|
494 |
state.set("allRole", allRole);
|
495 |
state.set("postCreatingStatement", postCreatingStatement);
|
496 |
state.set("createIndexInGeometryRow", createIndexInGeometryRow);
|
497 |
state.set("updateTableStatistics", updateTableStatistics);
|
498 |
state.set("deleteRows", deleteRows);
|
499 |
state.set("deleteRowsFilter", deleteRowsFilter);
|
500 |
} |
501 |
|
502 |
@Override
|
503 |
public void loadFromState(PersistentState state) throws PersistenceException { |
504 |
super.loadFromState(state);
|
505 |
this.explorerParameters = (JDBCServerExplorerParameters) state.get("explorerParameters"); |
506 |
this.schema = state.getString("schema"); |
507 |
this.tableName = state.getString("tableName"); |
508 |
this.canCreatetable = state.getBoolean("canCreatetable"); |
509 |
this.primaryKeyName = state.getString("primaryKeyName"); |
510 |
this.storeName = state.getString("storeName"); |
511 |
this.explorerName = state.getString("explorerName"); |
512 |
this.caseIdentifierMode = state.getInt("caseIdentifierMode",CASE_IDENTIFIERS_UPPERCASE); |
513 |
this.removeSpacesInIdentifiers = state.getBoolean("removeSpacesInIdentifiers"); |
514 |
this.translateHyphens = state.getBoolean("translateHyphens"); |
515 |
this.selectRole = state.getString("selectRole"); |
516 |
this.insertRole = state.getString("insertRole"); |
517 |
this.updateRole = state.getString("updateRole"); |
518 |
this.deleteRole = state.getString("deleteRole"); |
519 |
this.truncateRole = state.getString("truncateRole"); |
520 |
this.referenceRole = state.getString("referenceRole"); |
521 |
this.triggerRole = state.getString("triggerRole"); |
522 |
this.allRole = state.getString("allRole"); |
523 |
this.postCreatingStatement = state.getString("postCreatingStatement"); |
524 |
this.createIndexInGeometryRow = state.getBoolean("createIndexInGeometryRow"); |
525 |
this.updateTableStatistics = state.getBoolean("updateTableStatistics"); |
526 |
this.deleteRows = state.getBoolean("deleteRows"); |
527 |
this.deleteRowsFilter = (Expression) state.get("deleteRowsFilter"); |
528 |
|
529 |
ExportJDBCAttributeNamesTranslator nameTranslator = (ExportJDBCAttributeNamesTranslator) this.exportAttributes.getNamesTranslator();
|
530 |
nameTranslator.setParameters(this);
|
531 |
} |
532 |
|
533 |
} |