svn-gvsig-desktop / 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 / JDBCHelperBase.java @ 44198
History | View | Annotate | Download (18.8 KB)
1 | 43020 | jjdelcerro | package org.gvsig.fmap.dal.store.jdbc2.spi; |
---|---|---|---|
2 | |||
3 | import org.gvsig.fmap.dal.store.jdbc2.impl.ResulSetControlerBase; |
||
4 | import org.gvsig.fmap.dal.store.jdbc2.spi.operations.OperationsFactoryBase; |
||
5 | import java.sql.Connection; |
||
6 | import java.sql.ResultSet; |
||
7 | import org.apache.commons.lang3.StringUtils; |
||
8 | 44191 | jjdelcerro | import org.apache.commons.lang3.mutable.MutableBoolean; |
9 | import org.gvsig.expressionevaluator.Code; |
||
10 | 44042 | jjdelcerro | import org.gvsig.expressionevaluator.ExpressionBuilder.GeometrySupportType; |
11 | import static org.gvsig.expressionevaluator.ExpressionBuilder.GeometrySupportType.EWKB; |
||
12 | import static org.gvsig.expressionevaluator.ExpressionBuilder.GeometrySupportType.NATIVE; |
||
13 | import static org.gvsig.expressionevaluator.ExpressionBuilder.GeometrySupportType.WKB; |
||
14 | import static org.gvsig.expressionevaluator.ExpressionBuilder.GeometrySupportType.WKT; |
||
15 | 44191 | jjdelcerro | import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator; |
16 | import org.gvsig.expressionevaluator.ExpressionEvaluatorManager; |
||
17 | import org.gvsig.expressionevaluator.Function; |
||
18 | 44198 | jjdelcerro | import org.gvsig.expressionevaluator.SymbolTable; |
19 | 43020 | jjdelcerro | import org.gvsig.fmap.dal.DataTypes; |
20 | import org.gvsig.fmap.dal.exception.DataException; |
||
21 | import org.gvsig.fmap.dal.exception.InitializeException; |
||
22 | import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
||
23 | 44191 | jjdelcerro | import org.gvsig.fmap.dal.feature.FeatureQueryOrder; |
24 | 44198 | jjdelcerro | import org.gvsig.fmap.dal.feature.FeatureStore; |
25 | 43020 | jjdelcerro | import org.gvsig.fmap.dal.feature.FeatureType; |
26 | |||
27 | import org.gvsig.fmap.dal.feature.spi.FeatureProvider; |
||
28 | import org.gvsig.fmap.dal.resource.exception.AccessResourceException; |
||
29 | import org.gvsig.fmap.dal.resource.spi.ResourceConsumer; |
||
30 | import org.gvsig.fmap.dal.resource.spi.ResourceProvider; |
||
31 | import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices; |
||
32 | import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
||
33 | import org.gvsig.fmap.dal.store.db.DBHelper; |
||
34 | import org.gvsig.fmap.dal.store.jdbc.JDBCConnectionParameters; |
||
35 | import org.gvsig.fmap.dal.store.jdbc.JDBCLibrary; |
||
36 | import org.gvsig.fmap.dal.store.jdbc.JDBCNewStoreParameters; |
||
37 | import org.gvsig.fmap.dal.store.jdbc.JDBCResource; |
||
38 | import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
||
39 | import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
||
40 | import org.gvsig.fmap.dal.store.jdbc.exception.JDBCCantFetchValueException; |
||
41 | import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
||
42 | import org.gvsig.fmap.dal.store.jdbc2.JDBCServerExplorer; |
||
43 | import org.gvsig.fmap.dal.store.jdbc2.JDBCStoreProvider; |
||
44 | import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils; |
||
45 | import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
||
46 | import org.gvsig.fmap.dal.store.jdbc2.ResulSetControler; |
||
47 | import org.gvsig.fmap.dal.store.jdbc2.ResulSetControler.ResultSetEntry; |
||
48 | import org.gvsig.fmap.geom.Geometry; |
||
49 | import org.gvsig.fmap.geom.GeometryLocator; |
||
50 | import org.gvsig.fmap.geom.GeometryManager; |
||
51 | import org.gvsig.tools.dispose.impl.AbstractDisposable; |
||
52 | 44191 | jjdelcerro | import org.gvsig.tools.evaluator.Evaluator; |
53 | 43020 | jjdelcerro | import org.gvsig.tools.exception.BaseException; |
54 | 43377 | jjdelcerro | import org.gvsig.tools.exception.NotYetImplemented; |
55 | 44191 | jjdelcerro | import org.gvsig.tools.visitor.VisitCanceledException; |
56 | import org.gvsig.tools.visitor.Visitor; |
||
57 | 43020 | jjdelcerro | import org.slf4j.Logger; |
58 | import org.slf4j.LoggerFactory; |
||
59 | |||
60 | 44191 | jjdelcerro | @SuppressWarnings("UseSpecificCatch") |
61 | 43020 | jjdelcerro | public class JDBCHelperBase extends AbstractDisposable implements ResourceConsumer, JDBCHelper { |
62 | |||
63 | private static final boolean ALLOW_AUTOMATIC_VALUES = true; |
||
64 | private static final String QUOTE_FOR_USE_IN_IDENTIFIERS = "\""; |
||
65 | private static final String QUOTE_FOR_USE_IN_STRINGS = "'"; |
||
66 | |||
67 | 44191 | jjdelcerro | private static final Logger LOGGER = LoggerFactory.getLogger(JDBCHelperBase.class); |
68 | 43020 | jjdelcerro | |
69 | private ResulSetControler resulSetControler = null; |
||
70 | |||
71 | // Quien ha creado este helper.
|
||
72 | // Se le reenviaran las notificaciones del recurso asociado al helper.
|
||
73 | private ResourceConsumer helperClient = null; |
||
74 | |||
75 | private GeometryManager geometryManager = null; |
||
76 | |||
77 | 43035 | jjdelcerro | private JDBCConnectionParameters connectionParameters;
|
78 | 43020 | jjdelcerro | |
79 | private JDBCStoreProvider store;
|
||
80 | |||
81 | protected OperationsFactory operationsFactory = null; |
||
82 | |||
83 | 43606 | jjdelcerro | protected SRSSolver srssolver;
|
84 | 43355 | jjdelcerro | |
85 | 43020 | jjdelcerro | public JDBCHelperBase(JDBCConnectionParameters connectionParameters) {
|
86 | this.connectionParameters = connectionParameters;
|
||
87 | 43355 | jjdelcerro | |
88 | // If a particular treatment is required to convert SRS to the
|
||
89 | // BBDD format, overwrite JDBCSRSsBase and use it instead of JDBCSRSsDumb.
|
||
90 | 43606 | jjdelcerro | this.srssolver = new SRSSolverDumb(this); |
91 | 43020 | jjdelcerro | } |
92 | |||
93 | protected void initialize( |
||
94 | ResourceConsumer helperClient, |
||
95 | JDBCConnectionParameters connectionParameters, |
||
96 | JDBCStoreProvider store |
||
97 | ) { |
||
98 | 43093 | jjdelcerro | this.store = store;
|
99 | 43020 | jjdelcerro | this.helperClient = helperClient;
|
100 | this.connectionParameters = connectionParameters;
|
||
101 | initializeResource(connectionParameters); |
||
102 | } |
||
103 | |||
104 | protected String getResourceType() { |
||
105 | return JDBCResource.NAME;
|
||
106 | } |
||
107 | |||
108 | @Override
|
||
109 | public String getProviderName() { |
||
110 | return JDBCLibrary.NAME;
|
||
111 | } |
||
112 | |||
113 | @Override
|
||
114 | public GeometrySupportType getGeometrySupportType() {
|
||
115 | // El proveedor generico de JDBC guadara las geoemtrias como WKT
|
||
116 | return GeometrySupportType.WKT;
|
||
117 | } |
||
118 | |||
119 | @Override
|
||
120 | public boolean hasSpatialFunctions() { |
||
121 | // Por defecto el proveedor generico de JDBC asume que la BBDD no
|
||
122 | // tiene soporte para funciones espaciales.
|
||
123 | return false; |
||
124 | } |
||
125 | |||
126 | @Override
|
||
127 | 44191 | jjdelcerro | public boolean allowNestedOperations() { |
128 | return false; |
||
129 | } |
||
130 | |||
131 | @Override
|
||
132 | 43020 | jjdelcerro | public boolean canWriteGeometry(int geometryType, int geometrySubtype) { |
133 | // Como va a guardar las geometrias en WKT, puede escribirlas todas.
|
||
134 | return true; |
||
135 | } |
||
136 | |||
137 | @Override
|
||
138 | public JDBCSQLBuilderBase createSQLBuilder() {
|
||
139 | 43687 | jjdelcerro | return new JDBCSQLBuilderBase(this); |
140 | 43020 | jjdelcerro | } |
141 | |||
142 | @Override
|
||
143 | public String getQuoteForIdentifiers() { |
||
144 | return QUOTE_FOR_USE_IN_IDENTIFIERS;
|
||
145 | } |
||
146 | |||
147 | @Override
|
||
148 | public boolean allowAutomaticValues() { |
||
149 | return ALLOW_AUTOMATIC_VALUES;
|
||
150 | } |
||
151 | |||
152 | @Override
|
||
153 | public boolean supportOffsetInSelect() { |
||
154 | // Asumimos que la BBDD soporta OFFSET
|
||
155 | return true; |
||
156 | } |
||
157 | |||
158 | @Override
|
||
159 | public String getQuoteForStrings() { |
||
160 | return QUOTE_FOR_USE_IN_STRINGS;
|
||
161 | } |
||
162 | 44191 | jjdelcerro | |
163 | @Override
|
||
164 | 44198 | jjdelcerro | public boolean supportFilter(final FeatureType type, Evaluator filter) { |
165 | 44191 | jjdelcerro | // No podemos filtrar cuando:
|
166 | // - Hay una subquery especificada en los parametros
|
||
167 | // - Si hay un filtro y el getSQL devuelbe null.
|
||
168 | // - Si se esta usando alguna funcion no-sql en el getSQL
|
||
169 | // - Si se estan usando funciones OGC y no soportamos funciones espaciales
|
||
170 | 44198 | jjdelcerro | // - Si se esta usando algun campo calculado en la expresion de filtro.
|
171 | 44191 | jjdelcerro | //
|
172 | // Un proveedor especifico podria sobreescribir el metodo,
|
||
173 | // para hilar mas fino al comprobar si soporta el filtro o no.
|
||
174 | //
|
||
175 | |||
176 | if (this.useSubquery()) { |
||
177 | // Se esta usando una subquery en los parametros de acceso a la
|
||
178 | // BBDD, asi que no podemos filtrar.
|
||
179 | return false; |
||
180 | } |
||
181 | if (filter == null) { |
||
182 | // No hay que filtrar nada, asi que se p?ede.
|
||
183 | return true; |
||
184 | } |
||
185 | String sql = filter.getSQL();
|
||
186 | if (StringUtils.isEmpty(sql)) {
|
||
187 | // Hay un filtro, pero la SQL es null, con lo que no podemos
|
||
188 | // filtrar por el.
|
||
189 | return false; |
||
190 | } |
||
191 | |||
192 | // Ahora vamos a comprobar que las funciones que se usan son
|
||
193 | // compatibles sql, y que no se usan funciones OGC si el
|
||
194 | // proveedor dice que no soporta funciones espaciales.
|
||
195 | 44198 | jjdelcerro | // Tambien comprobaremos que el filtro no usa ningun campo calculado.
|
196 | 44191 | jjdelcerro | final MutableBoolean isCompatible = new MutableBoolean(true); |
197 | final boolean supportSpatialFunctions = this.hasSpatialFunctions(); |
||
198 | ExpressionEvaluatorManager manager = ExpressionEvaluatorLocator.getManager(); |
||
199 | Code code = manager.compile(sql); |
||
200 | 44198 | jjdelcerro | SymbolTable symbolTable = manager.createSymbolTable(); |
201 | code.link(symbolTable); |
||
202 | 44191 | jjdelcerro | try {
|
203 | code.accept(new Visitor() {
|
||
204 | @Override
|
||
205 | public void visit(Object code_obj) throws VisitCanceledException, BaseException { |
||
206 | Code code = (Code) code_obj; |
||
207 | 44198 | jjdelcerro | switch(code.code()) {
|
208 | case Code.CALLER:
|
||
209 | Code.Caller caller = (Code.Caller) code; |
||
210 | Function function = caller.function(); |
||
211 | if( function==null ) { |
||
212 | 44191 | jjdelcerro | isCompatible.setValue(false);
|
213 | throw new VisitCanceledException(); |
||
214 | } |
||
215 | 44198 | jjdelcerro | if( !function.isSQLCompatible() ) {
|
216 | isCompatible.setValue(false);
|
||
217 | throw new VisitCanceledException(); |
||
218 | } |
||
219 | if( !supportSpatialFunctions ) {
|
||
220 | if( StringUtils.equalsIgnoreCase(function.group(),Function.GROUP_OGC) ) {
|
||
221 | isCompatible.setValue(false);
|
||
222 | throw new VisitCanceledException(); |
||
223 | } |
||
224 | } |
||
225 | break;
|
||
226 | |||
227 | case Code.IDENTIFIER:
|
||
228 | Code.Identifier identifier = (Code.Identifier) code; |
||
229 | if( type!=null ) { |
||
230 | FeatureAttributeDescriptor attrdesc = type.getAttributeDescriptor(identifier.name()); |
||
231 | if( attrdesc!=null ) { |
||
232 | if( attrdesc.isComputed() ) {
|
||
233 | isCompatible.setValue(false);
|
||
234 | throw new VisitCanceledException(); |
||
235 | } |
||
236 | } |
||
237 | } |
||
238 | break;
|
||
239 | 44191 | jjdelcerro | } |
240 | } |
||
241 | }); |
||
242 | |||
243 | } catch (VisitCanceledException ex) {
|
||
244 | // Do nothing
|
||
245 | } catch (Exception ex) { |
||
246 | LOGGER.warn("Can't calculate if is SQL compatible.", ex);
|
||
247 | } |
||
248 | |||
249 | return isCompatible.booleanValue();
|
||
250 | } |
||
251 | 43020 | jjdelcerro | |
252 | @Override
|
||
253 | 44198 | jjdelcerro | public boolean supportOrder(FeatureType type, FeatureQueryOrder order) { |
254 | 44191 | jjdelcerro | if (this.useSubquery()) { |
255 | return false; |
||
256 | } |
||
257 | if (order == null) { |
||
258 | return true; |
||
259 | } |
||
260 | for( FeatureQueryOrder.FeatureQueryOrderMember member : order.members() ) {
|
||
261 | if (member.hasEvaluator()) {
|
||
262 | 44198 | jjdelcerro | if( !this.supportFilter(type, member.getEvaluator()) ) { |
263 | 44191 | jjdelcerro | return false; |
264 | } |
||
265 | } |
||
266 | } |
||
267 | return true; |
||
268 | } |
||
269 | |||
270 | @Override
|
||
271 | 43020 | jjdelcerro | public OperationsFactory getOperations() {
|
272 | if (this.operationsFactory== null) { |
||
273 | this.operationsFactory = new OperationsFactoryBase(this); |
||
274 | } |
||
275 | return operationsFactory;
|
||
276 | } |
||
277 | |||
278 | protected void initializeResource(JDBCConnectionParameters params) { |
||
279 | // Object[] resourceParams = new Object[]{
|
||
280 | // params.getUrl(),
|
||
281 | // params.getHost(),
|
||
282 | // params.getPort(),
|
||
283 | // params.getDBName(),
|
||
284 | // params.getUser(),
|
||
285 | // params.getPassword(),
|
||
286 | // params.getJDBCDriverClassName()
|
||
287 | // };
|
||
288 | //
|
||
289 | // try {
|
||
290 | // ResourceManagerProviderServices manager
|
||
291 | // = (ResourceManagerProviderServices) DALLocator.getResourceManager();
|
||
292 | // JDBCResource resource = (JDBCResource) manager.createAddResource(
|
||
293 | // this.getResourceType(),
|
||
294 | // resourceParams
|
||
295 | // );
|
||
296 | // this.resource = resource;
|
||
297 | // this.resource.addConsumer(this);
|
||
298 | // } catch (InitializeException ex) {
|
||
299 | // logger.debug("Can't initialize resource (" + ArrayUtils.toString(resourceParams) + ").", ex);
|
||
300 | // throw new RuntimeException("Can't initialize resource (" + ArrayUtils.toString(resourceParams) + ").", ex);
|
||
301 | // }
|
||
302 | |||
303 | } |
||
304 | |||
305 | @Override
|
||
306 | public String getSourceId() { |
||
307 | return this.store.getSourceId(); |
||
308 | } |
||
309 | |||
310 | @Override
|
||
311 | public JDBCResource getResource() {
|
||
312 | return null; |
||
313 | // return this.resource;
|
||
314 | } |
||
315 | |||
316 | @Override
|
||
317 | public Connection getConnection() throws AccessResourceException { |
||
318 | 43377 | jjdelcerro | throw new NotYetImplemented(); |
319 | 43020 | jjdelcerro | } |
320 | |||
321 | @Override
|
||
322 | 43377 | jjdelcerro | public Connection getConnectionWritable() throws AccessResourceException { |
323 | return this.getConnection(); |
||
324 | } |
||
325 | |||
326 | @Override
|
||
327 | 43035 | jjdelcerro | public String getConnectionURL() { |
328 | return null; |
||
329 | } |
||
330 | |||
331 | 43358 | jjdelcerro | @Override
|
332 | 43035 | jjdelcerro | public JDBCConnectionParameters getConnectionParameters() {
|
333 | return connectionParameters;
|
||
334 | } |
||
335 | |||
336 | @Override
|
||
337 | 43020 | jjdelcerro | public void closeConnection(Connection connection) { |
338 | 43377 | jjdelcerro | if( connection != null ) { |
339 | 44191 | jjdelcerro | LOGGER.debug("Clossing connection "+connection.hashCode());
|
340 | 43377 | jjdelcerro | try {
|
341 | connection.close(); |
||
342 | } catch(Exception ex) { |
||
343 | 44191 | jjdelcerro | LOGGER.warn("Can't close connection.", ex);
|
344 | 43377 | jjdelcerro | } |
345 | 43020 | jjdelcerro | } |
346 | 43377 | jjdelcerro | } |
347 | 44191 | jjdelcerro | |
348 | 44198 | jjdelcerro | @Override
|
349 | 44191 | jjdelcerro | public void closeConnectionQuietly(Connection connection) { |
350 | if( connection != null ) { |
||
351 | LOGGER.debug("Clossing connection quietly "+connection.hashCode());
|
||
352 | try {
|
||
353 | connection.close(); |
||
354 | } catch(Exception ex) { |
||
355 | LOGGER.warn("Can't close connection.", ex);
|
||
356 | } |
||
357 | } |
||
358 | } |
||
359 | 43020 | jjdelcerro | |
360 | @Override
|
||
361 | protected void doDispose() throws BaseException { |
||
362 | JDBCUtils.closeQuietly(this);
|
||
363 | } |
||
364 | |||
365 | @Override
|
||
366 | public void close() throws Exception { |
||
367 | // this.resource.removeConsumer(this);
|
||
368 | JDBCUtils.closeQuietly(this.resulSetControler);
|
||
369 | // this.resource = null;
|
||
370 | this.resulSetControler = null; |
||
371 | } |
||
372 | |||
373 | @Override
|
||
374 | public boolean closeResourceRequested(ResourceProvider resource) { |
||
375 | return this.helperClient.closeResourceRequested(resource); |
||
376 | } |
||
377 | |||
378 | @Override
|
||
379 | public void resourceChanged(ResourceProvider resource) { |
||
380 | this.helperClient.resourceChanged(resource);
|
||
381 | } |
||
382 | |||
383 | @Override
|
||
384 | public GeometryManager getGeometryManager() {
|
||
385 | if (this.geometryManager == null) { |
||
386 | this.geometryManager = GeometryLocator.getGeometryManager();
|
||
387 | } |
||
388 | return this.geometryManager; |
||
389 | } |
||
390 | |||
391 | @Override
|
||
392 | public ResulSetControler getResulSetControler() {
|
||
393 | if (this.resulSetControler == null) { |
||
394 | this.resulSetControler = new ResulSetControlerBase(this); |
||
395 | } |
||
396 | return this.resulSetControler; |
||
397 | } |
||
398 | |||
399 | @Override
|
||
400 | public void fetchFeature(FeatureProvider feature, ResultSetEntry rs) throws DataException { |
||
401 | 43358 | jjdelcerro | fetchFeature(feature, rs.get(), rs.getColumns()); |
402 | 43020 | jjdelcerro | } |
403 | |||
404 | @Override
|
||
405 | 43358 | jjdelcerro | public void fetchFeature(FeatureProvider feature, ResultSet rs, FeatureAttributeDescriptor[] columns) throws DataException { |
406 | 43420 | jjdelcerro | Object value;
|
407 | FeatureAttributeDescriptor column; |
||
408 | 43020 | jjdelcerro | try {
|
409 | 43358 | jjdelcerro | for (int index = 0; index < columns.length; index++) { |
410 | 43420 | jjdelcerro | column = columns[index]; |
411 | 43358 | jjdelcerro | switch (column.getType()) {
|
412 | 43020 | jjdelcerro | case DataTypes.GEOMETRY:
|
413 | value = this.getGeometryFromColumn(rs, index + 1); |
||
414 | break;
|
||
415 | default:
|
||
416 | value = rs.getObject(index + 1);
|
||
417 | } |
||
418 | 43358 | jjdelcerro | feature.set(column.getIndex(), value); |
419 | 43020 | jjdelcerro | } |
420 | } catch (Exception ex) { |
||
421 | throw new JDBCCantFetchValueException(ex); |
||
422 | } |
||
423 | } |
||
424 | |||
425 | @Override
|
||
426 | public Geometry getGeometryFromColumn(ResultSetEntry rs, int index) throws DataException { |
||
427 | return getGeometryFromColumn(rs.get(), index);
|
||
428 | } |
||
429 | |||
430 | @Override
|
||
431 | public Geometry getGeometryFromColumn(ResultSet rs, int index) throws DataException { |
||
432 | try {
|
||
433 | Object value;
|
||
434 | switch (this.getGeometrySupportType()) { |
||
435 | 43358 | jjdelcerro | case NATIVE:
|
436 | 43020 | jjdelcerro | case WKB:
|
437 | value = rs.getBytes(index); |
||
438 | if (value == null) { |
||
439 | return null; |
||
440 | } |
||
441 | return this.getGeometryManager().createFrom((byte[]) value); |
||
442 | |||
443 | case EWKB:
|
||
444 | value = rs.getBytes(index); |
||
445 | if (value == null) { |
||
446 | return null; |
||
447 | } |
||
448 | return this.getGeometryManager().createFrom((byte[]) value); |
||
449 | case WKT:
|
||
450 | default:
|
||
451 | value = rs.getString(index); |
||
452 | if (value == null) { |
||
453 | return null; |
||
454 | } |
||
455 | return this.getGeometryManager().createFrom((String) value); |
||
456 | |||
457 | } |
||
458 | } catch (Exception ex) { |
||
459 | throw new JDBCCantFetchValueException(ex); |
||
460 | } |
||
461 | } |
||
462 | |||
463 | @Override
|
||
464 | public FeatureProvider createFeature(FeatureType featureType) throws DataException { |
||
465 | return this.store.getStoreServices().createDefaultFeatureProvider(featureType); |
||
466 | } |
||
467 | |||
468 | @Override
|
||
469 | public boolean useSubquery() { |
||
470 | if( this.store == null ) { |
||
471 | return false; |
||
472 | } |
||
473 | return !StringUtils.isEmpty(this.store.getParameters().getSQL()); |
||
474 | } |
||
475 | 43355 | jjdelcerro | |
476 | @Override
|
||
477 | 43606 | jjdelcerro | public SRSSolver getSRSSolver() {
|
478 | return this.srssolver; |
||
479 | } |
||
480 | |||
481 | @Override
|
||
482 | 43020 | jjdelcerro | public JDBCStoreProvider createProvider(
|
483 | JDBCStoreParameters parameters, |
||
484 | DataStoreProviderServices providerServices |
||
485 | ) throws InitializeException {
|
||
486 | |||
487 | 44191 | jjdelcerro | JDBCStoreProviderBase theStore = new JDBCStoreProviderBase(
|
488 | 43020 | jjdelcerro | parameters, |
489 | providerServices, |
||
490 | DBHelper.newMetadataContainer(JDBCLibrary.NAME), |
||
491 | this
|
||
492 | ); |
||
493 | 44191 | jjdelcerro | this.initialize(theStore, parameters, theStore);
|
494 | return theStore;
|
||
495 | 43020 | jjdelcerro | } |
496 | |||
497 | @Override
|
||
498 | public JDBCServerExplorer createServerExplorer(
|
||
499 | JDBCServerExplorerParameters parameters, |
||
500 | DataServerExplorerProviderServices providerServices |
||
501 | ) throws InitializeException {
|
||
502 | |||
503 | JDBCServerExplorer explorer = new JDBCServerExplorerBase(
|
||
504 | parameters, |
||
505 | providerServices, |
||
506 | this
|
||
507 | ); |
||
508 | this.initialize(explorer, parameters, null); |
||
509 | return explorer;
|
||
510 | } |
||
511 | |||
512 | @Override
|
||
513 | public JDBCNewStoreParameters createNewStoreParameters() {
|
||
514 | return new JDBCNewStoreParameters(); |
||
515 | } |
||
516 | |||
517 | @Override
|
||
518 | public JDBCStoreParameters createOpenStoreParameters() {
|
||
519 | return new JDBCStoreParameters(); |
||
520 | } |
||
521 | |||
522 | 43358 | jjdelcerro | @Override
|
523 | 43020 | jjdelcerro | public JDBCServerExplorerParameters createServerExplorerParameters() {
|
524 | return new JDBCServerExplorerParameters(); |
||
525 | } |
||
526 | |||
527 | @Override
|
||
528 | public String getSourceId(JDBCStoreParameters parameters) { |
||
529 | return parameters.getHost() + ":" + |
||
530 | parameters.getDBName() + ":" +
|
||
531 | parameters.getSchema()+ ":" +
|
||
532 | parameters.tableID(); |
||
533 | } |
||
534 | 44198 | jjdelcerro | |
535 | @Override
|
||
536 | public boolean isThreadSafe() { |
||
537 | return true; |
||
538 | } |
||
539 | 43020 | jjdelcerro | |
540 | } |