Revision 47606
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/main/java/org/gvsig/expressionevaluator/impl/DefaultExpressionBuilder.java | ||
---|---|---|
115 | 115 |
if( formatter!=null && formatter.canApply(this) ) { |
116 | 116 |
return formatter.format(this); |
117 | 117 |
} |
118 |
return MessageFormat.format(FORMAT_GROUP, this.value.toString()); |
|
118 |
return MessageFormat.format(FORMAT_GROUP, this.value.toString(formatter));
|
|
119 | 119 |
} |
120 | 120 |
} |
121 | 121 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.geometry/org.gvsig.expressionevaluator.geometry.lib/org.gvsig.expressionevaluator.geometry.lib.api/src/main/java/org/gvsig/expressionevaluator/DelegatedGeometryExpressionBuilder.java | ||
---|---|---|
51 | 51 |
|
52 | 52 |
@Override |
53 | 53 |
public Constant geometry(Geometry geom, IProjection srs) { |
54 |
return ((GeometryExpressionBuilder)this.delegate).geometry(geom); |
|
54 |
return ((GeometryExpressionBuilder)this.delegate).geometry(geom, srs);
|
|
55 | 55 |
} |
56 | 56 |
|
57 | 57 |
@Override |
... | ... | |
75 | 75 |
} |
76 | 76 |
|
77 | 77 |
@Override |
78 |
public Function as_geometry(Value value) {
|
|
78 |
public Value as_geometry(Value value) {
|
|
79 | 79 |
return ((GeometryExpressionBuilder)this.delegate).as_geometry(value); |
80 | 80 |
} |
81 | 81 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.geometry/org.gvsig.expressionevaluator.geometry.lib/org.gvsig.expressionevaluator.geometry.lib.api/src/main/java/org/gvsig/expressionevaluator/GeometryExpressionBuilderHelper.java | ||
---|---|---|
92 | 92 |
|
93 | 93 |
public Constant srs(IProjection srs); |
94 | 94 |
|
95 |
public Function as_geometry(Value value);
|
|
95 |
public Value as_geometry(Value value);
|
|
96 | 96 |
|
97 | 97 |
public Function andand(Value geom1, Value geom2); |
98 | 98 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.geometry/org.gvsig.expressionevaluator.geometry.lib/org.gvsig.expressionevaluator.geometry.lib.impl/src/test/java/org/gvsig/expresionevaluator/impl/TestExpressionBuilderFormatter.java | ||
---|---|---|
76 | 76 |
String.valueOf(builder.srs_id(geometry.getProjection())) |
77 | 77 |
); |
78 | 78 |
case NATIVE: |
79 |
return MessageFormat.format("DECODE('{0}','hex')",
|
|
79 |
return MessageFormat.format("DECODE(''{0}'', ''hex'')",
|
|
80 | 80 |
builder.bytearray_hex(GeometryUtils.toEWKB(geometry)) |
81 | 81 |
); |
82 | 82 |
case WKT: |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.geometry/org.gvsig.expressionevaluator.geometry.lib/org.gvsig.expressionevaluator.geometry.lib.impl/src/main/java/org/gvsig/expressionevaluator/impl/DefaultGeometryExpressionBuilder.java | ||
---|---|---|
92 | 92 |
} |
93 | 93 |
|
94 | 94 |
@Override |
95 |
public Function as_geometry(Value value) {
|
|
95 |
public Value as_geometry(Value value) {
|
|
96 | 96 |
return this.helper.as_geometry(value); |
97 | 97 |
} |
98 | 98 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.geometry/org.gvsig.expressionevaluator.geometry.lib/org.gvsig.expressionevaluator.geometry.lib.impl/src/main/java/org/gvsig/expressionevaluator/impl/DefaultGeometryExpressionBuilderHelper.java | ||
---|---|---|
426 | 426 |
this.getSRS() |
427 | 427 |
); |
428 | 428 |
case NATIVE: |
429 |
return MessageFormat.format("DECODE('{0}','hex')",
|
|
429 |
return MessageFormat.format("DECODE(''{0}'',''hex'')",
|
|
430 | 430 |
this.builder.builder().bytearray_hex( |
431 | 431 |
GeometryUtils.toEWKB((Geometry) geometry) |
432 | 432 |
) |
... | ... | |
491 | 491 |
} |
492 | 492 |
|
493 | 493 |
protected GeometrySupportType geometrySupportType; |
494 |
protected ExpressionBuilder builder;
|
|
494 |
private ExpressionBuilder builder;
|
|
495 | 495 |
|
496 | 496 |
public DefaultGeometryExpressionBuilderHelper(ExpressionBuilder builder) { |
497 | 497 |
this.builder = builder; |
... | ... | |
529 | 529 |
@Override |
530 | 530 |
public Constant srs(IProjection projection) { |
531 | 531 |
if( projection == null ) { |
532 |
return this.builder.constant(null); |
|
532 |
return this.builder().constant(null);
|
|
533 | 533 |
} |
534 | 534 |
return new ProjectionConstant(this, projection); |
535 | 535 |
} |
... | ... | |
537 | 537 |
@Override |
538 | 538 |
public Constant geometry(Geometry geom, IProjection projection) { |
539 | 539 |
if( geom == null ) { |
540 |
return this.builder.constant(null); |
|
540 |
return this.builder().constant(null);
|
|
541 | 541 |
} |
542 | 542 |
geom.setProjection(projection); |
543 | 543 |
return new GeometryConstant(this, geom); |
... | ... | |
546 | 546 |
@Override |
547 | 547 |
public Constant geometry(Geometry geom) { |
548 | 548 |
if( geom == null ) { |
549 |
return this.builder.constant(null); |
|
549 |
return this.builder().constant(null);
|
|
550 | 550 |
} |
551 | 551 |
if( geom.getProjection()==null ) { |
552 | 552 |
throw new IllegalArgumentException("The geometry does not have an associated projection. Use 'geometry(Geometry, IProjection)'."); |
... | ... | |
557 | 557 |
@Override |
558 | 558 |
public Constant envelope(Envelope envelope, IProjection projection) { |
559 | 559 |
if( envelope == null ) { |
560 |
return this.builder.constant(null); |
|
560 |
return this.builder().constant(null);
|
|
561 | 561 |
} |
562 | 562 |
Geometry geom = envelope.getGeometry(); |
563 | 563 |
geom.setProjection(projection); |
... | ... | |
567 | 567 |
@Override |
568 | 568 |
public Constant envelope(Envelope envelope) { |
569 | 569 |
if( envelope == null ) { |
570 |
return this.builder.constant(null); |
|
570 |
return this.builder().constant(null);
|
|
571 | 571 |
} |
572 | 572 |
if( envelope.getProjection()==null ) { |
573 | 573 |
throw new IllegalArgumentException("The envelope does not have an associated projection. Use 'envelope(Geometry, IProjection)'."); |
... | ... | |
597 | 597 |
} |
598 | 598 |
|
599 | 599 |
public Function builtin_function(String name, String format, Value... values) { |
600 |
Function func = this.builder.function(name, values); |
|
600 |
Function func = this.builder().function(name, values);
|
|
601 | 601 |
func.format(format); |
602 | 602 |
return func; |
603 | 603 |
} |
604 | 604 |
|
605 | 605 |
public Function function(String name, Value... values) { |
606 |
Function func = this.builder.function(name, values); |
|
606 |
Function func = this.builder().function(name, values);
|
|
607 | 607 |
return func; |
608 | 608 |
} |
609 | 609 |
|
610 | 610 |
@Override |
611 |
public Function as_geometry(Value value) {
|
|
611 |
public Value as_geometry(Value value) {
|
|
612 | 612 |
return builtin_function(FUNCTION_ST_ASBINARY, FORMAT_ST_ASBINARY, value); |
613 | 613 |
} |
614 | 614 |
|
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/ExportJDBCService.java | ||
---|---|---|
38 | 38 |
import org.gvsig.expressionevaluator.ExpressionUtils; |
39 | 39 |
import org.gvsig.fmap.dal.DALLocator; |
40 | 40 |
import org.gvsig.fmap.dal.DataManager; |
41 |
import org.gvsig.fmap.dal.DataStoreProviderFactory; |
|
42 |
import org.gvsig.fmap.dal.DataTransaction; |
|
41 | 43 |
import org.gvsig.fmap.dal.DataTypes; |
42 | 44 |
import org.gvsig.fmap.dal.NewDataStoreParameters; |
43 | 45 |
import org.gvsig.fmap.dal.OpenDataStoreParameters; |
... | ... | |
116 | 118 |
// restrictions if proceed. |
117 | 119 |
for (int i = 0; i < targetEditableFeatureType.size(); i++) { |
118 | 120 |
EditableFeatureAttributeDescriptor eAttr = (EditableFeatureAttributeDescriptor) targetEditableFeatureType.get(i); |
119 |
if( eAttr.isPrimaryKey() ) { |
|
121 |
if( eAttr.isPrimaryKey() && factory.allowEditableFeatureType()!=DataStoreProviderFactory.NO) {
|
|
120 | 122 |
eAttr.setIsPrimaryKey(false); |
121 | 123 |
eAttr.setAllowNull(false); |
122 | 124 |
} else { |
... | ... | |
159 | 161 |
// ====================================== |
160 | 162 |
// Remove index to improve performance |
161 | 163 |
this.targetFeatureType = targetEditableFeatureType.getNotEditableCopy(); |
162 |
for (int i = 0; i < targetEditableFeatureType.size(); i++) { |
|
163 |
EditableFeatureAttributeDescriptor x = (EditableFeatureAttributeDescriptor) targetEditableFeatureType.get(i); |
|
164 |
//x.setIsPrimaryKey(false); |
|
165 |
x.setIsIndexed(false); |
|
164 |
if( factory.allowEditableFeatureType()!=DataStoreProviderFactory.NO) { |
|
165 |
for (int i = 0; i < targetEditableFeatureType.size(); i++) { |
|
166 |
EditableFeatureAttributeDescriptor x = (EditableFeatureAttributeDescriptor) targetEditableFeatureType.get(i); |
|
167 |
//x.setIsPrimaryKey(false); |
|
168 |
x.setIsIndexed(false); |
|
169 |
} |
|
166 | 170 |
} |
167 | 171 |
|
168 | 172 |
// ====================================== |
... | ... | |
229 | 233 |
EditableFeature targetFeature = null; |
230 | 234 |
FeatureStore target = null; |
231 | 235 |
Feature feature = null; |
232 |
|
|
236 |
DataManager dataManager = DALLocator.getDataManager(); |
|
237 |
DataTransaction trans = dataManager.createTransaction(); |
|
233 | 238 |
try { |
234 | 239 |
ExportServiceManager serviceManager = ExportLocator.getServiceManager(); |
235 | 240 |
|
... | ... | |
238 | 243 |
ICoordTrans coord_trans = this.getParameters().getTransformationToUse(); |
239 | 244 |
// ============================================ |
240 | 245 |
|
241 |
DataManager dataManager = DALLocator.getDataManager(); |
|
242 | 246 |
|
243 | 247 |
JDBCServerExplorer explorer = this.createServerExplorer(); |
248 |
trans.add(explorer); |
|
244 | 249 |
|
245 | 250 |
if (this.getParameters().canCreatetable()) { |
246 | 251 |
LOG.debug("Creating table"); |
... | ... | |
375 | 380 |
} |
376 | 381 |
target.finishEditing(); |
377 | 382 |
|
378 |
if (this.getParameters().canCreatetable()) { |
|
383 |
if (this.getParameters().canCreatetable() && ((FeatureStoreProviderFactory)target.getProviderFactory()).allowEditableFeatureType()!=DataStoreProviderFactory.NO) {
|
|
379 | 384 |
getTaskStatus().message("Preparing the update of the indices" + msgRowCount); |
380 | 385 |
target.edit(); |
381 | 386 |
EditableFeatureType ft = target.getDefaultFeatureType().getEditable(); |
... | ... | |
405 | 410 |
); |
406 | 411 |
} |
407 | 412 |
LOG.info("Finish export"); |
413 |
trans.commit(); |
|
408 | 414 |
getTaskStatus().message("Exportation finished"); |
409 | 415 |
getTaskStatus().terminate(); |
410 | 416 |
|
411 | 417 |
} catch (Exception e) { |
412 | 418 |
LOG.warn("Can't export data.", e); |
419 |
trans.rollbackQuietly(); |
|
413 | 420 |
getTaskStatus().message("Problems exporting data"); |
414 | 421 |
throw new ExportException(e, targetFeature); |
415 | 422 |
|
... | ... | |
428 | 435 |
} |
429 | 436 |
target.dispose(); |
430 | 437 |
} |
438 |
DataTransaction.close(trans); |
|
431 | 439 |
this.getTaskStatus().terminate(); |
432 | 440 |
this.getTaskStatus().remove(); |
433 | 441 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.lib/src/main/java/org/gvsig/fmap/dal/resource/file/FileResource.java | ||
---|---|---|
27 | 27 |
import java.io.FileInputStream; |
28 | 28 |
import java.io.FileNotFoundException; |
29 | 29 |
import java.text.MessageFormat; |
30 |
|
|
31 | 30 |
import org.gvsig.fmap.dal.exception.InitializeException; |
32 | 31 |
import org.gvsig.fmap.dal.resource.ResourceParameters; |
33 | 32 |
import org.gvsig.fmap.dal.resource.exception.AccessResourceException; |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/impl/DefaultDatabaseWorkspaceManager.java | ||
---|---|---|
18 | 18 |
import org.gvsig.fmap.dal.DataServerExplorer; |
19 | 19 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
20 | 20 |
import org.gvsig.fmap.dal.DataStoreParameters; |
21 |
import org.gvsig.fmap.dal.DataTransaction; |
|
21 | 22 |
import org.gvsig.fmap.dal.DataTypes; |
22 | 23 |
import org.gvsig.fmap.dal.DatabaseWorkspaceManager; |
23 | 24 |
import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.CONFIG_NAME_STORESREPOSITORYID; |
... | ... | |
41 | 42 |
import org.gvsig.fmap.dal.feature.Feature; |
42 | 43 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
43 | 44 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
45 |
import org.gvsig.fmap.dal.feature.spi.LocalTransaction; |
|
44 | 46 |
import org.gvsig.tools.dispose.DisposeUtils; |
45 | 47 |
import org.gvsig.tools.dynobject.DynClass; |
46 | 48 |
import org.gvsig.tools.dynobject.DynField; |
... | ... | |
67 | 69 |
private static final String CONFIG_NAME_BASEFOLDER = "BASEFOLDER"; |
68 | 70 |
private static final String CONFIG_NAME_ALTERNATIVE_RESOURCES_PATH = "ALTERNATIVE_RESOURCES_PATH"; |
69 | 71 |
|
72 |
private DataTransaction transaction; |
|
73 |
|
|
70 | 74 |
private class CachedConfigValue extends CachedValue<String> { |
71 | 75 |
|
72 | 76 |
private final String name; |
... | ... | |
233 | 237 |
|
234 | 238 |
@Override |
235 | 239 |
public DataServerExplorer getServerExplorer() { |
240 |
DataManager dataManager = DALLocator.getDataManager(); |
|
241 |
DataServerExplorer server = null; |
|
242 |
LocalTransaction trans = new LocalTransaction(dataManager, this.getTransaction()); |
|
236 | 243 |
try { |
237 |
DataManager dataManager = DALLocator.getDataManager(); |
|
238 |
DataServerExplorer server = dataManager.openServerExplorer( |
|
244 |
trans.begin(); |
|
245 |
trans.add(this); |
|
246 |
server = dataManager.openServerExplorer( |
|
239 | 247 |
this.serverParameters.getProviderName(), |
240 | 248 |
this.serverParameters |
241 | 249 |
); |
250 |
trans.add(server); |
|
251 |
trans.commit(); |
|
242 | 252 |
return server; |
243 | 253 |
} catch (Exception ex) { |
254 |
trans.abortQuietly(); |
|
244 | 255 |
throw new RuntimeException("Can't get server explorer for workspace '"+Objects.toString(this.serverParameters)+"'", ex); |
256 |
} finally { |
|
257 |
trans.closeQuietly(); |
|
245 | 258 |
} |
246 | 259 |
} |
247 | 260 |
|
... | ... | |
254 | 267 |
|
255 | 268 |
private boolean existsTable(String tableName) { |
256 | 269 |
DataServerExplorer server = null; |
270 |
LocalTransaction trans = new LocalTransaction(null, this.getTransaction()); |
|
257 | 271 |
try { |
272 |
trans.begin(); |
|
273 |
trans.add(this); |
|
258 | 274 |
server = this.getServerExplorer(); |
275 |
trans.add(server); |
|
259 | 276 |
List<DataStoreParameters> list = server.list(); |
260 | 277 |
if(list == null){ |
278 |
trans.commit(); |
|
261 | 279 |
return false; |
262 | 280 |
} |
263 | 281 |
for (DataStoreParameters params : server.list()) { |
264 | 282 |
String theTableName = (String) params.getDynValue("Table"); |
265 | 283 |
if( StringUtils.equals(theTableName, tableName) ) { |
284 |
trans.commit(); |
|
266 | 285 |
return true; |
267 | 286 |
} |
268 | 287 |
} |
288 |
trans.commit(); |
|
269 | 289 |
} catch (Exception ex) { |
270 | 290 |
LOGGER.warn("Can't check if the table '"+tableName+"' exists.",ex); |
291 |
trans.abortQuietly(); |
|
271 | 292 |
} finally { |
293 |
trans.closeQuietly(); |
|
272 | 294 |
DisposeUtils.disposeQuietly(server); |
273 | 295 |
} |
274 | 296 |
return false; |
... | ... | |
276 | 298 |
|
277 | 299 |
private FeatureStore getTable(String tableName) { |
278 | 300 |
DataServerExplorer server = null; |
301 |
LocalTransaction trans = new LocalTransaction(null, this.getTransaction()); |
|
279 | 302 |
try { |
303 |
trans.begin(); |
|
304 |
trans.add(this); |
|
280 | 305 |
DataManager dataManager = DALLocator.getDataManager(); |
281 | 306 |
server = this.getServerExplorer(); |
307 |
trans.add(server); |
|
282 | 308 |
DataStoreParameters params = server.get(tableName); |
283 | 309 |
if( params!=null ) { |
284 | 310 |
FeatureStore store = (FeatureStore) dataManager.openStore( |
311 |
this.getTransaction(), |
|
285 | 312 |
params.getProviderName(), |
286 | 313 |
params, |
287 | 314 |
true |
288 | 315 |
); |
316 |
trans.commit(); |
|
289 | 317 |
return store; |
290 | 318 |
} |
319 |
trans.commit(); |
|
291 | 320 |
} catch (Exception ex) { |
292 | 321 |
LOGGER.warn("Can't open table '"+tableName+"'.",ex); |
322 |
trans.abortQuietly(); |
|
293 | 323 |
} finally { |
324 |
trans.closeQuietly(); |
|
294 | 325 |
DisposeUtils.disposeQuietly(server); |
295 | 326 |
} |
296 | 327 |
return null; |
... | ... | |
298 | 329 |
|
299 | 330 |
private void dropTable(String tableName) { |
300 | 331 |
DataServerExplorer server = null; |
332 |
LocalTransaction trans = new LocalTransaction(null, this.getTransaction()); |
|
301 | 333 |
try { |
334 |
trans.begin(); |
|
335 |
trans.add(this); |
|
302 | 336 |
server = this.getServerExplorer(); |
337 |
trans.add(server); |
|
303 | 338 |
DataStoreParameters params = server.get(tableName); |
304 | 339 |
if( params!=null ) { |
305 | 340 |
server.remove(params); |
306 | 341 |
} |
342 |
trans.commit(); |
|
307 | 343 |
} catch (Exception ex) { |
308 | 344 |
LOGGER.warn("Can't drop table '"+tableName+"'.",ex); |
345 |
trans.abortQuietly(); |
|
309 | 346 |
} finally { |
347 |
trans.closeQuietly(); |
|
310 | 348 |
DisposeUtils.disposeQuietly(server); |
311 | 349 |
} |
312 | 350 |
} |
... | ... | |
318 | 356 |
// la creacion de esta tabla en el helper de H2 |
319 | 357 |
|
320 | 358 |
DataServerExplorer server = null; |
359 |
LocalTransaction trans = new LocalTransaction(null, this.getTransaction()); |
|
321 | 360 |
try { |
361 |
trans.begin(); |
|
362 |
trans.add(this); |
|
322 | 363 |
server = this.getServerExplorer(); |
364 |
trans.add(server); |
|
323 | 365 |
NewFeatureStoreParameters params = (NewFeatureStoreParameters) server.getAddParameters(tableName); |
324 | 366 |
EditableFeatureType ft = params.getDefaultFeatureType(); |
325 | 367 |
ft.add(FIELD_RESOURCES_NAME, DataTypes.STRING, 150) |
... | ... | |
328 | 370 |
ft.add(FIELD_RESOURCES_RESOURCE, DataTypes.BYTEARRAY) |
329 | 371 |
.setAllowNull(true); |
330 | 372 |
server.add(tableName, params, false); |
373 |
trans.commit(); |
|
331 | 374 |
} catch (Exception ex) { |
332 | 375 |
LOGGER.debug("Can't create resources table '"+tableName+"'.",ex); |
376 |
trans.abortQuietly(); |
|
333 | 377 |
throw new RuntimeException("Can't create resources table '"+tableName+"'.", ex); |
334 | 378 |
} finally { |
379 |
trans.closeQuietly(); |
|
335 | 380 |
DisposeUtils.disposeQuietly(server); |
336 | 381 |
} |
337 | 382 |
} |
... | ... | |
343 | 388 |
@Override |
344 | 389 |
public void createTableRepository(String tableName) throws RuntimeException { |
345 | 390 |
DataServerExplorer server = null; |
391 |
LocalTransaction trans = new LocalTransaction(null, this.getTransaction()); |
|
346 | 392 |
try { |
393 |
trans.begin(); |
|
394 |
trans.add(this); |
|
347 | 395 |
server = this.getServerExplorer(); |
396 |
trans.add(server); |
|
348 | 397 |
NewFeatureStoreParameters params = (NewFeatureStoreParameters) server.getAddParameters(tableName); |
349 | 398 |
EditableFeatureType ft = params.getDefaultFeatureType(); |
350 | 399 |
ft.add(FIELD_REPOSITORY_NAME, DataTypes.STRING, 150) |
... | ... | |
356 | 405 |
.setAllowNull(false) |
357 | 406 |
.setDefaultValue(0); |
358 | 407 |
server.add(tableName, params, false); |
408 |
trans.commit(); |
|
359 | 409 |
} catch (Exception ex) { |
360 | 410 |
LOGGER.debug("Can't create repository table '"+tableName+"'.",ex); |
411 |
trans.abortQuietly(); |
|
361 | 412 |
throw new RuntimeException("Can't create repository table '"+tableName+"'.", ex); |
362 | 413 |
} finally { |
414 |
trans.closeQuietly(); |
|
363 | 415 |
DisposeUtils.disposeQuietly(server); |
364 | 416 |
} |
365 | 417 |
} |
... | ... | |
375 | 427 |
String tableName = TABLE_CONFIGURATION_NAME; |
376 | 428 |
DataServerExplorer server = null; |
377 | 429 |
FeatureStore store = null; |
430 |
LocalTransaction trans = new LocalTransaction(null, this.getTransaction()); |
|
378 | 431 |
try { |
432 |
trans.begin(); |
|
433 |
trans.add(this); |
|
379 | 434 |
server = this.getServerExplorer(); |
435 |
trans.add(server); |
|
380 | 436 |
NewFeatureStoreParameters params = (NewFeatureStoreParameters) server.getAddParameters(tableName); |
381 | 437 |
EditableFeatureType ft = params.getDefaultFeatureType(); |
382 | 438 |
ft.add(FIELD_CONFIGURATION_NAME, DataTypes.STRING, 200) |
... | ... | |
388 | 444 |
|
389 | 445 |
DataStoreParameters openParams = server.get(TABLE_CONFIGURATION_NAME); |
390 | 446 |
store = (FeatureStore) DALLocator.getDataManager().openStore( |
391 |
openParams.getProviderName(), openParams |
|
447 |
this.getTransaction(), openParams.getProviderName(), openParams
|
|
392 | 448 |
); |
393 | 449 |
store.edit(); |
394 | 450 |
EditableFeature efeature = store.createNewFeature(); |
... | ... | |
398 | 454 |
store.finishEditing(); |
399 | 455 |
|
400 | 456 |
this.existsConfiguration = null; |
457 |
trans.commit(); |
|
401 | 458 |
} catch (Exception ex) { |
402 | 459 |
LOGGER.warn("Can't create table '"+tableName+"'.",ex); |
403 |
FeatureStore.cancelEditingQuietly(store); |
|
460 |
// FeatureStore.cancelEditingQuietly(store); |
|
461 |
trans.abortQuietly(); |
|
404 | 462 |
} finally { |
463 |
trans.closeQuietly(); |
|
405 | 464 |
DisposeUtils.disposeQuietly(server); |
406 | 465 |
DisposeUtils.disposeQuietly(store); |
407 | 466 |
} |
... | ... | |
416 | 475 |
|
417 | 476 |
@Override |
418 | 477 |
public String get(String name) { |
478 |
LocalTransaction trans = new LocalTransaction(null, this.getTransaction()); |
|
419 | 479 |
try { |
420 |
if( !this.existsConfiguration() ) { |
|
480 |
trans.begin(); |
|
481 |
trans.add(this); |
|
482 |
if (!this.existsConfiguration()) { |
|
483 |
trans.commit(); |
|
421 | 484 |
return null; |
422 | 485 |
} |
423 |
if( StringUtils.equalsIgnoreCase(name, CONFIG_NAME_BASEFOLDER) ) { |
|
424 |
return Objects.toString(this.baseFolder.get(), null); |
|
486 |
if (StringUtils.equalsIgnoreCase(name, CONFIG_NAME_BASEFOLDER)) { |
|
487 |
String s = Objects.toString(this.baseFolder.get(), null); |
|
488 |
trans.commit(); |
|
489 |
return s; |
|
425 | 490 |
} |
426 |
if( StringUtils.equalsIgnoreCase(name, CONFIG_NAME_ALTERNATIVE_RESOURCES_PATH) ) { |
|
427 |
return Objects.toString(this.alternativeResourcesFolder.get(), null); |
|
491 |
if (StringUtils.equalsIgnoreCase(name, CONFIG_NAME_ALTERNATIVE_RESOURCES_PATH)) { |
|
492 |
String s = Objects.toString(this.alternativeResourcesFolder.get(), null); |
|
493 |
trans.commit(); |
|
494 |
return s; |
|
428 | 495 |
} |
429 | 496 |
CachedConfigValue cachedValue = this.cachedConfigValues.get(name); |
430 |
if( cachedValue != null ) { |
|
431 |
return cachedValue.get(); |
|
497 |
if (cachedValue != null) { |
|
498 |
String s = cachedValue.get(); |
|
499 |
trans.commit(); |
|
500 |
return s; |
|
432 | 501 |
} |
433 | 502 |
String value = this.getConfigValue(name); |
434 | 503 |
this.cachedConfigValues.put(name, new CachedConfigValue(name, value, 15000)); |
435 | 504 |
value = ExpressionUtils.evaluateDynamicText(this, value); |
505 |
trans.commit(); |
|
436 | 506 |
return value; |
437 | 507 |
} catch (Exception ex) { |
438 | 508 |
LOGGER.warn("Can't read configuration value '"+name+"'", ex); |
509 |
trans.abortQuietly(); |
|
439 | 510 |
return null; |
511 |
} finally { |
|
512 |
trans.closeQuietly(); |
|
440 | 513 |
} |
441 | 514 |
} |
442 | 515 |
|
443 | 516 |
private String getConfigValue(String name) { |
444 | 517 |
FeatureStore store = null; |
518 |
LocalTransaction trans = new LocalTransaction(null, this.getTransaction()); |
|
445 | 519 |
try { |
520 |
trans.begin(); |
|
521 |
trans.add(this); |
|
446 | 522 |
if( !this.existsConfiguration() ) { |
523 |
trans.commit(); |
|
447 | 524 |
return null; |
448 | 525 |
} |
449 | 526 |
store = this.getTable(TABLE_CONFIGURATION); |
450 | 527 |
if( store == null ) { |
528 |
trans.commit(); |
|
451 | 529 |
return null; |
452 | 530 |
} |
531 |
trans.add(store); |
|
453 | 532 |
ExpressionBuilder builder = ExpressionUtils.createExpressionBuilder(); |
454 | 533 |
String filter = builder.eq( |
455 | 534 |
builder.column(FIELD_CONFIGURATION_NAME), |
... | ... | |
457 | 536 |
).toString(); |
458 | 537 |
Feature feature = store.findFirst(filter); |
459 | 538 |
if( feature == null ) { |
539 |
trans.commit(); |
|
460 | 540 |
return null; |
461 | 541 |
} |
462 | 542 |
String value = feature.getString(FIELD_CONFIGURATION_VALUE); |
463 | 543 |
// value = ExpressionUtils.evaluateDynamicText(this, value); |
544 |
trans.commit(); |
|
464 | 545 |
return value; |
465 | 546 |
|
466 | 547 |
} catch (Exception ex) { |
467 | 548 |
LOGGER.warn("Can't read configuration value '"+name+"'", ex); |
549 |
trans.abortQuietly(); |
|
468 | 550 |
return null; |
469 | 551 |
} finally { |
552 |
trans.closeQuietly(); |
|
470 | 553 |
DisposeUtils.disposeQuietly(store); |
471 | 554 |
} |
472 | 555 |
} |
... | ... | |
474 | 557 |
@Override |
475 | 558 |
public boolean set(String name, String value) { |
476 | 559 |
FeatureStore store = null; |
560 |
LocalTransaction trans = new LocalTransaction(null, this.getTransaction()); |
|
477 | 561 |
try { |
562 |
trans.begin(); |
|
563 |
trans.add(this); |
|
478 | 564 |
if( !this.existsConfiguration() ) { |
565 |
trans.commit(); |
|
479 | 566 |
return false; |
480 | 567 |
} |
481 | 568 |
store = this.getTable(TABLE_CONFIGURATION); |
482 | 569 |
if( store == null ) { |
570 |
trans.commit(); |
|
483 | 571 |
return false; |
484 | 572 |
} |
573 |
trans.add(store); |
|
485 | 574 |
store.edit(); |
486 | 575 |
ExpressionBuilder builder = ExpressionUtils.createExpressionBuilder(); |
487 | 576 |
String filter = builder.eq( |
... | ... | |
507 | 596 |
value = ExpressionUtils.evaluateDynamicText(this, value); |
508 | 597 |
this.cachedConfigValues.get(name).set(value); |
509 | 598 |
} |
599 |
trans.commit(); |
|
510 | 600 |
return true; |
511 | 601 |
} catch (Exception ex) { |
512 | 602 |
LOGGER.warn("Can't write configuration value '"+name+"'", ex); |
603 |
trans.abortQuietly(); |
|
513 | 604 |
return false; |
514 | 605 |
} finally { |
606 |
trans.closeQuietly(); |
|
515 | 607 |
DisposeUtils.disposeQuietly(store); |
516 | 608 |
} |
517 | 609 |
} |
... | ... | |
617 | 709 |
@Override |
618 | 710 |
public boolean writeStoresRepositoryEntry(String name, DataStoreParameters parameters) { |
619 | 711 |
FeatureStore store = null; |
712 |
LocalTransaction trans = new LocalTransaction(null, this.getTransaction()); |
|
620 | 713 |
try { |
714 |
trans.begin(); |
|
715 |
trans.add(this); |
|
621 | 716 |
parameters = this.replaceInFilesToUseBaseFolder(parameters); |
622 | 717 |
byte[] data = parameters.toByteArray(); |
623 | 718 |
if( data == null ) { |
624 | 719 |
throw new RuntimeException("Can't convert parameters to byte array."); |
625 | 720 |
} |
626 | 721 |
store = this.getTable(TABLE_REPOSITORY); |
722 |
trans.add(store); |
|
627 | 723 |
store.edit(); |
628 | 724 |
ExpressionBuilder builder = ExpressionUtils.createExpressionBuilder(); |
629 | 725 |
String filter = builder.eq( |
... | ... | |
646 | 742 |
} |
647 | 743 |
store.finishEditing(); |
648 | 744 |
this.storesRepository = null; |
745 |
trans.commit(); |
|
649 | 746 |
return true; |
650 | 747 |
|
651 | 748 |
} catch (Exception ex) { |
652 | 749 |
LOGGER.warn("Can't save entry '"+name+"' in repository information", ex); |
750 |
trans.abortQuietly(); |
|
653 | 751 |
return false; |
654 | 752 |
} finally { |
753 |
trans.closeQuietly(); |
|
655 | 754 |
DisposeUtils.disposeQuietly(store); |
656 | 755 |
} |
657 | 756 |
} |
... | ... | |
731 | 830 |
|
732 | 831 |
@Override |
733 | 832 |
public void create(String id, String description) { |
734 |
if( !this.existsTable(TABLE_RESOURCES) ) { |
|
735 |
this.createTable(TABLE_RESOURCES); |
|
736 |
} |
|
737 |
if( !this.existsTable(TABLE_CONFIGURATION) ) { |
|
738 |
this.createTable(TABLE_CONFIGURATION); |
|
739 |
} |
|
740 |
if( !this.existsTable(TABLE_REPOSITORY) ) { |
|
741 |
this.createTable(TABLE_REPOSITORY); |
|
742 |
} |
|
743 |
this.set(CONFIG_NAME_STORESREPOSITORYID,id); |
|
744 |
this.set(CONFIG_NAME_STORESREPOSITORYLABEL,description); |
|
745 |
this.set(CONFIG_CAN_ANONYMOUS_USER_WRITE_IN_THE_TABLES,"true"); |
|
746 |
this.set(CONFIG_NAME_ALTERNATIVE_RESOURCES_PATH,""); |
|
747 |
File theBaseFolder = this.getBaseFolder(); |
|
748 |
if( this.serverParameters instanceof HasAFile && theBaseFolder==null ) { |
|
749 |
File f = ((HasAFile)this.serverParameters).getFile(); |
|
750 |
if( f != null ) { |
|
751 |
theBaseFolder = f.getParentFile(); |
|
752 |
this.setBaseFolder(theBaseFolder); |
|
833 |
LocalTransaction trans = new LocalTransaction(null, this.getTransaction()); |
|
834 |
try { |
|
835 |
trans.begin(); |
|
836 |
trans.add(this); |
|
837 |
|
|
838 |
if (!this.existsTable(TABLE_RESOURCES)) { |
|
839 |
this.createTable(TABLE_RESOURCES); |
|
840 |
} |
|
841 |
if (!this.existsTable(TABLE_CONFIGURATION)) { |
|
842 |
this.createTable(TABLE_CONFIGURATION); |
|
843 |
} |
|
844 |
if (!this.existsTable(TABLE_REPOSITORY)) { |
|
845 |
this.createTable(TABLE_REPOSITORY); |
|
846 |
} |
|
847 |
this.set(CONFIG_NAME_STORESREPOSITORYID, id); |
|
848 |
this.set(CONFIG_NAME_STORESREPOSITORYLABEL, description); |
|
849 |
this.set(CONFIG_CAN_ANONYMOUS_USER_WRITE_IN_THE_TABLES, "true"); |
|
850 |
this.set(CONFIG_NAME_ALTERNATIVE_RESOURCES_PATH, ""); |
|
851 |
File theBaseFolder = this.getBaseFolder(); |
|
852 |
if (this.serverParameters instanceof HasAFile && theBaseFolder == null) { |
|
853 |
File f = ((HasAFile) this.serverParameters).getFile(); |
|
854 |
if (f != null) { |
|
855 |
theBaseFolder = f.getParentFile(); |
|
856 |
this.setBaseFolder(theBaseFolder); |
|
857 |
} else { |
|
858 |
this.set(CONFIG_NAME_BASEFOLDER, ""); |
|
859 |
} |
|
753 | 860 |
} else { |
754 |
this.set(CONFIG_NAME_BASEFOLDER,""); |
|
861 |
this.set(CONFIG_NAME_BASEFOLDER, "");
|
|
755 | 862 |
} |
756 |
} else { |
|
757 |
this.set(CONFIG_NAME_BASEFOLDER,""); |
|
863 |
trans.commit(); |
|
864 |
} catch (RuntimeException ex) { |
|
865 |
trans.abortQuietly(); |
|
866 |
throw ex; |
|
867 |
} catch (Exception ex) { |
|
868 |
trans.abortQuietly(); |
|
869 |
throw new RuntimeException("Can't create table " + id, ex); |
|
870 |
} finally { |
|
871 |
trans.closeQuietly(); |
|
758 | 872 |
} |
759 | 873 |
} |
760 | 874 |
|
761 | 875 |
@Override |
762 | 876 |
public boolean exists(String name) { |
763 | 877 |
FeatureStore store = null; |
878 |
LocalTransaction trans = new LocalTransaction(null, this.getTransaction()); |
|
764 | 879 |
try { |
880 |
trans.begin(); |
|
881 |
trans.add(this); |
|
765 | 882 |
if( StringUtils.equalsIgnoreCase(name, "WORKSPACEFILE") ) { |
766 | 883 |
File wsfile = getWorkspaceFile(); |
767 | 884 |
if( wsfile!=null ) { |
885 |
trans.commit(); |
|
768 | 886 |
return true; |
769 | 887 |
} |
770 | 888 |
} |
771 | 889 |
if (this.existsConfiguration()) { |
772 | 890 |
if( StringUtils.equalsIgnoreCase(name, CONFIG_NAME_BASEFOLDER) ) { |
891 |
trans.commit(); |
|
773 | 892 |
return true; |
774 | 893 |
} |
775 | 894 |
if( this.cachedConfigValues.containsKey(name) ) { |
895 |
trans.commit(); |
|
776 | 896 |
return true; |
777 | 897 |
} |
778 | 898 |
store = this.getTable(TABLE_CONFIGURATION); |
899 |
trans.add(store); |
|
779 | 900 |
if (store != null) { |
780 | 901 |
ExpressionBuilder builder = ExpressionUtils.createExpressionBuilder(); |
781 | 902 |
String filter = builder.eq( |
... | ... | |
787 | 908 |
String value = feature.getString(FIELD_CONFIGURATION_VALUE); |
788 | 909 |
value = ExpressionUtils.evaluateDynamicText(this, value); |
789 | 910 |
this.cachedConfigValues.put(name, new CachedConfigValue(name, value, 15000)); |
911 |
trans.commit(); |
|
790 | 912 |
return true; |
791 | 913 |
} |
792 | 914 |
} |
793 | 915 |
} |
794 |
return super.exists(name); |
|
916 |
boolean b = super.exists(name); |
|
917 |
trans.commit(); |
|
918 |
return b; |
|
795 | 919 |
} catch (Exception ex) { |
796 | 920 |
LOGGER.warn("Can't read configuration value '" + name + "'", ex); |
921 |
trans.abortQuietly(); |
|
797 | 922 |
return false; |
798 | 923 |
} finally { |
924 |
trans.closeQuietly(); |
|
799 | 925 |
DisposeUtils.disposeQuietly(store); |
800 | 926 |
} |
801 | 927 |
} |
... | ... | |
818 | 944 |
@Override |
819 | 945 |
public Collection<String> localvariables() { |
820 | 946 |
FeatureStore store = null; |
947 |
LocalTransaction trans = new LocalTransaction(null, this.getTransaction()); |
|
821 | 948 |
try { |
949 |
trans.begin(); |
|
950 |
trans.add(this); |
|
822 | 951 |
final List<String> theVars = new ArrayList<>(); |
823 | 952 |
if (this.existsConfiguration()) { |
824 | 953 |
store = this.getTable(TABLE_CONFIGURATION); |
... | ... | |
829 | 958 |
}); |
830 | 959 |
} |
831 | 960 |
} |
961 |
trans.commit(); |
|
832 | 962 |
return theVars; |
833 | 963 |
} catch (Exception ex) { |
834 | 964 |
LOGGER.warn("Can't read configuration variables", ex); |
965 |
trans.abortQuietly(); |
|
835 | 966 |
return Collections.EMPTY_LIST; |
836 | 967 |
} finally { |
968 |
trans.closeQuietly(); |
|
837 | 969 |
DisposeUtils.disposeQuietly(store); |
838 | 970 |
} |
839 | 971 |
} |
... | ... | |
841 | 973 |
@Override |
842 | 974 |
public ResourcesStorage getResourcesStorage() { |
843 | 975 |
DataServerExplorer server = null; |
976 |
LocalTransaction trans = new LocalTransaction(null, this.getTransaction()); |
|
844 | 977 |
try { |
978 |
trans.begin(); |
|
979 |
trans.add(this); |
|
845 | 980 |
server = this.getServerExplorer(); |
981 |
trans.add(server); |
|
846 | 982 |
ResourcesStorage resourcesStorage = server.getResourcesStorage(); |
983 |
trans.commit(); |
|
847 | 984 |
return resourcesStorage; |
848 | 985 |
} catch (Exception ex) { |
986 |
trans.abortQuietly(); |
|
849 | 987 |
LOGGER.warn("Can't get resorces storage.",ex); |
850 | 988 |
return null; |
851 | 989 |
} finally { |
990 |
trans.closeQuietly(); |
|
852 | 991 |
DisposeUtils.disposeQuietly(server); |
853 | 992 |
} |
854 | 993 |
} |
... | ... | |
902 | 1041 |
return label; |
903 | 1042 |
} |
904 | 1043 |
|
1044 |
@Override |
|
1045 |
public void setTransaction(DataTransaction transaction) { |
|
1046 |
this.transaction = transaction; |
|
1047 |
} |
|
1048 |
|
|
1049 |
@Override |
|
1050 |
public DataTransaction getTransaction() { |
|
1051 |
return this.transaction; |
|
1052 |
} |
|
1053 |
|
|
1054 |
|
|
1055 |
|
|
905 | 1056 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/impl/DefaultDataManager.java | ||
---|---|---|
15 | 15 |
import java.util.Set; |
16 | 16 |
import java.util.UUID; |
17 | 17 |
import java.util.function.Predicate; |
18 |
import java.util.logging.Level; |
|
18 | 19 |
import javax.json.JsonArray; |
19 | 20 |
import javax.json.JsonObject; |
20 | 21 |
import javax.json.JsonValue; |
... | ... | |
81 | 82 |
import org.gvsig.fmap.dal.feature.paging.impl.FeaturePagingHelperImpl; |
82 | 83 |
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider; |
83 | 84 |
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProviderServices; |
85 |
import org.gvsig.fmap.dal.feature.spi.LocalTransaction; |
|
84 | 86 |
import org.gvsig.fmap.dal.feature.spi.cache.FeatureCacheProvider; |
85 | 87 |
import org.gvsig.fmap.dal.feature.spi.cache.FeatureCacheProviderFactory; |
86 | 88 |
import org.gvsig.fmap.dal.feature.spi.index.FeatureIndexProvider; |
... | ... | |
568 | 570 |
} |
569 | 571 |
|
570 | 572 |
@Override |
573 |
public DataStore openStore(DataTransaction transaction, String providerName, DataStoreParameters parameters) throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException { |
|
574 |
return this.openStore(transaction, providerName, parameters, false); |
|
575 |
} |
|
576 |
|
|
577 |
@Override |
|
571 | 578 |
public DataStore openStore(String providerName, DataStoreParameters parameters) throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException { |
572 |
return this.openStore(providerName, parameters, false); |
|
579 |
return this.openStore((DataTransaction)null, providerName, parameters, false);
|
|
573 | 580 |
} |
574 | 581 |
|
575 | 582 |
@Override |
576 | 583 |
public DataStore openStore(String providerName, DataStoreParameters parameters, boolean ignoreDALResource) throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException { |
584 |
return this.openStore((DataTransaction)null, providerName, parameters, ignoreDALResource); |
|
585 |
} |
|
586 |
|
|
587 |
@Override |
|
588 |
public DataStore openStore(DataTransaction transaction, String providerName, DataStoreParameters parameters, boolean ignoreDALResource) throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException { |
|
577 | 589 |
if (providerName == null) { |
578 | 590 |
String msg = "Provider name can't be null."; |
579 | 591 |
LOGGER.warn(msg); |
... | ... | |
609 | 621 |
DataStore store = (DataStore) storeFactory.create(parameters, this); |
610 | 622 |
if( store instanceof DefaultFeatureStore ) { |
611 | 623 |
((DefaultFeatureStore)store).setIgnoreDALResource(ignoreDALResource); |
624 |
try { |
|
625 |
DataTransaction.add(transaction, (FeatureStore) store, false); |
|
626 |
} catch (Exception ex) { |
|
627 |
throw new InitializeException(store.getFullName(), ex); |
|
628 |
} |
|
629 |
|
|
612 | 630 |
} |
613 | 631 |
DataStoreProvider provider = (DataStoreProvider) providerFactory.create(parameters, store); |
614 | 632 |
|
... | ... | |
1263 | 1281 |
} |
1264 | 1282 |
} |
1265 | 1283 |
} |
1284 |
LocalTransaction trans = new LocalTransaction(this,null); |
|
1266 | 1285 |
try { |
1286 |
trans.begin(); |
|
1287 |
trans.add(databaseWorkspace); |
|
1267 | 1288 |
ResourcesStorage resources = databaseWorkspace.getResourcesStorage(); |
1268 | 1289 |
ScriptManager scriptManager = ToolsLocator.getScriptManager(); |
1269 | 1290 |
Script script = scriptManager.loadScript(resources, "OnConnectToWorkspace.script"); |
1270 | 1291 |
if( script != null ) { |
1271 | 1292 |
script.invokeFunction("main", new Object[] {databaseWorkspace}); |
1272 | 1293 |
} |
1294 |
trans.commit(); |
|
1273 | 1295 |
} catch(Throwable th) { |
1274 | 1296 |
LOGGER.warn("Problems executing 'OnConnectToWorkspace.script' from workspace '"+databaseWorkspace.getId()+"'.",th); |
1297 |
trans.abortQuietly(); |
|
1298 |
} finally { |
|
1299 |
trans.closeQuietly(); |
|
1275 | 1300 |
} |
1276 | 1301 |
} |
1277 | 1302 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/impl/DefaultTransaction.java | ||
---|---|---|
24 | 24 |
|
25 | 25 |
import java.util.ArrayList; |
26 | 26 |
import java.util.HashMap; |
27 |
import java.util.HashSet; |
|
27 | 28 |
import java.util.List; |
28 | 29 |
import java.util.Map; |
30 |
import java.util.Set; |
|
29 | 31 |
import java.util.UUID; |
30 | 32 |
import org.apache.commons.lang3.StringUtils; |
31 | 33 |
import org.apache.commons.lang3.tuple.MutablePair; |
... | ... | |
62 | 64 |
private boolean inProgress; |
63 | 65 |
private List<Disposable> disposables; |
64 | 66 |
private ObservableHelper observableHelper; |
67 |
private Set<SupportTransactions> supportTransactions; |
|
65 | 68 |
|
66 | 69 |
public DefaultTransaction() { |
67 | 70 |
this.code = UUID.randomUUID().toString().replace("-", ""); |
68 | 71 |
this.stores = new HashMap<>(); |
69 | 72 |
this.explorers = new HashMap<>(); |
70 | 73 |
this.disposables = new ArrayList<>(); |
74 |
this.supportTransactions = new HashSet<>(); |
|
71 | 75 |
this.inProgress = false; |
72 | 76 |
this.connections = new HashMap<>(); |
73 | 77 |
this.observableHelper = new ObservableHelper(); |
... | ... | |
157 | 161 |
|
158 | 162 |
@Override |
159 | 163 |
public void add(DataStore store, String id, boolean local) { |
164 |
if(store == null){ |
|
165 |
throw new IllegalArgumentException("The store is required."); |
|
166 |
} |
|
160 | 167 |
String theId = id; |
161 | 168 |
if( StringUtils.isBlank(id) ) { |
162 | 169 |
theId = store.hashCode() + "@"+ store.getFullName(); |
... | ... | |
200 | 207 |
|
201 | 208 |
@Override |
202 | 209 |
public void add(DataServerExplorer explorer, String id, boolean local) { |
210 |
if(explorer == null){ |
|
211 |
throw new IllegalArgumentException("The explorer is required."); |
|
212 |
} |
|
203 | 213 |
String theId = id; |
204 | 214 |
if( StringUtils.isBlank(id) ) { |
205 | 215 |
theId = String.valueOf(explorer.hashCode()); |
... | ... | |
233 | 243 |
} |
234 | 244 |
|
235 | 245 |
@Override |
246 |
public void add(SupportTransactions obj, boolean local) throws DataException { |
|
247 |
if(obj == null){ |
|
248 |
throw new IllegalArgumentException("The transaction supplier is required."); |
|
249 |
} |
|
250 |
if(obj instanceof DataStore){ |
|
251 |
this.add((DataStore)obj, local); |
|
252 |
return; |
|
253 |
} |
|
254 |
if(obj instanceof DataServerExplorer){ |
|
255 |
this.add((DataServerExplorer)obj, local); |
|
256 |
return; |
|
257 |
} |
|
258 |
obj.setTransaction(this); |
|
259 |
if(!local){ |
|
260 |
DisposeUtils.bind(obj); |
|
261 |
} |
|
262 |
this.supportTransactions.add(obj); |
|
263 |
} |
|
264 |
|
|
265 |
@Override |
|
236 | 266 |
public void remove(DataStore store) { |
237 | 267 |
if( this.inProgress && !DisposeUtils.isNullOrDisposed(store)){ |
238 | 268 |
throw new IllegalStateException("Can't remove store from a in progress transaction."); |
... | ... | |
307 | 337 |
} |
308 | 338 |
DisposeUtils.disposeQuietly(resource); |
309 | 339 |
} |
340 |
for (SupportTransactions obj : supportTransactions) { |
|
341 |
obj.setTransaction(null); |
|
342 |
DisposeUtils.disposeQuietly(obj); |
|
343 |
} |
|
310 | 344 |
for (ConnectionService connection : this.connections.values()) { |
311 | 345 |
connection.dispose(); |
312 | 346 |
} |
347 |
this.supportTransactions = null; |
|
313 | 348 |
this.disposables = null; |
314 | 349 |
this.stores = null; |
315 | 350 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeatureStore.java | ||
---|---|---|
141 | 141 |
import org.gvsig.fmap.dal.feature.spi.FeatureReferenceProviderServices; |
142 | 142 |
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider; |
143 | 143 |
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProviderServices; |
144 |
import org.gvsig.fmap.dal.feature.spi.LocalTransaction; |
|
144 | 145 |
import org.gvsig.fmap.dal.feature.spi.cache.FeatureCacheProvider; |
145 | 146 |
import org.gvsig.fmap.dal.feature.spi.index.FeatureIndexProviderServices; |
146 | 147 |
import org.gvsig.fmap.dal.impl.DefaultDataManager; |
... | ... | |
181 | 182 |
import org.gvsig.tools.persistence.Persistent; |
182 | 183 |
import org.gvsig.tools.persistence.PersistentState; |
183 | 184 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
185 |
import org.gvsig.tools.resourcesstorage.CompoundResourcesStorage; |
|
184 | 186 |
import org.gvsig.tools.resourcesstorage.ResourcesStorage; |
185 | 187 |
import org.gvsig.tools.undo.RedoException; |
186 | 188 |
import org.gvsig.tools.undo.UndoException; |
... | ... | |
2000 | 2002 |
} |
2001 | 2003 |
} |
2002 | 2004 |
|
2005 |
|
|
2003 | 2006 |
@Override |
2004 | 2007 |
synchronized public void finishEditing() throws DataException { |
2005 | 2008 |
LOGGER.debug("finish editing of mode: {}", mode); |
2009 |
LocalTransaction trans = new LocalTransaction(this.dataManager, this.getTransaction()); |
|
2006 | 2010 |
try { |
2007 | 2011 |
Map<String, List<FeatureAttributeDescriptor>> computedFields = this.getComputedFields(); |
2008 | 2012 |
switch (mode) { |
... | ... | |
2016 | 2020 |
if (notifyChange(FeatureStoreNotification.BEFORE_FINISHEDITING).isCanceled()) { |
2017 | 2021 |
return; |
2018 | 2022 |
} |
2023 |
trans.begin(); |
|
2024 |
trans.add(this); |
|
2019 | 2025 |
saveDALFile(); |
2020 | 2026 |
provider.endAppend(); |
2021 | 2027 |
exitEditingMode(); |
2022 | 2028 |
this.updateComputedFields(computedFields); |
2023 | 2029 |
loadDALFile(); |
2024 | 2030 |
updateIndexes(); |
2031 |
trans.commit(); |
|
2032 |
trans.close(); |
|
2025 | 2033 |
notifyChange(FeatureStoreNotification.AFTER_FINISHEDITING); |
2026 | 2034 |
break; |
2027 | 2035 |
|
... | ... | |
2044 | 2052 |
featureManager.isSelectionCompromised()).isCanceled()) { |
2045 | 2053 |
return; |
2046 | 2054 |
} |
2055 |
trans.begin(); |
|
2056 |
trans.add(this); |
|
2047 | 2057 |
saveDALFile(); |
2048 | 2058 |
if (featureManager.isSelectionCompromised() && selection != null) { |
2049 | 2059 |
selection = null; |
... | ... | |
2061 | 2071 |
exitEditingMode(); |
2062 | 2072 |
loadDALFile(); |
2063 | 2073 |
updateIndexes(); |
2074 |
trans.commit(); |
|
2075 |
trans.close(); |
|
2064 | 2076 |
} else { |
2065 | 2077 |
exitEditingMode(); |
2066 | 2078 |
} |
... | ... | |
2080 | 2092 |
} |
2081 | 2093 |
} catch (ValidateFeaturesException | WriteNotAllowedException ex) { |
2082 | 2094 |
// Don't notify failed. |
2095 |
trans.abortQuietly(); |
|
2083 | 2096 |
throw ex; |
2084 | 2097 |
} catch (PerformEditingException pee) { |
2098 |
trans.abortQuietly(); |
|
2085 | 2099 |
notifyChange(FeatureStoreNotification.FAILED_FINISHEDITING); |
2086 | 2100 |
throw new WriteException(provider.getSourceId().toString(), pee); |
2087 | 2101 |
} catch (Exception e) { |
2102 |
trans.abortQuietly(); |
|
2088 | 2103 |
notifyChange(FeatureStoreNotification.FAILED_FINISHEDITING); |
2089 | 2104 |
throw new FinishEditingException(e); |
2105 |
} finally { |
|
2106 |
trans.closeQuietly(); |
|
2090 | 2107 |
} |
2091 | 2108 |
} |
2092 |
|
|
2109 |
|
|
2093 | 2110 |
@Override |
2094 | 2111 |
public String getEditingSession() { |
2095 | 2112 |
return this.editingSessionCode; |
... | ... | |
2388 | 2405 |
|
2389 | 2406 |
@Override |
2390 | 2407 |
public void copyTo(final FeatureStore target) { |
2408 |
LocalTransaction trans = new LocalTransaction(this.getDataManager(), this.getTransaction(), ((DefaultFeatureStore)target).getTransaction()); |
|
2391 | 2409 |
boolean finishEditingAtEnd = false; |
2392 | 2410 |
try { |
2411 |
trans.begin(); |
|
2412 |
trans.add(this); //Es posible que hubiera que pasarle un local a true |
|
2413 |
trans.add(target); //Es posible que hubiera que pasarle un local a true |
|
2393 | 2414 |
if (!target.isEditing() && !target.isAppending()) { |
2394 | 2415 |
finishEditingAtEnd = true; |
2395 | 2416 |
target.edit(MODE_APPEND); |
... | ... | |
2402 | 2423 |
if (finishEditingAtEnd) { |
2403 | 2424 |
target.finishEditing(); |
2404 | 2425 |
} |
2426 |
trans.commit(); |
|
2405 | 2427 |
|
2406 | 2428 |
} catch (Exception ex) { |
2407 | 2429 |
try { |
... | ... | |
2410 | 2432 |
} |
2411 | 2433 |
} catch (Exception ex1) { |
2412 | 2434 |
} |
2435 |
trans.abortQuietly(); |
|
2413 | 2436 |
throw new RuntimeException("Can't copy store.", ex); |
2437 |
} finally { |
|
2438 |
trans.closeQuietly(); |
|
2414 | 2439 |
} |
2415 | 2440 |
|
2416 | 2441 |
} |
... | ... | |
3789 | 3814 |
@Override |
3790 | 3815 |
public ResourcesStorage getResourcesStorage() { |
3791 | 3816 |
if (this.resourcesStorage != null) { |
3817 |
if(this.resourcesStorage instanceof SupportTransactions){ |
|
3818 |
((SupportTransactions)this.resourcesStorage).setTransaction(transaction); |
|
3819 |
} else if(this.resourcesStorage instanceof CompoundResourcesStorage) { |
|
3820 |
for (ResourcesStorage storage : (CompoundResourcesStorage)this.resourcesStorage) { |
|
3821 |
if(storage instanceof SupportTransactions){ |
|
3822 |
((SupportTransactions)storage).setTransaction(transaction); |
|
3823 |
} |
|
3824 |
} |
|
3825 |
} |
|
3792 | 3826 |
DisposeUtils.bind(this.resourcesStorage); |
3793 | 3827 |
return this.resourcesStorage; |
3794 | 3828 |
} |
... | ... | |
3968 | 4002 |
this.transaction.deleteObserver(transactionObserver); |
3969 | 4003 |
} |
3970 | 4004 |
this.transaction = transaction; |
3971 |
if (transaction == null || transaction instanceof DataTransactionServices) { |
|
3972 |
this.provider.setTransaction((DataTransactionServices) transaction); |
|
4005 |
if (this.provider != null){ |
|
4006 |
if (transaction == null || transaction instanceof DataTransactionServices) { |
|
4007 |
this.provider.setTransaction((DataTransactionServices) transaction); |
|
4008 |
} |
|
3973 | 4009 |
} |
3974 | 4010 |
if( transaction!=null ) { |
3975 | 4011 |
transaction.addObserver(transactionObserver); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/test/java/org/gvsig/fmap/dal/store/jdbc2/AbstractTestExport2db.java | ||
---|---|---|
3 | 3 |
import junit.framework.TestCase; |
4 | 4 |
import static junit.framework.TestCase.assertEquals; |
5 | 5 |
import org.gvsig.fmap.dal.DatabaseWorkspaceManager; |
6 |
import org.gvsig.fmap.dal.exception.SQLBuilderUnsupportedOperationException; |
|
6 | 7 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
7 | 8 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
8 | 9 |
import org.gvsig.fmap.dal.feature.FeatureType; |
9 | 10 |
import org.gvsig.tools.dispose.DisposeUtils; |
11 |
import org.gvsig.tools.exception.BaseException; |
|
10 | 12 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
11 | 13 |
import org.slf4j.Logger; |
12 | 14 |
import org.slf4j.LoggerFactory; |
... | ... | |
142 | 144 |
|
143 | 145 |
|
144 | 146 |
DisposeUtils.dispose(dbstore); |
147 |
// } catch (SQLBuilderUnsupportedOperationException th) { |
|
148 |
// LOGGER.warn("Unsupported sql", th); |
|
145 | 149 |
} catch (Throwable th) { |
150 |
if(BaseException.containsCause(th, SQLBuilderUnsupportedOperationException.class)){ |
|
151 |
LOGGER.warn("Unsupported sql", th); |
|
152 |
return; |
|
153 |
} |
|
146 | 154 |
LOGGER.warn("", th); |
147 | 155 |
throw th; |
148 | 156 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/test/java/org/gvsig/fmap/dal/store/jdbc2/AbstractTestUtils.java | ||
---|---|---|
19 | 19 |
import org.gvsig.fmap.dal.DataManager; |
20 | 20 |
import org.gvsig.fmap.dal.DataStore; |
21 | 21 |
import static org.gvsig.fmap.dal.DataStore.H2SPATIAL_PROVIDER_NAME; |
22 |
import org.gvsig.fmap.dal.DataTransaction; |
|
22 | 23 |
import org.gvsig.fmap.dal.DatabaseWorkspaceManager; |
23 | 24 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
24 | 25 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
... | ... | |
473 | 474 |
|
474 | 475 |
public void insert_into_from(JDBCServerExplorer targetExplorer, String targetName, FeatureStore sourceStore, int mode) throws Exception { |
475 | 476 |
FeatureStore targetStore = openStore(targetExplorer, targetName); |
476 |
targetStore.edit(mode); |
|
477 |
try { |
|
478 |
for (Feature sourceFeature : sourceStore.getFeatureSet()) { |
|
479 |
EditableFeature targetFeature = targetStore.createNewFeature(sourceFeature); |
|
480 |
targetStore.insert(targetFeature); |
|
481 |
} |
|
482 |
} finally { |
|
483 |
targetStore.finishEditing(); |
|
477 |
switch(mode){ |
|
478 |
case FeatureStore.MODE_FULLEDIT: |
|
479 |
targetStore.edit(mode); |
|
480 |
try { |
|
481 |
for (Feature sourceFeature : sourceStore.getFeatureSet()) { |
|
482 |
EditableFeature targetFeature = targetStore.createNewFeature(sourceFeature); |
|
483 |
targetStore.insert(targetFeature); |
|
484 |
} |
|
485 |
} finally { |
|
486 |
targetStore.finishEditing(); |
|
487 |
} |
|
488 |
break; |
|
489 |
default: |
|
490 |
DataTransaction trans = DALLocator.getDataManager().createTransaction(); |
|
491 |
trans.begin(); |
|
492 |
trans.add(targetStore); |
|
493 |
targetStore.edit(mode); |
|
494 |
try { |
|
495 |
for (Feature sourceFeature : sourceStore.getFeatureSet()) { |
|
496 |
EditableFeature targetFeature = targetStore.createNewFeature(sourceFeature); |
|
497 |
targetStore.insert(targetFeature); |
|
498 |
} |
|
499 |
} finally { |
|
500 |
targetStore.finishEditing(); |
|
501 |
} |
|
502 |
trans.commit(); |
|
503 |
trans.close(); |
|
504 |
break; |
|
484 | 505 |
} |
485 | 506 |
} |
486 | 507 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/test/java/org/gvsig/fmap/dal/store/jdbc2/AbstractTestJsonValue.java | ||
---|---|---|
87 | 87 |
0 |
88 | 88 |
); |
89 | 89 |
String sql = resultSetForSetProvider.getSQL(); |
90 |
System.out.println(sql); |
|
90 |
System.out.println("###### testJsonValue(0)"); |
|
91 |
System.out.println("###### SQL:" + sql + ";"); |
|
92 |
System.out.println("###### EXP:" + expectedSQLs.get(0) + ";"); |
|
93 |
|
|
91 | 94 |
assertEquals("ResultSetForSetProvider SQL", expectedSQLs.get(0), sql); |
92 | 95 |
} catch (Throwable th) { |
93 | 96 |
LOGGER.warn("", th); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/JDBCResourcesStorage.java | ||
---|---|---|
54 | 54 |
import org.gvsig.expressionevaluator.ExpressionUtils; |
55 | 55 |
import org.gvsig.fmap.dal.DALLocator; |
56 | 56 |
import org.gvsig.fmap.dal.DataManager; |
57 |
import org.gvsig.fmap.dal.DataTransaction; |
|
57 | 58 |
import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.FIELD_RESOURCES_NAME; |
58 | 59 |
import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.FIELD_RESOURCES_RESOURCE; |
59 | 60 |
import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.TABLE_RESOURCES_NAME; |
61 |
import org.gvsig.fmap.dal.SupportTransactions; |
|
60 | 62 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
61 | 63 |
import org.gvsig.fmap.dal.feature.Feature; |
62 | 64 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
63 | 65 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
66 |
import org.gvsig.fmap.dal.spi.DataTransactionServices; |
|
64 | 67 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
65 | 68 |
import org.gvsig.fmap.dal.store.jdbc.exception.SQLRuntimeException; |
66 | 69 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
... | ... | |
81 | 84 |
* @author jjdelcerro |
82 | 85 |
*/ |
83 | 86 |
@SuppressWarnings("UseSpecificCatch") |
84 |
public class JDBCResourcesStorage extends AbstractResourcesStorage { |
|
87 |
public class JDBCResourcesStorage extends AbstractResourcesStorage implements SupportTransactions {
|
|
85 | 88 |
|
86 | 89 |
private static final Logger LOGGER = LoggerFactory.getLogger(JDBCResourcesStorage.class); |
87 | 90 |
public static final String TABLENAME_SERVER_EXPLORER_MARK = "$ServerExplorer"; |
88 | 91 |
|
89 | 92 |
private final JDBCHelper helper; |
90 |
|
|
93 |
|
|
91 | 94 |
private static class ExistsResourcesCache extends CachedValue<Map<String,Boolean>> { |
92 | 95 |
@Override |
93 | 96 |
protected void reload() { |
... | ... | |
203 | 206 |
try { |
204 | 207 |
DataManager dataManager = DALLocator.getDataManager(); |
205 | 208 |
store = (FeatureStore) dataManager.openStore( |
209 |
this.storage.getTransaction(), |
|
206 | 210 |
this.getStoreParameters().getDataStoreName(), |
207 | 211 |
this.getStoreParameters() |
208 | 212 |
); |
... | ... | |
272 | 276 |
} |
273 | 277 |
DataManager dataManager = DALLocator.getDataManager(); |
274 | 278 |
store = (FeatureStore) dataManager.openStore( |
279 |
this.storage.getTransaction(), |
|
275 | 280 |
this.getStoreParameters().getDataStoreName(), |
276 | 281 |
this.getStoreParameters() |
277 | 282 |
); |
... | ... | |
453 | 458 |
try { |
454 | 459 |
DataManager dataManager = DALLocator.getDataManager(); |
455 | 460 |
store = (FeatureStore) dataManager.openStore( |
461 |
this.storage.getTransaction(), |
|
456 | 462 |
this.getStoreParameters().getDataStoreName(), |
457 | 463 |
this.getStoreParameters() |
458 | 464 |
); |
... | ... | |
545 | 551 |
} |
546 | 552 |
|
547 | 553 |
@Override |
554 |
public void setTransaction(DataTransaction transaction) { |
|
555 |
this.helper.setTransaction((DataTransactionServices) transaction); |
|
556 |
} |
|
557 |
|
|
558 |
@Override |
|
559 |
public DataTransaction getTransaction() { |
|
560 |
return this.helper.getTransaction(); |
|
561 |
} |
|
562 |
|
|
563 |
@Override |
|
548 | 564 |
public boolean isEmpty() { |
549 | 565 |
return this.resourcesStoreParameters == null; |
550 | 566 |
} |
... | ... | |
564 | 580 |
DataManager dataManager = DALLocator.getDataManager(); |
565 | 581 |
Set<String> typeNames = new HashSet<>(); |
566 | 582 |
store = (FeatureStore) dataManager.openStore( |
583 |
this.getTransaction(), |
|
567 | 584 |
this.resourcesStoreParameters.getDataStoreName(), |
568 | 585 |
this.resourcesStoreParameters |
569 | 586 |
); |
... | ... | |
618 | 635 |
try { |
619 | 636 |
DataManager dataManager = DALLocator.getDataManager(); |
620 | 637 |
store = (FeatureStore) dataManager.openStore( |
638 |
this.getTransaction(), |
|
621 | 639 |
this.resourcesStoreParameters.getDataStoreName(), |
622 | 640 |
this.resourcesStoreParameters |
623 | 641 |
); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/JDBCStoreProviderBase.java | ||
---|---|---|
38 | 38 |
import org.gvsig.fmap.dal.DataServerExplorer; |
39 | 39 |
import org.gvsig.fmap.dal.DataStore; |
40 | 40 |
import org.gvsig.fmap.dal.DataStoreNotification; |
41 |
import org.gvsig.fmap.dal.DataTransaction; |
|
41 | 42 |
import org.gvsig.fmap.dal.DataTypes; |
42 | 43 |
import org.gvsig.fmap.dal.exception.CloseException; |
43 | 44 |
import org.gvsig.fmap.dal.exception.DataException; |
... | ... | |
448 | 449 |
exParams.setCatalog(params.getCatalog()); |
449 | 450 |
exParams.setSchema(params.getSchema()); |
450 | 451 |
exParams.setJDBCDriverClassName(params.getJDBCDriverClassName()); |
452 |
|
|
453 |
DataServerExplorer explorer = manager.openServerExplorer(exParams.getExplorerName(), exParams); |
|
454 |
DataTransaction.add(this.helper.getTransaction(), explorer, false); |
|
451 | 455 |
|
452 |
return manager.openServerExplorer(exParams.getExplorerName(), exParams);
|
|
456 |
return explorer;
|
|
453 | 457 |
} catch (Exception e) { |
454 | 458 |
throw new ReadException(this.getProviderName(), e); |
455 | 459 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/SRSSolverBase.java | ||
---|---|---|
110 | 110 |
try { |
111 | 111 |
String[] s = applicationAbbrev.split(":"); |
112 | 112 |
sql = "select srid, auth_name, auth_srid from spatial_ref_sys where upper(auth_name) = upper('" + s[0] +"') and auth_srid = "+s[1]+" "; |
113 |
Statement st = connection.createStatement(); |
|
113 |
Statement st = connection.createStatement(sql);
|
|
114 | 114 |
ResultSet rs = JDBCUtils.executeQuery(st, sql); |
115 | 115 |
if ( rs.next() ) { |
116 | 116 |
Integer srid = rs.getInt("srid"); |
... | ... | |
126 | 126 |
protected String searchApplicationAbbrev(JDBCConnection connection, Integer databaseCode) { |
127 | 127 |
String sql = "select srid, auth_name, auth_srid from spatial_ref_sys where srid = " + databaseCode; |
128 | 128 |
try { |
129 |
Statement st = connection.createStatement(); |
|
129 |
Statement st = connection.createStatement(sql);
|
|
130 | 130 |
ResultSet rs = JDBCUtils.executeQuery(st, sql); |
131 | 131 |
if ( rs.next() ) { |
132 | 132 |
int auth_code = rs.getInt("auth_srid"); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/RetrieveValueOperation.java | ||
---|---|---|
94 | 94 |
Statement st = null; |
95 | 95 |
ResultSet rs = null; |
96 | 96 |
try { |
97 |
st = conn.createStatement(); |
|
97 |
st = conn.createStatement(sql);
|
|
98 | 98 |
rs = JDBCUtils.executeQuery(st, sql); |
99 | 99 |
if (!rs.next()) { |
100 | 100 |
return null; |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/AbstractConnectionOperation.java | ||
---|---|---|
126 | 126 |
throw new JDBCTransactionRollbackException(e1, ex); |
127 | 127 |
} |
128 | 128 |
throw new SQLRuntimeException("Can't perform operation '"+this.getClass().getSimpleName()+"'.",ex); |
129 |
} catch (RuntimeException ex) { |
|
130 |
try { |
|
131 |
this.getConnection().rollback(); |
|
132 |
} catch (Exception e1) { |
|
133 |
throw new JDBCTransactionRollbackException(e1, ex); |
|
134 |
} |
|
135 |
throw ex;//new RuntimeException("Can't perform operation '"+this.getClass().getSimpleName()+"'.",ex); |
|
129 | 136 |
} catch (Exception ex) { |
130 | 137 |
try { |
131 | 138 |
this.getConnection().rollback(); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/CountOperation.java | ||
---|---|---|
183 | 183 |
Statement st = null; |
184 | 184 |
ResultSet rs = null; |
185 | 185 |
try { |
186 |
st = conn.createStatement(); |
|
186 |
st = conn.createStatement(sql);
|
|
187 | 187 |
rs = JDBCUtils.executeQuery(st, sql); |
188 | 188 |
if (!rs.next()) { |
189 | 189 |
return 0; |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/DeletePassThroughOperation.java | ||
---|---|---|
60 | 60 |
Statement st = null; |
61 | 61 |
String sql = getSQL(table, filter); |
62 | 62 |
try { |
63 |
st = this.getConnection().createStatement(); |
|
63 |
st = this.getConnection().createStatement(sql);
|
|
64 | 64 |
JDBCUtils.executeUpdate(st, sql); |
65 | 65 |
JDBCUtils.closeQuietly(st); |
66 | 66 |
return null; |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/CalculateEnvelopeOfColumnOperation.java | ||
---|---|---|
187 | 187 |
Statement st = null; |
188 | 188 |
ResultSet rs = null; |
189 | 189 |
try { |
190 |
st = conn.createStatement(); |
|
190 |
st = conn.createStatement(sql);
|
|
191 | 191 |
try { |
192 | 192 |
LOGGER.debug("execute query SQL:" + sql); |
193 | 193 |
rs = st.executeQuery(sql); |
... | ... | |
231 | 231 |
Statement st = null; |
232 | 232 |
ResultSet rs = null; |
233 | 233 |
try { |
234 |
st = conn.createStatement(); |
|
234 |
st = conn.createStatement(sql);
|
|
235 | 235 |
try { |
236 | 236 |
LOGGER.debug("execute query SQL:" + sql); |
237 | 237 |
rs = st.executeQuery(sql); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/TableIsEmptyOperation.java | ||
---|---|---|
137 | 137 |
Statement st = null; |
138 | 138 |
ResultSet rs = null; |
139 | 139 |
try { |
140 |
st = conn.createStatement(); |
|
140 |
st = conn.createStatement(sql);
|
|
141 | 141 |
rs = JDBCUtils.executeQuery(st, sql); |
142 | 142 |
return !rs.next(); |
143 | 143 |
|
Also available in: Unified diff