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