Revision 44328 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/JDBCServerExplorerBase.java
JDBCServerExplorerBase.java | ||
---|---|---|
33 | 33 |
import org.apache.commons.lang3.tuple.ImmutablePair; |
34 | 34 |
import org.apache.commons.lang3.tuple.Pair; |
35 | 35 |
import org.gvsig.fmap.dal.DALLocator; |
36 |
import org.gvsig.fmap.dal.DataManager; |
|
36 | 37 |
import org.gvsig.fmap.dal.DataStore; |
37 | 38 |
import org.gvsig.fmap.dal.DataStoreParameters; |
38 | 39 |
import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.TABLE_RESOURCES_NAME; |
... | ... | |
46 | 47 |
import org.gvsig.fmap.dal.feature.FeatureType; |
47 | 48 |
import org.gvsig.fmap.dal.SQLBuilder; |
48 | 49 |
import org.gvsig.fmap.dal.SQLBuilder.Privilege; |
50 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
|
49 | 51 |
import org.gvsig.fmap.dal.resource.spi.ResourceProvider; |
50 | 52 |
import org.gvsig.fmap.dal.serverexplorer.db.spi.AbstractDBServerExplorer; |
51 | 53 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
... | ... | |
357 | 359 |
userAndPrivileges, |
358 | 360 |
additionalSQLs |
359 | 361 |
); |
360 |
return (boolean) createTable.perform(); |
|
362 |
boolean isOk = (boolean) createTable.perform(); |
|
363 |
if( !isOk ) { |
|
364 |
return false; |
|
365 |
} |
|
366 |
|
|
367 |
if( theParams instanceof NewFeatureStoreParameters ) { |
|
368 |
DataManager dataManager = DALLocator.getDataManager(); |
|
369 |
ResourcesStorage resources = this.getResourcesStorage(theParams); |
|
370 |
dataManager.writeDALResource(resources, ((NewFeatureStoreParameters) theParams).getDefaultFeatureType()); |
|
371 |
} |
|
372 |
return true; |
|
361 | 373 |
} |
362 | 374 |
|
363 | 375 |
@Override |
... | ... | |
393 | 405 |
return this.getHelper().createSQLBuilder(); |
394 | 406 |
} |
395 | 407 |
|
396 |
@Override |
|
397 |
public ResourcesStorage getResourcesStorage(DataStore dataStore) { |
|
398 |
if( this.resourcesStorage==null ) { |
|
399 |
try { |
|
400 |
List<JDBCStoreParameters> tables = this.list(); |
|
401 |
for (JDBCStoreParameters params : tables) { |
|
402 |
String theTableName = params.getTable(); |
|
403 |
if (StringUtils.equals(theTableName, TABLE_RESOURCES_NAME)) { |
|
404 |
this.resourcesStorage = new JDBCResourcesStorage( |
|
405 |
params, |
|
406 |
dataStore.getName() |
|
407 |
); |
|
408 |
return this.resourcesStorage; |
|
409 |
} |
|
408 |
private ResourcesStorage getResourcesStorage(DataStoreParameters parameters, String storeName) { |
|
409 |
try { |
|
410 |
List<JDBCStoreParameters> tables = this.list(); |
|
411 |
for (JDBCStoreParameters params : tables) { |
|
412 |
String theTableName = params.getTable(); |
|
413 |
if (StringUtils.equals(theTableName, TABLE_RESOURCES_NAME)) { |
|
414 |
JDBCResourcesStorage theResourcesStorage = new JDBCResourcesStorage( |
|
415 |
params, |
|
416 |
storeName |
|
417 |
); |
|
418 |
return theResourcesStorage; |
|
410 | 419 |
} |
411 |
this.resourcesStorage = new EmptyResourcesStorage(); |
|
412 |
} catch (Throwable ex) { |
|
413 |
LOG.warn("Can't retrieve reources storage from table '" + TABLE_RESOURCES_NAME + "' in '"+this.getParameters().getUrl()+"'.", ex); |
|
414 | 420 |
} |
421 |
} catch (Throwable ex) { |
|
422 |
LOG.warn("Can't retrieve reources storage from table '" + TABLE_RESOURCES_NAME + "' in '"+this.getParameters().getUrl()+"'.", ex); |
|
415 | 423 |
} |
416 |
return this.resourcesStorage; |
|
424 |
EmptyResourcesStorage theResourcesStorage = new EmptyResourcesStorage(); |
|
425 |
return theResourcesStorage; |
|
417 | 426 |
} |
427 |
|
|
428 |
|
|
429 |
@Override |
|
430 |
public ResourcesStorage getResourcesStorage(DataStoreParameters parameters) { |
|
431 |
if( parameters == null ) { |
|
432 |
throw new IllegalArgumentException("null is a valid value for parameters."); |
|
433 |
} |
|
434 |
String tableName; |
|
435 |
if( parameters instanceof JDBCNewStoreParameters) { |
|
436 |
tableName = ((JDBCNewStoreParameters)parameters).getTable(); |
|
437 |
} else if( parameters instanceof JDBCStoreParameters) { |
|
438 |
tableName = ((JDBCStoreParameters)parameters).getTable(); |
|
439 |
} else { |
|
440 |
throw new IllegalArgumentException("Required a JDBCStoreParameters or JDBCNewStoreParameters parameters, received "+parameters.getClass().getName()+"."); |
|
441 |
} |
|
442 |
return this.getResourcesStorage(parameters, tableName); |
|
443 |
} |
|
444 |
|
|
445 |
@Override |
|
446 |
public ResourcesStorage getResourcesStorage(DataStore dataStore) { |
|
447 |
return this.getResourcesStorage( |
|
448 |
(JDBCStoreParameters) dataStore.getParameters(), |
|
449 |
dataStore.getName() |
|
450 |
); |
|
451 |
} |
|
418 | 452 |
} |
Also available in: Unified diff