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