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