svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.api / src / main / java / org / gvsig / fmap / dal / DataManager.java @ 44346
History | View | Annotate | Download (18.6 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify it under
|
7 |
* the terms of the GNU General Public License as published by the Free Software
|
8 |
* Foundation; either version 3 of the License, or (at your option) any later
|
9 |
* version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
13 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
14 |
* details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License along with
|
17 |
* this program; if not, write to the Free Software Foundation, Inc., 51
|
18 |
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
19 |
*
|
20 |
* For any additional information, do not hesitate to contact us at info AT
|
21 |
* gvsig.com, or visit our website www.gvsig.com.
|
22 |
*/
|
23 |
package org.gvsig.fmap.dal; |
24 |
|
25 |
import java.io.File; |
26 |
import java.util.List; |
27 |
import org.gvsig.expressionevaluator.Expression; |
28 |
import org.gvsig.expressionevaluator.ExpressionBuilder; |
29 |
|
30 |
import org.gvsig.fmap.dal.exception.DataException; |
31 |
import org.gvsig.fmap.dal.exception.InitializeException; |
32 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
33 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
34 |
import org.gvsig.fmap.dal.expressionevaluator.FeatureSymbolTable; |
35 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
36 |
import org.gvsig.fmap.dal.feature.Feature; |
37 |
import org.gvsig.fmap.dal.feature.FeatureIndex; |
38 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
39 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
40 |
import org.gvsig.fmap.dal.feature.FeatureType; |
41 |
import org.gvsig.fmap.dal.feature.paging.FeaturePagingHelper; |
42 |
import org.gvsig.fmap.dal.resource.ResourceManager; |
43 |
import org.gvsig.tools.dataTypes.DataType; |
44 |
import org.gvsig.tools.dynobject.DynObject; |
45 |
import org.gvsig.tools.dynobject.DynStruct; |
46 |
import org.gvsig.tools.dynobject.Tags; |
47 |
import org.gvsig.tools.evaluator.Evaluator; |
48 |
import org.gvsig.tools.exception.BaseException; |
49 |
import org.gvsig.tools.service.spi.Services; |
50 |
import org.gvsig.fmap.dal.expressionevaluator.FeatureAttributeEmulatorExpression; |
51 |
import org.gvsig.fmap.dal.feature.DataProfile; |
52 |
import org.gvsig.tools.resourcesstorage.ResourcesStorage; |
53 |
|
54 |
/**
|
55 |
* There are two top level management roles within DAL: data access and resource
|
56 |
* management.
|
57 |
*
|
58 |
* This class is responsible of the data access management role. It provides
|
59 |
* ways for registering and instantiating {@link DataServerExplorer}(s),
|
60 |
* {@link DataStore}(s), {@link Evaluator}(s) and {@link FeatureIndex}(es).
|
61 |
*
|
62 |
* @see ResourceManager
|
63 |
*
|
64 |
*/
|
65 |
public interface DataManager extends Services { |
66 |
|
67 |
public static final String CREATE_STORE_AUTHORIZATION = "dal-create-store"; |
68 |
public static final String READ_STORE_AUTHORIZATION = "dal-read-store"; |
69 |
public static final String WRITE_STORE_AUTHORIZATION = "dal-write-store"; |
70 |
|
71 |
public static final String DAL_SYMBOL_TABLE = "DAL.SymbolTable.Global"; |
72 |
public static final String DAL_SYMBOL_TABLE_FEATURE = "DAL.SymbolTable.Feature"; |
73 |
|
74 |
public static final String FUNCTION_FOREING_VALUE = "FOREING_VALUE"; |
75 |
|
76 |
public static final String DAL_PREFERRED_COLUMNS = "DAL.Preferred.Columns"; |
77 |
|
78 |
/**
|
79 |
*
|
80 |
* Returns the default DAL's temporary directory
|
81 |
*
|
82 |
* @return Temporary directory name
|
83 |
* @deprecated use FoldersManager of org.gvsig.tools
|
84 |
*/
|
85 |
public String getTemporaryDirectory(); |
86 |
|
87 |
/*
|
88 |
* ====================================================================
|
89 |
*
|
90 |
* Store related services
|
91 |
*/
|
92 |
/**
|
93 |
* Creates, initializes and returns an instance of DataStoreParameters given
|
94 |
* the name with which their provider is registered.
|
95 |
*
|
96 |
* @param name provider name
|
97 |
* @return the data store parameters
|
98 |
*
|
99 |
* @throws ProviderNotRegisteredException if the memory provider is not
|
100 |
* registered
|
101 |
* @throws InitializeException if there is an error initializing the
|
102 |
* parameters for the memory provider
|
103 |
*
|
104 |
*/
|
105 |
public DataStoreParameters createStoreParameters(String name) |
106 |
throws InitializeException, ProviderNotRegisteredException;
|
107 |
|
108 |
public DataStoreParameters createStoreParameters(byte[] data); |
109 |
|
110 |
/**
|
111 |
* Creates, initializes and fill an instance of DataStoreParameters from the
|
112 |
* tags of the DynStruct passed as parameter.
|
113 |
*
|
114 |
* @param struct structure from which tags were created ths parameters.
|
115 |
* @return the data store parameters
|
116 |
*
|
117 |
* @throws ProviderNotRegisteredException if the memory provider is not
|
118 |
* registered
|
119 |
* @throws InitializeException if there is an error initializing the
|
120 |
* parameters for the memory provider
|
121 |
*
|
122 |
*/
|
123 |
public DataStoreParameters createStoreParameters(DynStruct struct)
|
124 |
throws InitializeException, ProviderNotRegisteredException;
|
125 |
|
126 |
public DataStoreParameters createStoreParameters(Tags tags) throws InitializeException, ProviderNotRegisteredException; |
127 |
|
128 |
/**
|
129 |
* Creates, initializes and returns an instance of NewDataStoreParameters
|
130 |
* given the name with which their provider is registered.
|
131 |
*
|
132 |
* @param explorer
|
133 |
* @param provider
|
134 |
* @return
|
135 |
*
|
136 |
* @throws InitializeException
|
137 |
* @throws ProviderNotRegisteredException
|
138 |
*/
|
139 |
public NewDataStoreParameters createNewStoreParameters(String explorer, String provider) |
140 |
throws InitializeException, ProviderNotRegisteredException;
|
141 |
|
142 |
/**
|
143 |
*
|
144 |
* Creates, initializes and returns an instance of DataStore given the
|
145 |
* DataStoreParameters.
|
146 |
*
|
147 |
* @param provider
|
148 |
* @param parameters parameters used to instantiate and initialize the
|
149 |
* DataStore
|
150 |
* @return
|
151 |
*
|
152 |
* @throws ProviderNotRegisteredException if the memory provider is not
|
153 |
* registered
|
154 |
* @throws InitializeException if there is an error initializing the
|
155 |
* parameters for the memory provider
|
156 |
* @throws ValidateDataParametersException if the parameters to open the
|
157 |
* memory based store are not valid
|
158 |
*/
|
159 |
public DataStore openStore(String provider, DynObject parameters) |
160 |
throws InitializeException, ProviderNotRegisteredException,
|
161 |
ValidateDataParametersException; |
162 |
|
163 |
public DataStore openStore(String provider, DataStoreParameters parameters) |
164 |
throws InitializeException, ProviderNotRegisteredException,
|
165 |
ValidateDataParametersException; |
166 |
|
167 |
public DataStore openStore(
|
168 |
String providerName,
|
169 |
Object... arguments)
|
170 |
throws
|
171 |
InitializeException, |
172 |
ProviderNotRegisteredException, |
173 |
ValidateDataParametersException; |
174 |
|
175 |
public DataStore openStore(DynStruct struct)
|
176 |
throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException;
|
177 |
|
178 |
/**
|
179 |
* Create a new physical store
|
180 |
*
|
181 |
* @param explorer
|
182 |
* @param provider
|
183 |
* @param parameters
|
184 |
* @param overwrite
|
185 |
*
|
186 |
* @throws InitializeException
|
187 |
* @throws ProviderNotRegisteredException
|
188 |
* @throws ValidateDataParametersException
|
189 |
*/
|
190 |
public void newStore(String explorer, String provider, NewDataStoreParameters parameters, boolean overwrite) |
191 |
throws InitializeException, ProviderNotRegisteredException,
|
192 |
ValidateDataParametersException; |
193 |
|
194 |
/**
|
195 |
* Returns a list of Strings containing the names of all available DataStore
|
196 |
* providers.
|
197 |
*
|
198 |
* @return list of String containing available DataStore provider names
|
199 |
*/
|
200 |
public List getStoreProviders(); |
201 |
|
202 |
/**
|
203 |
* Returns a list of Strings containing the names of all available DataStore
|
204 |
* providers for an explorer.
|
205 |
*
|
206 |
* @param name
|
207 |
* @return
|
208 |
*/
|
209 |
public List<String> getStoreProviders(String name); |
210 |
|
211 |
/*
|
212 |
* ====================================================================
|
213 |
*
|
214 |
* Explorer related services
|
215 |
*/
|
216 |
/**
|
217 |
* Returns an instance of {@link DataServerExplorerParameters} corresponding
|
218 |
* to the given name.
|
219 |
*
|
220 |
* @param name name of a registered server explorer provider
|
221 |
* @return
|
222 |
*
|
223 |
* @throws InitializeException if parameter initialization causes an error.
|
224 |
*
|
225 |
* @throws ProviderNotRegisteredException if could not find a provider by
|
226 |
* the given name.
|
227 |
*
|
228 |
*
|
229 |
*/
|
230 |
public DataServerExplorerParameters createServerExplorerParameters(
|
231 |
String name)
|
232 |
throws InitializeException, ProviderNotRegisteredException;
|
233 |
|
234 |
/**
|
235 |
* Returns an instance of {@link DataServerExplorer} given its parameters.
|
236 |
*
|
237 |
* @param name
|
238 |
* @param parameters parameters used to instantiate and initialize the
|
239 |
* {@link DataServerExplorer}.
|
240 |
*
|
241 |
* @return an instance of {@link DataServerExplorer}.
|
242 |
*
|
243 |
* @throws InitializeException
|
244 |
*
|
245 |
* @throws ProviderNotRegisteredException
|
246 |
* @throws ValidateDataParametersException
|
247 |
*/
|
248 |
public DataServerExplorer openServerExplorer(
|
249 |
String name,
|
250 |
DataServerExplorerParameters parameters) |
251 |
throws InitializeException, ProviderNotRegisteredException,
|
252 |
ValidateDataParametersException; |
253 |
|
254 |
public DataServerExplorer openServerExplorer(
|
255 |
String explorerName,
|
256 |
Object... arguments)
|
257 |
throws
|
258 |
InitializeException, |
259 |
ProviderNotRegisteredException, |
260 |
ValidateDataParametersException; |
261 |
/**
|
262 |
* @param parameters
|
263 |
* @return
|
264 |
* @throws org.gvsig.fmap.dal.exception.InitializeException
|
265 |
* @throws org.gvsig.fmap.dal.exception.ProviderNotRegisteredException
|
266 |
* @throws org.gvsig.fmap.dal.exception.ValidateDataParametersException
|
267 |
* @deprecated see openServerExplorer
|
268 |
*/
|
269 |
public DataServerExplorer createServerExplorer(
|
270 |
DataServerExplorerParameters parameters) |
271 |
throws InitializeException, ProviderNotRegisteredException,
|
272 |
ValidateDataParametersException; |
273 |
|
274 |
/**
|
275 |
* @param parameters
|
276 |
* @return
|
277 |
* @throws org.gvsig.fmap.dal.exception.InitializeException
|
278 |
* @throws org.gvsig.fmap.dal.exception.ProviderNotRegisteredException
|
279 |
* @throws org.gvsig.fmap.dal.exception.ValidateDataParametersException
|
280 |
* @deprecated see openStore
|
281 |
*/
|
282 |
public DataStore createStore(DataStoreParameters parameters)
|
283 |
throws InitializeException, ProviderNotRegisteredException,
|
284 |
ValidateDataParametersException; |
285 |
|
286 |
/**
|
287 |
* Returns a list of String containing the names of the available
|
288 |
* DataServerExplorer providers.
|
289 |
*
|
290 |
* @return list of String containing the names of the available
|
291 |
* DataServerExplorer providers.
|
292 |
*/
|
293 |
public List<String> getExplorerProviders(); |
294 |
|
295 |
/**
|
296 |
* Creates an instance of Evaluator that represents the given expression.
|
297 |
*
|
298 |
* @param expression String containing a CQL expression.
|
299 |
* @return instance of Evaluator representing the given expression.
|
300 |
* @throws InitializeException
|
301 |
* @deprecated use createFilter
|
302 |
*/
|
303 |
public Evaluator createExpresion(String expression) |
304 |
throws InitializeException;
|
305 |
|
306 |
/**
|
307 |
* Creates an instance of Evaluator that represents the given expression.
|
308 |
*
|
309 |
* @param expression a Expression with the filter
|
310 |
* @return instance of Evaluator representing the given expression.
|
311 |
* @throws InitializeException
|
312 |
* @deprecated use createFilter
|
313 |
*/
|
314 |
public Evaluator createExpresion(Expression expression) |
315 |
throws InitializeException;
|
316 |
|
317 |
/**
|
318 |
* Creates an instance of Evaluator that represents the given expression.
|
319 |
*
|
320 |
* @param expression String containing a CQL expression.
|
321 |
* @return instance of Evaluator representing the given expression.
|
322 |
* @throws InitializeException
|
323 |
*/
|
324 |
public Evaluator createFilter(String expression) |
325 |
throws InitializeException;
|
326 |
|
327 |
/**
|
328 |
* Creates an instance of Evaluator that represents the given expression.
|
329 |
*
|
330 |
* @param expression a Expression with the filter
|
331 |
* @return instance of Evaluator representing the given expression.
|
332 |
* @throws InitializeException
|
333 |
*/
|
334 |
public Evaluator createFilter(Expression expression) |
335 |
throws InitializeException;
|
336 |
|
337 |
/*
|
338 |
* ====================================================================
|
339 |
*
|
340 |
* Index related services
|
341 |
*/
|
342 |
/**
|
343 |
* Returns a list of String containing the names of the available index
|
344 |
* providers.
|
345 |
*
|
346 |
* @return list of strings with the names of the available index providers
|
347 |
*/
|
348 |
public List<String> getFeatureIndexProviders(); |
349 |
|
350 |
/**
|
351 |
* Sets the default DataIndexProvider for the given data type.
|
352 |
*
|
353 |
* @param dataType one of the data types defined in {@link DataTypes}.
|
354 |
* @param name Provider's name
|
355 |
*/
|
356 |
public void setDefaultFeatureIndexProviderName(int dataType, String name); |
357 |
|
358 |
/**
|
359 |
* Returns the default DataIndexProvider name, given a data type. Data types
|
360 |
* are defined in {@link DataTypes}.
|
361 |
*
|
362 |
* @param dataType one of the constants in {@link DataTypes}.
|
363 |
*
|
364 |
* @return the name of the default {@link FeatureIndexProvider} if there is
|
365 |
* anyone available for the given data type.
|
366 |
*/
|
367 |
public String getDefaultFeatureIndexProviderName(int dataType); |
368 |
|
369 |
/**
|
370 |
* Utility method to create the {@link DataStoreParameters} to create a
|
371 |
* {@link FeatureStore} based on the {@link MemoryStoreProvider}.
|
372 |
*
|
373 |
* @param autoOrderAttributeName the name of the {@link Feature} attribute
|
374 |
* to be used to order the store {@link Feature}s by default. Set to null if
|
375 |
* you don't want any order by default
|
376 |
* @return the parameters for the memory based store
|
377 |
* @throws InitializeException if there is an error initializing the
|
378 |
* parameters for the memory provider
|
379 |
*/
|
380 |
public DataStoreParameters createMemoryStoreParameters(
|
381 |
String autoOrderAttributeName) throws InitializeException; |
382 |
|
383 |
/**
|
384 |
* Utility method to create the a {@link FeatureStore} based on the
|
385 |
* {@link MemoryStoreProvider}.
|
386 |
*
|
387 |
* @param autoOrderAttributeName the name of the {@link Feature} attribute
|
388 |
* to be used to order the store {@link Feature}s by default. Set to null if
|
389 |
* you don't want any order by default
|
390 |
* @return the the memory based store
|
391 |
* @throws InitializeException if there is an error initializing the
|
392 |
* parameters for the memory provider
|
393 |
*/
|
394 |
public FeatureStore createMemoryStore(String autoOrderAttributeName) |
395 |
throws InitializeException;
|
396 |
|
397 |
/**
|
398 |
* Creates a {@link FeaturePagingHelper} to paginate data from a
|
399 |
* {@link FeatureStore}.
|
400 |
*
|
401 |
* @param featureStore to get the {@link Feature}s from
|
402 |
* @param pageSize the page size
|
403 |
* @return a {@link FeaturePagingHelper}
|
404 |
* @throws BaseException if there is an error creating the helper
|
405 |
*/
|
406 |
public FeaturePagingHelper createFeaturePagingHelper(
|
407 |
FeatureStore featureStore, int pageSize) throws BaseException; |
408 |
|
409 |
/**
|
410 |
* Creates a {@link FeaturePagingHelper} to paginate data from a
|
411 |
* {@link FeatureStore}.
|
412 |
*
|
413 |
* @param featureStore to get the {@link Feature}s from
|
414 |
* @param featureQuery to filter and/or order the data
|
415 |
* @param pageSize the page size
|
416 |
* @return a {@link FeaturePagingHelper}
|
417 |
* @throws BaseException if there is an error creating the helper
|
418 |
*/
|
419 |
public FeaturePagingHelper createFeaturePagingHelper(
|
420 |
FeatureStore featureStore, FeatureQuery featureQuery, int pageSize)
|
421 |
throws BaseException;
|
422 |
|
423 |
public void setOpenErrorHandler(OpenErrorHandler handler); |
424 |
|
425 |
public OpenErrorHandler getOpenErrorHandler();
|
426 |
|
427 |
public DataStoreProviderFactory getStoreProviderFactory(String name); |
428 |
|
429 |
public EditableFeatureType createFeatureType();
|
430 |
|
431 |
public DataServerExplorerPool getDataServerExplorerPool();
|
432 |
|
433 |
public void setDataServerExplorerPool(DataServerExplorerPool pool); |
434 |
|
435 |
public void setResourcesLoader(ClassLoader loader); |
436 |
|
437 |
public void setResourcesLoader(File folder); |
438 |
|
439 |
/**
|
440 |
* Return a list of the DataTypes supported for the type of the feature
|
441 |
* attributes. The list is only informative.
|
442 |
*
|
443 |
* @return
|
444 |
*/
|
445 |
public List<DataType> getDataTypes(); |
446 |
|
447 |
public Register getStoreRegister();
|
448 |
|
449 |
public Register getStoreProviderRegister();
|
450 |
|
451 |
public Register getServerExplorerRegister();
|
452 |
|
453 |
public Register getFeatureIndexRegister();
|
454 |
|
455 |
/**
|
456 |
* Creates a default ExpressionBuilder.
|
457 |
*
|
458 |
* This ExpressionBuilder is not dependent on a data source,
|
459 |
* and is not advisable to use it.
|
460 |
*
|
461 |
* @return the ExpressionBuilder
|
462 |
* @deprecated use ExpressionEvaluatorManager.createExpressionBuilder()
|
463 |
*/
|
464 |
public ExpressionBuilder createExpressionBuilder();
|
465 |
|
466 |
/**
|
467 |
* Returns a list of String containing the names of the available cache providers.
|
468 |
*
|
469 |
* @return
|
470 |
* list of strings with the names of the available cache providers
|
471 |
*/
|
472 |
public List getFeatureCacheProviders(); |
473 |
|
474 |
/**
|
475 |
* Returns an instance of {@link DataServerExplorerParameters} corresponding
|
476 |
* to the given name used by the cache to create a store to save the
|
477 |
* retrieved data.
|
478 |
*
|
479 |
* @param name
|
480 |
* name of a registered feature cache provider
|
481 |
* @return
|
482 |
*
|
483 |
* @throws InitializeException
|
484 |
* if parameter initialization causes an error.
|
485 |
*
|
486 |
* @throws ProviderNotRegisteredException
|
487 |
* if could not find a cache provider by the given name.
|
488 |
*
|
489 |
*/
|
490 |
public DynObject createCacheParameters(String name) |
491 |
throws InitializeException, ProviderNotRegisteredException;
|
492 |
|
493 |
/**
|
494 |
* @param providerName
|
495 |
* @param params
|
496 |
* @param overwrite
|
497 |
* @throws DataException
|
498 |
*/
|
499 |
public void createFileStore(String providerName, NewDataStoreParameters params, boolean overwrite) throws DataException; |
500 |
|
501 |
public FeatureSymbolTable createFeatureSymbolTable();
|
502 |
|
503 |
public FeatureAttributeEmulatorExpression createFeatureAttributeEmulatorExpression(FeatureType type, Expression expression); |
504 |
|
505 |
public void registerDataProfile(DataProfile profile); |
506 |
|
507 |
public List<DataProfile> getDataProfiles(); |
508 |
|
509 |
public DataProfile getDataProfile(String name); |
510 |
|
511 |
public StoresRepository getStoresRepository();
|
512 |
|
513 |
public DatabaseWorkspaceManager createDatabaseWorkspaceManager(DataServerExplorerParameters connection);
|
514 |
|
515 |
public void addDatabaseWorkspace(DatabaseWorkspaceManager DatabaseWorkspace); |
516 |
|
517 |
public DatabaseWorkspaceManager getDatabaseWorkspace(String name); |
518 |
|
519 |
public DatabaseWorkspaceManager getDatabaseWorkspace(DataStoreParameters params);
|
520 |
|
521 |
public void writeDALResource(ResourcesStorage resources, DataStore store); |
522 |
|
523 |
public void writeDALResource(ResourcesStorage resources, FeatureType featureType); |
524 |
|
525 |
} |