Revision 45165 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 | ||
---|---|---|
96 | 96 |
private class CachedTablesValue extends CachedValue<List<JDBCStoreParameters>> { |
97 | 97 |
|
98 | 98 |
private final int mode; |
99 |
private final JDBCStoreParameters baseParams;
|
|
99 |
private final JDBCServerExplorerParameters serverParameters;
|
|
100 | 100 |
private final boolean informationTables; |
101 | 101 |
|
102 |
public CachedTablesValue(int mode, JDBCStoreParameters baseParams, boolean informationTables) {
|
|
102 |
public CachedTablesValue(int mode, JDBCServerExplorerParameters serverParameters, boolean informationTables) {
|
|
103 | 103 |
this.mode = mode; |
104 |
this.baseParams = baseParams;
|
|
104 |
this.serverParameters = serverParameters;
|
|
105 | 105 |
this.informationTables = informationTables; |
106 | 106 |
} |
107 | 107 |
|
108 |
public CachedTablesValue(int mode, JDBCStoreParameters baseParams, boolean informationTables, long expireTime) {
|
|
108 |
public CachedTablesValue(int mode, JDBCServerExplorerParameters serverParameters, boolean informationTables, long expireTime) {
|
|
109 | 109 |
this.mode = mode; |
110 | 110 |
this.setExpireTime(expireTime); |
111 |
this.baseParams = baseParams;
|
|
111 |
this.serverParameters = serverParameters;
|
|
112 | 112 |
this.informationTables = informationTables; |
113 | 113 |
} |
114 | 114 |
|
... | ... | |
117 | 117 |
List<JDBCStoreParameters> tables = null; |
118 | 118 |
try { |
119 | 119 |
ListTablesOperation listTables = helper.getOperations().createListTables( |
120 |
this.mode, baseParams, informationTables
|
|
120 |
this.mode, serverParameters, informationTables
|
|
121 | 121 |
); |
122 | 122 |
tables = (List<JDBCStoreParameters>) listTables.perform(); |
123 | 123 |
} catch(Exception ex) { |
... | ... | |
187 | 187 |
this.getParameters().getShowInformationDBTables() |
188 | 188 |
); |
189 | 189 |
|
190 |
JDBCStoreParameters baseParams = this.getOpenParameters();
|
|
190 |
JDBCServerExplorerParameters serverParams = this.getParameters();
|
|
191 | 191 |
|
192 |
String key = buildKeyForCachedTables(mode, baseParams, informationTables);
|
|
192 |
String key = buildKeyForCachedTables(mode, serverParams, informationTables);
|
|
193 | 193 |
CachedValue<List<JDBCStoreParameters>> tablesValue = CACHED_TABLES.get(key); |
194 | 194 |
List<JDBCStoreParameters> tables = null; |
195 | 195 |
if(tablesValue != null){ |
... | ... | |
198 | 198 |
if( tables != null ) { |
199 | 199 |
return tables; |
200 | 200 |
} |
201 |
tablesValue = new CachedTablesValue(mode, baseParams, informationTables, 60000); //60"
|
|
201 |
tablesValue = new CachedTablesValue(mode, serverParams, informationTables, 60000); //60"
|
|
202 | 202 |
CACHED_TABLES.put(key, tablesValue); |
203 | 203 |
tables = tablesValue.get(); |
204 | 204 |
return tables; |
205 | 205 |
} |
206 | 206 |
|
207 |
public String buildKeyForCachedTables(int mode, JDBCStoreParameters params, boolean informationTables) {
|
|
208 |
JDBCStoreParameters clonedParams = params.getCopy();
|
|
207 |
public String buildKeyForCachedTables(int mode, JDBCServerExplorerParameters params, boolean informationTables) {
|
|
208 |
JDBCServerExplorerParameters clonedParams = (JDBCServerExplorerParameters) params.getCopy();
|
|
209 | 209 |
clonedParams.setSchema(null); //ListTableOperation no usa el schema |
210 | 210 |
|
211 | 211 |
StringBuilder builder = new StringBuilder(); |
... | ... | |
216 | 216 |
return key; |
217 | 217 |
} |
218 | 218 |
|
219 |
|
|
220 | 219 |
@Override |
221 | 220 |
public void remove(DataStoreParameters theParams) throws RemoveException { |
222 |
|
|
223 | 221 |
JDBCStoreParameters params = (JDBCStoreParameters) theParams; |
224 | 222 |
DropTableOperation removeTable = this.getOperations().createDropTable( |
225 | 223 |
this.getOperations().createTableReference(params) |
226 | 224 |
); |
227 | 225 |
if((Boolean)removeTable.perform()) { |
228 |
boolean informationTables = BooleanUtils.isTrue( |
|
229 |
this.getParameters().getShowInformationDBTables() |
|
230 |
); |
|
231 |
CACHED_TABLES.remove(buildKeyForCachedTables(MODE_ALL, params, informationTables)); |
|
232 |
CACHED_TABLES.remove(buildKeyForCachedTables(MODE_FEATURE, params, informationTables)); |
|
233 |
CACHED_TABLES.remove(buildKeyForCachedTables(MODE_GEOMETRY, params, informationTables)); |
|
226 |
this.dropCachedTables(); |
|
234 | 227 |
} |
235 | 228 |
} |
236 | 229 |
|
237 | 230 |
@Override |
238 | 231 |
public JDBCStoreParameters getOpenParameters() throws DataException { |
239 |
JDBCServerExplorerParameters parameters = getParameters(); |
|
240 |
JDBCStoreParameters params = this.helper.createOpenStoreParameters(); |
|
241 |
params.setHost(parameters.getHost()); |
|
242 |
params.setPort(parameters.getPort()); |
|
243 |
params.setDBName(parameters.getDBName()); |
|
244 |
params.setUser(parameters.getUser()); |
|
245 |
params.setPassword(parameters.getPassword()); |
|
246 |
params.setCatalog(parameters.getCatalog()); |
|
247 |
params.setSchema(parameters.getSchema()); |
|
248 |
params.setJDBCDriverClassName(parameters.getJDBCDriverClassName()); |
|
249 |
params.setUrl(parameters.getUrl()); |
|
250 |
if( parameters instanceof FilesystemStoreParameters ) { |
|
251 |
File f = ((FilesystemStoreParameters) parameters).getFile(); |
|
252 |
((FilesystemStoreParameters) params).setFile(f); |
|
253 |
} |
|
232 |
JDBCStoreParameters params = this.helper.createOpenStoreParameters(this.getParameters()); |
|
254 | 233 |
return params; |
255 | 234 |
} |
256 | 235 |
|
... | ... | |
448 | 427 |
ResourcesStorage resources = this.getResourcesStorage(theParams); |
449 | 428 |
dataManager.writeDALResource(resources, ((NewFeatureStoreParameters) theParams).getDefaultFeatureType()); |
450 | 429 |
} |
430 |
this.dropCachedTables(); |
|
451 | 431 |
return true; |
452 | 432 |
} |
433 |
|
|
434 |
private void dropCachedTables() { |
|
435 |
boolean informationTables = BooleanUtils.isTrue( |
|
436 |
this.getParameters().getShowInformationDBTables() |
|
437 |
); |
|
438 |
CACHED_TABLES.remove(buildKeyForCachedTables(MODE_ALL, this.getParameters(), informationTables)); |
|
439 |
CACHED_TABLES.remove(buildKeyForCachedTables(MODE_FEATURE, this.getParameters(), informationTables)); |
|
440 |
CACHED_TABLES.remove(buildKeyForCachedTables(MODE_GEOMETRY, this.getParameters(), informationTables)); |
|
441 |
} |
|
453 | 442 |
|
454 | 443 |
@Override |
455 | 444 |
public List getDataStoreProviderNames() { |
Also available in: Unified diff