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