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 @ 44644
History | View | Annotate | Download (19.1 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 |
public static final String DAL_USE_LABELS = "DAL.useLabels"; |
79 |
public static final int USE_LABELS_YES = 0; |
80 |
public static final int USE_LABELS_NO = 1; |
81 |
public static final int USE_LABELS_BOTH = 2; |
82 |
|
83 |
/**
|
84 |
*
|
85 |
* Returns the default DAL's temporary directory
|
86 |
*
|
87 |
* @return Temporary directory name
|
88 |
* @deprecated use FoldersManager of org.gvsig.tools
|
89 |
*/
|
90 |
public String getTemporaryDirectory(); |
91 |
|
92 |
/*
|
93 |
* ====================================================================
|
94 |
*
|
95 |
* Store related services
|
96 |
*/
|
97 |
/**
|
98 |
* Creates, initializes and returns an instance of DataStoreParameters given
|
99 |
* the name with which their provider is registered.
|
100 |
*
|
101 |
* @param name provider name
|
102 |
* @return the data store parameters
|
103 |
*
|
104 |
* @throws ProviderNotRegisteredException if the memory provider is not
|
105 |
* registered
|
106 |
* @throws InitializeException if there is an error initializing the
|
107 |
* parameters for the memory provider
|
108 |
*
|
109 |
*/
|
110 |
public DataStoreParameters createStoreParameters(String name) |
111 |
throws InitializeException, ProviderNotRegisteredException;
|
112 |
|
113 |
public DataStoreParameters createStoreParameters(byte[] data); |
114 |
|
115 |
/**
|
116 |
* Creates, initializes and fill an instance of DataStoreParameters from the
|
117 |
* tags of the DynStruct passed as parameter.
|
118 |
*
|
119 |
* @param struct structure from which tags were created ths parameters.
|
120 |
* @return the data store parameters
|
121 |
*
|
122 |
* @throws ProviderNotRegisteredException if the memory provider is not
|
123 |
* registered
|
124 |
* @throws InitializeException if there is an error initializing the
|
125 |
* parameters for the memory provider
|
126 |
*
|
127 |
*/
|
128 |
public DataStoreParameters createStoreParameters(DynStruct struct)
|
129 |
throws InitializeException, ProviderNotRegisteredException;
|
130 |
|
131 |
public DataStoreParameters createStoreParameters(Tags tags) throws InitializeException, ProviderNotRegisteredException; |
132 |
|
133 |
/**
|
134 |
* Creates, initializes and returns an instance of NewDataStoreParameters
|
135 |
* given the name with which their provider is registered.
|
136 |
*
|
137 |
* @param explorer
|
138 |
* @param provider
|
139 |
* @return
|
140 |
*
|
141 |
* @throws InitializeException
|
142 |
* @throws ProviderNotRegisteredException
|
143 |
*/
|
144 |
public NewDataStoreParameters createNewStoreParameters(String explorer, String provider) |
145 |
throws InitializeException, ProviderNotRegisteredException;
|
146 |
|
147 |
/**
|
148 |
*
|
149 |
* Creates, initializes and returns an instance of DataStore given the
|
150 |
* DataStoreParameters.
|
151 |
*
|
152 |
* @param provider
|
153 |
* @param parameters parameters used to instantiate and initialize the
|
154 |
* DataStore
|
155 |
* @return
|
156 |
*
|
157 |
* @throws ProviderNotRegisteredException if the memory provider is not
|
158 |
* registered
|
159 |
* @throws InitializeException if there is an error initializing the
|
160 |
* parameters for the memory provider
|
161 |
* @throws ValidateDataParametersException if the parameters to open the
|
162 |
* memory based store are not valid
|
163 |
*/
|
164 |
public DataStore openStore(String provider, DynObject parameters) |
165 |
throws InitializeException, ProviderNotRegisteredException,
|
166 |
ValidateDataParametersException; |
167 |
|
168 |
public DataStore openStore(String provider, DataStoreParameters parameters) |
169 |
throws InitializeException, ProviderNotRegisteredException,
|
170 |
ValidateDataParametersException; |
171 |
|
172 |
public DataStore openStore(
|
173 |
String providerName,
|
174 |
Object... arguments)
|
175 |
throws
|
176 |
InitializeException, |
177 |
ProviderNotRegisteredException, |
178 |
ValidateDataParametersException; |
179 |
|
180 |
public DataStore openStore(DynStruct struct)
|
181 |
throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException;
|
182 |
|
183 |
/**
|
184 |
* Create a new physical store
|
185 |
*
|
186 |
* @param explorer
|
187 |
* @param provider
|
188 |
* @param parameters
|
189 |
* @param overwrite
|
190 |
*
|
191 |
* @throws InitializeException
|
192 |
* @throws ProviderNotRegisteredException
|
193 |
* @throws ValidateDataParametersException
|
194 |
*/
|
195 |
public void newStore(String explorer, String provider, NewDataStoreParameters parameters, boolean overwrite) |
196 |
throws InitializeException, ProviderNotRegisteredException,
|
197 |
ValidateDataParametersException; |
198 |
|
199 |
/**
|
200 |
* Returns a list of Strings containing the names of all available DataStore
|
201 |
* providers.
|
202 |
*
|
203 |
* @return list of String containing available DataStore provider names
|
204 |
*/
|
205 |
public List getStoreProviders(); |
206 |
|
207 |
/**
|
208 |
* Returns a list of Strings containing the names of all available DataStore
|
209 |
* providers for an explorer.
|
210 |
*
|
211 |
* @param name
|
212 |
* @return
|
213 |
*/
|
214 |
public List<String> getStoreProviders(String name); |
215 |
|
216 |
/*
|
217 |
* ====================================================================
|
218 |
*
|
219 |
* Explorer related services
|
220 |
*/
|
221 |
/**
|
222 |
* Returns an instance of {@link DataServerExplorerParameters} corresponding
|
223 |
* to the given name.
|
224 |
*
|
225 |
* @param name name of a registered server explorer provider
|
226 |
* @return
|
227 |
*
|
228 |
* @throws InitializeException if parameter initialization causes an error.
|
229 |
*
|
230 |
* @throws ProviderNotRegisteredException if could not find a provider by
|
231 |
* the given name.
|
232 |
*
|
233 |
*
|
234 |
*/
|
235 |
public DataServerExplorerParameters createServerExplorerParameters(
|
236 |
String name)
|
237 |
throws InitializeException, ProviderNotRegisteredException;
|
238 |
|
239 |
/**
|
240 |
* Returns an instance of {@link DataServerExplorer} given its parameters.
|
241 |
*
|
242 |
* @param name
|
243 |
* @param parameters parameters used to instantiate and initialize the
|
244 |
* {@link DataServerExplorer}.
|
245 |
*
|
246 |
* @return an instance of {@link DataServerExplorer}.
|
247 |
*
|
248 |
* @throws InitializeException
|
249 |
*
|
250 |
* @throws ProviderNotRegisteredException
|
251 |
* @throws ValidateDataParametersException
|
252 |
*/
|
253 |
public DataServerExplorer openServerExplorer(
|
254 |
String name,
|
255 |
DataServerExplorerParameters parameters) |
256 |
throws InitializeException, ProviderNotRegisteredException,
|
257 |
ValidateDataParametersException; |
258 |
|
259 |
public DataServerExplorer openServerExplorer(
|
260 |
String explorerName,
|
261 |
Object... arguments)
|
262 |
throws
|
263 |
InitializeException, |
264 |
ProviderNotRegisteredException, |
265 |
ValidateDataParametersException; |
266 |
/**
|
267 |
* @param parameters
|
268 |
* @return
|
269 |
* @throws org.gvsig.fmap.dal.exception.InitializeException
|
270 |
* @throws org.gvsig.fmap.dal.exception.ProviderNotRegisteredException
|
271 |
* @throws org.gvsig.fmap.dal.exception.ValidateDataParametersException
|
272 |
* @deprecated see openServerExplorer
|
273 |
*/
|
274 |
public DataServerExplorer createServerExplorer(
|
275 |
DataServerExplorerParameters parameters) |
276 |
throws InitializeException, ProviderNotRegisteredException,
|
277 |
ValidateDataParametersException; |
278 |
|
279 |
/**
|
280 |
* @param parameters
|
281 |
* @return
|
282 |
* @throws org.gvsig.fmap.dal.exception.InitializeException
|
283 |
* @throws org.gvsig.fmap.dal.exception.ProviderNotRegisteredException
|
284 |
* @throws org.gvsig.fmap.dal.exception.ValidateDataParametersException
|
285 |
* @deprecated see openStore
|
286 |
*/
|
287 |
public DataStore createStore(DataStoreParameters parameters)
|
288 |
throws InitializeException, ProviderNotRegisteredException,
|
289 |
ValidateDataParametersException; |
290 |
|
291 |
/**
|
292 |
* Returns a list of String containing the names of the available
|
293 |
* DataServerExplorer providers.
|
294 |
*
|
295 |
* @return list of String containing the names of the available
|
296 |
* DataServerExplorer providers.
|
297 |
*/
|
298 |
public List<String> getExplorerProviders(); |
299 |
|
300 |
/**
|
301 |
* Creates an instance of Evaluator that represents the given expression.
|
302 |
*
|
303 |
* @param expression String containing a CQL expression.
|
304 |
* @return instance of Evaluator representing the given expression.
|
305 |
* @throws InitializeException
|
306 |
* @deprecated use createFilter
|
307 |
*/
|
308 |
public Evaluator createExpresion(String expression) |
309 |
throws InitializeException;
|
310 |
|
311 |
/**
|
312 |
* Creates an instance of Evaluator that represents the given expression.
|
313 |
*
|
314 |
* @param expression a Expression with the filter
|
315 |
* @return instance of Evaluator representing the given expression.
|
316 |
* @throws InitializeException
|
317 |
* @deprecated use createFilter
|
318 |
*/
|
319 |
public Evaluator createExpresion(Expression expression) |
320 |
throws InitializeException;
|
321 |
|
322 |
/**
|
323 |
* Creates an instance of Evaluator that represents the given expression.
|
324 |
*
|
325 |
* @param expression String containing a CQL expression.
|
326 |
* @return instance of Evaluator representing the given expression.
|
327 |
* @throws InitializeException
|
328 |
*/
|
329 |
public Evaluator createFilter(String expression) |
330 |
throws InitializeException;
|
331 |
|
332 |
/**
|
333 |
* Creates an instance of Evaluator that represents the given expression.
|
334 |
*
|
335 |
* @param expression a Expression with the filter
|
336 |
* @return instance of Evaluator representing the given expression.
|
337 |
* @throws InitializeException
|
338 |
*/
|
339 |
public Evaluator createFilter(Expression expression) |
340 |
throws InitializeException;
|
341 |
|
342 |
/*
|
343 |
* ====================================================================
|
344 |
*
|
345 |
* Index related services
|
346 |
*/
|
347 |
/**
|
348 |
* Returns a list of String containing the names of the available index
|
349 |
* providers.
|
350 |
*
|
351 |
* @return list of strings with the names of the available index providers
|
352 |
*/
|
353 |
public List<String> getFeatureIndexProviders(); |
354 |
|
355 |
/**
|
356 |
* Sets the default DataIndexProvider for the given data type.
|
357 |
*
|
358 |
* @param dataType one of the data types defined in {@link DataTypes}.
|
359 |
* @param name Provider's name
|
360 |
*/
|
361 |
public void setDefaultFeatureIndexProviderName(int dataType, String name); |
362 |
|
363 |
/**
|
364 |
* Returns the default DataIndexProvider name, given a data type. Data types
|
365 |
* are defined in {@link DataTypes}.
|
366 |
*
|
367 |
* @param dataType one of the constants in {@link DataTypes}.
|
368 |
*
|
369 |
* @return the name of the default {@link FeatureIndexProvider} if there is
|
370 |
* anyone available for the given data type.
|
371 |
*/
|
372 |
public String getDefaultFeatureIndexProviderName(int dataType); |
373 |
|
374 |
/**
|
375 |
* Utility method to create the {@link DataStoreParameters} to create a
|
376 |
* {@link FeatureStore} based on the {@link MemoryStoreProvider}.
|
377 |
*
|
378 |
* @param autoOrderAttributeName the name of the {@link Feature} attribute
|
379 |
* to be used to order the store {@link Feature}s by default. Set to null if
|
380 |
* you don't want any order by default
|
381 |
* @return the parameters for the memory based store
|
382 |
* @throws InitializeException if there is an error initializing the
|
383 |
* parameters for the memory provider
|
384 |
*/
|
385 |
public DataStoreParameters createMemoryStoreParameters(
|
386 |
String autoOrderAttributeName) throws InitializeException; |
387 |
|
388 |
/**
|
389 |
* Utility method to create the a {@link FeatureStore} based on the
|
390 |
* {@link MemoryStoreProvider}.
|
391 |
*
|
392 |
* @param autoOrderAttributeName the name of the {@link Feature} attribute
|
393 |
* to be used to order the store {@link Feature}s by default. Set to null if
|
394 |
* you don't want any order by default
|
395 |
* @return the the memory based store
|
396 |
* @throws InitializeException if there is an error initializing the
|
397 |
* parameters for the memory provider
|
398 |
*/
|
399 |
public FeatureStore createMemoryStore(String autoOrderAttributeName) |
400 |
throws InitializeException;
|
401 |
|
402 |
/**
|
403 |
* Creates a {@link FeaturePagingHelper} to paginate data from a
|
404 |
* {@link FeatureStore}.
|
405 |
*
|
406 |
* @param featureStore to get the {@link Feature}s from
|
407 |
* @param pageSize the page size
|
408 |
* @return a {@link FeaturePagingHelper}
|
409 |
* @throws BaseException if there is an error creating the helper
|
410 |
*/
|
411 |
public FeaturePagingHelper createFeaturePagingHelper(
|
412 |
FeatureStore featureStore, int pageSize) throws BaseException; |
413 |
|
414 |
/**
|
415 |
* Creates a {@link FeaturePagingHelper} to paginate data from a
|
416 |
* {@link FeatureStore}.
|
417 |
*
|
418 |
* @param featureStore to get the {@link Feature}s from
|
419 |
* @param featureQuery to filter and/or order the data
|
420 |
* @param pageSize the page size
|
421 |
* @return a {@link FeaturePagingHelper}
|
422 |
* @throws BaseException if there is an error creating the helper
|
423 |
*/
|
424 |
public FeaturePagingHelper createFeaturePagingHelper(
|
425 |
FeatureStore featureStore, FeatureQuery featureQuery, int pageSize)
|
426 |
throws BaseException;
|
427 |
|
428 |
public void setOpenErrorHandler(OpenErrorHandler handler); |
429 |
|
430 |
public OpenErrorHandler getOpenErrorHandler();
|
431 |
|
432 |
public DataStoreProviderFactory getStoreProviderFactory(String name); |
433 |
|
434 |
public EditableFeatureType createFeatureType();
|
435 |
|
436 |
public DataServerExplorerPool getDataServerExplorerPool();
|
437 |
|
438 |
public void setDataServerExplorerPool(DataServerExplorerPool pool); |
439 |
|
440 |
public void setResourcesLoader(ClassLoader loader); |
441 |
|
442 |
public void setResourcesLoader(File folder); |
443 |
|
444 |
/**
|
445 |
* Return a list of the DataTypes supported for the type of the feature
|
446 |
* attributes. The list is only informative.
|
447 |
*
|
448 |
* @return
|
449 |
*/
|
450 |
public List<DataType> getDataTypes(); |
451 |
|
452 |
public Register getStoreRegister();
|
453 |
|
454 |
public Register getStoreProviderRegister();
|
455 |
|
456 |
public Register getServerExplorerRegister();
|
457 |
|
458 |
public Register getFeatureIndexRegister();
|
459 |
|
460 |
/**
|
461 |
* Creates a default ExpressionBuilder.
|
462 |
*
|
463 |
* This ExpressionBuilder is not dependent on a data source,
|
464 |
* and is not advisable to use it.
|
465 |
*
|
466 |
* @return the ExpressionBuilder
|
467 |
* @deprecated use ExpressionEvaluatorManager.createExpressionBuilder()
|
468 |
*/
|
469 |
public ExpressionBuilder createExpressionBuilder();
|
470 |
|
471 |
/**
|
472 |
* Returns a list of String containing the names of the available cache providers.
|
473 |
*
|
474 |
* @return
|
475 |
* list of strings with the names of the available cache providers
|
476 |
*/
|
477 |
public List getFeatureCacheProviders(); |
478 |
|
479 |
/**
|
480 |
* Returns an instance of {@link DataServerExplorerParameters} corresponding
|
481 |
* to the given name used by the cache to create a store to save the
|
482 |
* retrieved data.
|
483 |
*
|
484 |
* @param name
|
485 |
* name of a registered feature cache provider
|
486 |
* @return
|
487 |
*
|
488 |
* @throws InitializeException
|
489 |
* if parameter initialization causes an error.
|
490 |
*
|
491 |
* @throws ProviderNotRegisteredException
|
492 |
* if could not find a cache provider by the given name.
|
493 |
*
|
494 |
*/
|
495 |
public DynObject createCacheParameters(String name) |
496 |
throws InitializeException, ProviderNotRegisteredException;
|
497 |
|
498 |
/**
|
499 |
* @param providerName
|
500 |
* @param params
|
501 |
* @param overwrite
|
502 |
* @throws DataException
|
503 |
*/
|
504 |
public void createFileStore(String providerName, NewDataStoreParameters params, boolean overwrite) throws DataException; |
505 |
|
506 |
public FeatureSymbolTable createFeatureSymbolTable();
|
507 |
|
508 |
public FeatureAttributeEmulatorExpression createFeatureAttributeEmulatorExpression(FeatureType type, Expression expression); |
509 |
|
510 |
public void registerDataProfile(DataProfile profile); |
511 |
|
512 |
public List<DataProfile> getDataProfiles(); |
513 |
|
514 |
public DataProfile getDataProfile(String name); |
515 |
|
516 |
public StoresRepository getStoresRepository();
|
517 |
|
518 |
public DatabaseWorkspaceManager createDatabaseWorkspaceManager(DataServerExplorerParameters connection);
|
519 |
|
520 |
public void addDatabaseWorkspace(DatabaseWorkspaceManager DatabaseWorkspace); |
521 |
|
522 |
public void addDatabaseWorkspaceListener(DatabaseWorkspaceManager.AddDatabaseWorkspaceListener listener); |
523 |
|
524 |
public DatabaseWorkspaceManager getDatabaseWorkspace(String name); |
525 |
|
526 |
public DatabaseWorkspaceManager getDatabaseWorkspace(DataStoreParameters params);
|
527 |
|
528 |
public void writeDALResource(ResourcesStorage resources, DataStore store); |
529 |
|
530 |
public void writeDALResource(ResourcesStorage resources, FeatureType featureType); |
531 |
|
532 |
/**
|
533 |
* Return a 35-40 characters unique identifier.
|
534 |
*
|
535 |
* @return the unique identifier
|
536 |
*/
|
537 |
public String createUniqueID(); |
538 |
|
539 |
public int getDefaultSize(int dataType); |
540 |
|
541 |
} |