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