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