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 @ 43989
History | View | Annotate | Download (16.8 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 |
|
29 |
import org.gvsig.fmap.dal.exception.DataException; |
30 |
import org.gvsig.fmap.dal.exception.InitializeException; |
31 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
32 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
33 |
import org.gvsig.fmap.dal.expressionevaluator.FeatureSymbolTable; |
34 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
35 |
import org.gvsig.fmap.dal.feature.Feature; |
36 |
import org.gvsig.fmap.dal.feature.FeatureIndex; |
37 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
38 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
39 |
import org.gvsig.fmap.dal.feature.FeatureType; |
40 |
import org.gvsig.fmap.dal.feature.paging.FeaturePagingHelper; |
41 |
import org.gvsig.fmap.dal.resource.ResourceManager; |
42 |
import org.gvsig.tools.dataTypes.DataType; |
43 |
import org.gvsig.tools.dynobject.DynObject; |
44 |
import org.gvsig.tools.dynobject.DynStruct; |
45 |
import org.gvsig.tools.dynobject.Tags; |
46 |
import org.gvsig.tools.evaluator.Evaluator; |
47 |
import org.gvsig.tools.evaluator.EvaluatorFactory; |
48 |
import org.gvsig.tools.exception.BaseException; |
49 |
import org.gvsig.tools.service.spi.Services; |
50 |
import org.gvsig.fmap.dal.expressionevaluator.FeatureAttributeEmulatorExpression; |
51 |
|
52 |
/**
|
53 |
* There are two top level management roles within DAL: data access and resource
|
54 |
* management.
|
55 |
*
|
56 |
* This class is responsible of the data access management role. It provides
|
57 |
* ways for registering and instantiating {@link DataServerExplorer}(s),
|
58 |
* {@link DataStore}(s), {@link Evaluator}(s) and {@link FeatureIndex}(es).
|
59 |
*
|
60 |
* @see ResourceManager
|
61 |
*
|
62 |
*/
|
63 |
public interface DataManager extends Services { |
64 |
|
65 |
public static final String CREATE_STORE_AUTHORIZATION = "dal-create-store"; |
66 |
public static final String READ_STORE_AUTHORIZATION = "dal-read-store"; |
67 |
public static final String WRITE_STORE_AUTHORIZATION = "dal-write-store"; |
68 |
|
69 |
public static final String FEATURE_SYMBOL_TABLE = "DAL.FeatureSymbolTable"; |
70 |
/**
|
71 |
* Returns the default DAL's temporary directory
|
72 |
*
|
73 |
* @return Temporary directory name
|
74 |
* @deprecated use FoldersManager of org.gvsig.tools
|
75 |
*/
|
76 |
public String getTemporaryDirectory(); |
77 |
|
78 |
/*
|
79 |
* ====================================================================
|
80 |
*
|
81 |
* Store related services
|
82 |
*/
|
83 |
/**
|
84 |
* Creates, initializes and returns an instance of DataStoreParameters given
|
85 |
* the name with which their provider is registered.
|
86 |
*
|
87 |
* @param name provider name
|
88 |
* @return the data store parameters
|
89 |
*
|
90 |
* @throws ProviderNotRegisteredException if the memory provider is not
|
91 |
* registered
|
92 |
* @throws InitializeException if there is an error initializing the
|
93 |
* parameters for the memory provider
|
94 |
*
|
95 |
*/
|
96 |
public DataStoreParameters createStoreParameters(String name) |
97 |
throws InitializeException, ProviderNotRegisteredException;
|
98 |
|
99 |
/**
|
100 |
* Creates, initializes and fill an instance of DataStoreParameters from the
|
101 |
* tags of the DynStruct passed as parameter.
|
102 |
*
|
103 |
* @param struct structure from which tags were created ths parameters.
|
104 |
* @return the data store parameters
|
105 |
*
|
106 |
* @throws ProviderNotRegisteredException if the memory provider is not
|
107 |
* registered
|
108 |
* @throws InitializeException if there is an error initializing the
|
109 |
* parameters for the memory provider
|
110 |
*
|
111 |
*/
|
112 |
public DataStoreParameters createStoreParameters(DynStruct struct)
|
113 |
throws InitializeException, ProviderNotRegisteredException;
|
114 |
|
115 |
public DataStoreParameters createStoreParameters(Tags tags) throws InitializeException, ProviderNotRegisteredException; |
116 |
|
117 |
/**
|
118 |
* Creates, initializes and returns an instance of NewDataStoreParameters
|
119 |
* given the name with which their provider is registered.
|
120 |
*
|
121 |
* @param explorer
|
122 |
* @param provider
|
123 |
* @return
|
124 |
*
|
125 |
* @throws InitializeException
|
126 |
* @throws ProviderNotRegisteredException
|
127 |
*/
|
128 |
public NewDataStoreParameters createNewStoreParameters(String explorer, String provider) |
129 |
throws InitializeException, ProviderNotRegisteredException;
|
130 |
|
131 |
/**
|
132 |
*
|
133 |
* Creates, initializes and returns an instance of DataStore given the
|
134 |
* DataStoreParameters.
|
135 |
*
|
136 |
* @param provider
|
137 |
* @param parameters parameters used to instantiate and initialize the
|
138 |
* DataStore
|
139 |
* @return
|
140 |
*
|
141 |
* @throws ProviderNotRegisteredException if the memory provider is not
|
142 |
* registered
|
143 |
* @throws InitializeException if there is an error initializing the
|
144 |
* parameters for the memory provider
|
145 |
* @throws ValidateDataParametersException if the parameters to open the
|
146 |
* memory based store are not valid
|
147 |
*/
|
148 |
public DataStore openStore(String provider, DynObject parameters) |
149 |
throws InitializeException, ProviderNotRegisteredException,
|
150 |
ValidateDataParametersException; |
151 |
|
152 |
public DataStore openStore(String provider, DataStoreParameters parameters) |
153 |
throws InitializeException, ProviderNotRegisteredException,
|
154 |
ValidateDataParametersException; |
155 |
|
156 |
public DataStore openStore(
|
157 |
String providerName,
|
158 |
Object... arguments)
|
159 |
throws
|
160 |
InitializeException, |
161 |
ProviderNotRegisteredException, |
162 |
ValidateDataParametersException; |
163 |
|
164 |
public DataStore openStore(DynStruct struct)
|
165 |
throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException;
|
166 |
|
167 |
/**
|
168 |
* Create a new physical store
|
169 |
*
|
170 |
* @param explorer
|
171 |
* @param provider
|
172 |
* @param parameters
|
173 |
* @param overwrite
|
174 |
*
|
175 |
* @throws InitializeException
|
176 |
* @throws ProviderNotRegisteredException
|
177 |
* @throws ValidateDataParametersException
|
178 |
*/
|
179 |
public void newStore(String explorer, String provider, NewDataStoreParameters parameters, boolean overwrite) |
180 |
throws InitializeException, ProviderNotRegisteredException,
|
181 |
ValidateDataParametersException; |
182 |
|
183 |
/**
|
184 |
* Returns a list of Strings containing the names of all available DataStore
|
185 |
* providers.
|
186 |
*
|
187 |
* @return list of String containing available DataStore provider names
|
188 |
*/
|
189 |
public List getStoreProviders(); |
190 |
|
191 |
/**
|
192 |
* Returns a list of Strings containing the names of all available DataStore
|
193 |
* providers for an explorer.
|
194 |
*
|
195 |
* @param name
|
196 |
* @return
|
197 |
*/
|
198 |
public List<String> getStoreProviders(String name); |
199 |
|
200 |
/*
|
201 |
* ====================================================================
|
202 |
*
|
203 |
* Explorer related services
|
204 |
*/
|
205 |
/**
|
206 |
* Returns an instance of {@link DataServerExplorerParameters} corresponding
|
207 |
* to the given name.
|
208 |
*
|
209 |
* @param name name of a registered server explorer provider
|
210 |
* @return
|
211 |
*
|
212 |
* @throws InitializeException if parameter initialization causes an error.
|
213 |
*
|
214 |
* @throws ProviderNotRegisteredException if could not find a provider by
|
215 |
* the given name.
|
216 |
*
|
217 |
*
|
218 |
*/
|
219 |
public DataServerExplorerParameters createServerExplorerParameters(
|
220 |
String name)
|
221 |
throws InitializeException, ProviderNotRegisteredException;
|
222 |
|
223 |
/**
|
224 |
* Returns an instance of {@link DataServerExplorer} given its parameters.
|
225 |
*
|
226 |
* @param name
|
227 |
* @param parameters parameters used to instantiate and initialize the
|
228 |
* {@link DataServerExplorer}.
|
229 |
*
|
230 |
* @return an instance of {@link DataServerExplorer}.
|
231 |
*
|
232 |
* @throws InitializeException
|
233 |
*
|
234 |
* @throws ProviderNotRegisteredException
|
235 |
* @throws ValidateDataParametersException
|
236 |
*/
|
237 |
public DataServerExplorer openServerExplorer(
|
238 |
String name,
|
239 |
DataServerExplorerParameters parameters) |
240 |
throws InitializeException, ProviderNotRegisteredException,
|
241 |
ValidateDataParametersException; |
242 |
|
243 |
public DataServerExplorer openServerExplorer(
|
244 |
String explorerName,
|
245 |
Object... arguments)
|
246 |
throws
|
247 |
InitializeException, |
248 |
ProviderNotRegisteredException, |
249 |
ValidateDataParametersException; |
250 |
/**
|
251 |
* @param parameters
|
252 |
* @return
|
253 |
* @throws org.gvsig.fmap.dal.exception.InitializeException
|
254 |
* @throws org.gvsig.fmap.dal.exception.ProviderNotRegisteredException
|
255 |
* @throws org.gvsig.fmap.dal.exception.ValidateDataParametersException
|
256 |
* @deprecated see openServerExplorer
|
257 |
*/
|
258 |
public DataServerExplorer createServerExplorer(
|
259 |
DataServerExplorerParameters parameters) |
260 |
throws InitializeException, ProviderNotRegisteredException,
|
261 |
ValidateDataParametersException; |
262 |
|
263 |
/**
|
264 |
* @param parameters
|
265 |
* @return
|
266 |
* @throws org.gvsig.fmap.dal.exception.InitializeException
|
267 |
* @throws org.gvsig.fmap.dal.exception.ProviderNotRegisteredException
|
268 |
* @throws org.gvsig.fmap.dal.exception.ValidateDataParametersException
|
269 |
* @deprecated see openStore
|
270 |
*/
|
271 |
public DataStore createStore(DataStoreParameters parameters)
|
272 |
throws InitializeException, ProviderNotRegisteredException,
|
273 |
ValidateDataParametersException; |
274 |
|
275 |
/**
|
276 |
* Returns a list of String containing the names of the available
|
277 |
* DataServerExplorer providers.
|
278 |
*
|
279 |
* @return list of String containing the names of the available
|
280 |
* DataServerExplorer providers.
|
281 |
*/
|
282 |
public List<String> getExplorerProviders(); |
283 |
|
284 |
/*
|
285 |
* ====================================================================
|
286 |
*
|
287 |
* Expression evaluation related services
|
288 |
*/
|
289 |
/**
|
290 |
* Registers the default expression evaluator. It is used by DAL to evaluate
|
291 |
* and resolve query filters and expressions.
|
292 |
*
|
293 |
* @param evaluatorFactory
|
294 |
*/
|
295 |
public void registerDefaultEvaluator(EvaluatorFactory evaluatorFactory); |
296 |
|
297 |
/**
|
298 |
* Creates an instance of Evaluator that represents the given expression.
|
299 |
*
|
300 |
* @param expression String containing a CQL expression.
|
301 |
* @return instance of Evaluator representing the given expression.
|
302 |
* @throws InitializeException
|
303 |
*/
|
304 |
public Evaluator createExpresion(String expression) |
305 |
throws InitializeException;
|
306 |
|
307 |
public Evaluator createExpresion(Expression expression) |
308 |
throws InitializeException;
|
309 |
|
310 |
public EvaluatorFactory createEvaluatorFactory();
|
311 |
|
312 |
/*
|
313 |
* ====================================================================
|
314 |
*
|
315 |
* Index related services
|
316 |
*/
|
317 |
/**
|
318 |
* Returns a list of String containing the names of the available index
|
319 |
* providers.
|
320 |
*
|
321 |
* @return list of strings with the names of the available index providers
|
322 |
*/
|
323 |
public List<String> getFeatureIndexProviders(); |
324 |
|
325 |
/**
|
326 |
* Sets the default DataIndexProvider for the given data type.
|
327 |
*
|
328 |
* @param dataType one of the data types defined in {@link DataTypes}.
|
329 |
* @param name Provider's name
|
330 |
*/
|
331 |
public void setDefaultFeatureIndexProviderName(int dataType, String name); |
332 |
|
333 |
/**
|
334 |
* Returns the default DataIndexProvider name, given a data type. Data types
|
335 |
* are defined in {@link DataTypes}.
|
336 |
*
|
337 |
* @param dataType one of the constants in {@link DataTypes}.
|
338 |
*
|
339 |
* @return the name of the default {@link FeatureIndexProvider} if there is
|
340 |
* anyone available for the given data type.
|
341 |
*/
|
342 |
public String getDefaultFeatureIndexProviderName(int dataType); |
343 |
|
344 |
/**
|
345 |
* Utility method to create the {@link DataStoreParameters} to create a
|
346 |
* {@link FeatureStore} based on the {@link MemoryStoreProvider}.
|
347 |
*
|
348 |
* @param autoOrderAttributeName the name of the {@link Feature} attribute
|
349 |
* to be used to order the store {@link Feature}s by default. Set to null if
|
350 |
* you don't want any order by default
|
351 |
* @return the parameters for the memory based store
|
352 |
* @throws InitializeException if there is an error initializing the
|
353 |
* parameters for the memory provider
|
354 |
*/
|
355 |
public DataStoreParameters createMemoryStoreParameters(
|
356 |
String autoOrderAttributeName) throws InitializeException; |
357 |
|
358 |
/**
|
359 |
* Utility method to create the a {@link FeatureStore} based on the
|
360 |
* {@link MemoryStoreProvider}.
|
361 |
*
|
362 |
* @param autoOrderAttributeName the name of the {@link Feature} attribute
|
363 |
* to be used to order the store {@link Feature}s by default. Set to null if
|
364 |
* you don't want any order by default
|
365 |
* @return the the memory based store
|
366 |
* @throws InitializeException if there is an error initializing the
|
367 |
* parameters for the memory provider
|
368 |
*/
|
369 |
public FeatureStore createMemoryStore(String autoOrderAttributeName) |
370 |
throws InitializeException;
|
371 |
|
372 |
/**
|
373 |
* Creates a {@link FeaturePagingHelper} to paginate data from a
|
374 |
* {@link FeatureStore}.
|
375 |
*
|
376 |
* @param featureStore to get the {@link Feature}s from
|
377 |
* @param pageSize the page size
|
378 |
* @return a {@link FeaturePagingHelper}
|
379 |
* @throws BaseException if there is an error creating the helper
|
380 |
*/
|
381 |
public FeaturePagingHelper createFeaturePagingHelper(
|
382 |
FeatureStore featureStore, int pageSize) throws BaseException; |
383 |
|
384 |
/**
|
385 |
* Creates a {@link FeaturePagingHelper} to paginate data from a
|
386 |
* {@link FeatureStore}.
|
387 |
*
|
388 |
* @param featureStore to get the {@link Feature}s from
|
389 |
* @param featureQuery to filter and/or order the data
|
390 |
* @param pageSize the page size
|
391 |
* @return a {@link FeaturePagingHelper}
|
392 |
* @throws BaseException if there is an error creating the helper
|
393 |
*/
|
394 |
public FeaturePagingHelper createFeaturePagingHelper(
|
395 |
FeatureStore featureStore, FeatureQuery featureQuery, int pageSize)
|
396 |
throws BaseException;
|
397 |
|
398 |
public void setOpenErrorHandler(OpenErrorHandler handler); |
399 |
|
400 |
public OpenErrorHandler getOpenErrorHandler();
|
401 |
|
402 |
public DataStoreProviderFactory getStoreProviderFactory(String name); |
403 |
|
404 |
public EditableFeatureType createFeatureType();
|
405 |
|
406 |
public DataServerExplorerPool getDataServerExplorerPool();
|
407 |
|
408 |
public void setDataServerExplorerPool(DataServerExplorerPool pool); |
409 |
|
410 |
public void setResourcesLoader(ClassLoader loader); |
411 |
|
412 |
public void setResourcesLoader(File folder); |
413 |
|
414 |
/**
|
415 |
* Return a list of the DataTypes supported for the type of the feature
|
416 |
* attributes. The list is only informative.
|
417 |
*
|
418 |
* @return
|
419 |
*/
|
420 |
public List<DataType> getDataTypes(); |
421 |
|
422 |
public Register getStoreRegister();
|
423 |
|
424 |
public Register getStoreProviderRegister();
|
425 |
|
426 |
public Register getServerExplorerRegister();
|
427 |
|
428 |
public Register getFeatureIndexRegister();
|
429 |
|
430 |
/**
|
431 |
* Creates a default ExpressionBuilder.
|
432 |
*
|
433 |
* This ExpressionBuilder is not dependent on a data source,
|
434 |
* and is not advisable to use it.
|
435 |
*
|
436 |
* @return the ExpressionBuilder
|
437 |
*/
|
438 |
public ExpressionBuilder createExpressionBuilder();
|
439 |
|
440 |
/**
|
441 |
* Returns a list of String containing the names of the available cache providers.
|
442 |
*
|
443 |
* @return
|
444 |
* list of strings with the names of the available cache providers
|
445 |
*/
|
446 |
public List getFeatureCacheProviders(); |
447 |
|
448 |
/**
|
449 |
* Returns an instance of {@link DataServerExplorerParameters} corresponding
|
450 |
* to the given name used by the cache to create a store to save the
|
451 |
* retrieved data.
|
452 |
*
|
453 |
* @param name
|
454 |
* name of a registered feature cache provider
|
455 |
* @return
|
456 |
*
|
457 |
* @throws InitializeException
|
458 |
* if parameter initialization causes an error.
|
459 |
*
|
460 |
* @throws ProviderNotRegisteredException
|
461 |
* if could not find a cache provider by the given name.
|
462 |
*
|
463 |
*/
|
464 |
public DynObject createCacheParameters(String name) |
465 |
throws InitializeException, ProviderNotRegisteredException;
|
466 |
|
467 |
/**
|
468 |
* @param providerName
|
469 |
* @param params
|
470 |
* @param overwrite
|
471 |
* @throws DataException
|
472 |
*/
|
473 |
public void createFileStore(String providerName, NewDataStoreParameters params, boolean overwrite) throws DataException; |
474 |
|
475 |
public FeatureSymbolTable createFeatureSymbolTable();
|
476 |
|
477 |
public FeatureAttributeEmulatorExpression createFeatureAttributeEmulatorExpression(FeatureType type, Expression expression); |
478 |
} |