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