Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_dal / src / org / gvsig / fmap / dal / DataManager.java @ 40333

History | View | Annotate | Download (13.1 KB)

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