Statistics
| Revision:

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 @ 40596

History | View | Annotate | Download (12.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.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

    
56
        /**
57
         * Returns the default DAL's temporary directory
58
         *
59
         * @return Temporary directory name
60
         */
61
        public String getTemporaryDirectory();
62

    
63
        /*
64
         * ====================================================================
65
         *
66
         * Store related services
67
         */
68

    
69
        /**
70
         * Creates, initializes and returns an instance of DataStoreParameters given
71
         * the name with which their provider is registered.
72
         * 
73
         * @param name
74
         *            provider name
75
         * 
76
         * @throws ProviderNotRegisteredException
77
         *             if the memory provider is not registered
78
         * @throws InitializeException
79
         *             if there is an error initializing the parameters for the
80
         *             memory provider
81
         **/
82
        public DataStoreParameters createStoreParameters(String name)
83
                        throws InitializeException, ProviderNotRegisteredException;
84

    
85
        /**
86
         * 
87
         * Creates, initializes and returns an instance of NewDataStoreParameters
88
         * given the name with which their provider is registered.
89
         * 
90
         * @param name
91
         * 
92
         * @throws InitializeException
93
         * @throws ProviderNotRegisteredException
94
         */
95
        public NewDataStoreParameters createNewStoreParameters(String explorer, String provider)
96
                        throws InitializeException, ProviderNotRegisteredException;
97

    
98
        /**
99
         * 
100
         * Creates, initializes and returns an instance of DataStore given the
101
         * DataStoreParameters.
102
         * 
103
         * @param parameters
104
         *            parameters used to instantiate and initialize the DataStore
105
         * 
106
         * @throws ProviderNotRegisteredException
107
         *             if the memory provider is not registered
108
         * @throws InitializeException
109
         *             if there is an error initializing the parameters for the
110
         *             memory provider
111
         * @throws ValidateDataParametersException
112
         *             if the parameters to open the memory based store are not
113
         *             valid
114
         */
115
        public DataStore openStore(String provider, DataStoreParameters parameters)
116
                        throws InitializeException, ProviderNotRegisteredException,
117
                        ValidateDataParametersException;
118

    
119
        /**
120
         * @deprecated see openStore
121
         */
122
        public DataStore createStore(DataStoreParameters parameters)
123
                        throws InitializeException, ProviderNotRegisteredException,
124
                        ValidateDataParametersException;
125

    
126
        /**
127
         * Create a new physical store 
128
         *  
129
         * @param parameters
130
         *
131
         * @throws InitializeException
132
         * @throws ProviderNotRegisteredException
133
         * @throws ValidateDataParametersException
134
         */
135
        public void newStore(String explorer, String provider, NewDataStoreParameters parameters, boolean overwrite)
136
                        throws InitializeException, ProviderNotRegisteredException,
137
                        ValidateDataParametersException;
138

    
139
        /**
140
         * Returns a list of Strings containing the names of all available DataStore
141
         * providers.
142
         *
143
         * @return list of String containing available DataStore provider names
144
         */
145
        public List getStoreProviders();
146

    
147
        /**
148
         * Returns a list of Strings containing the names of all available DataStore
149
         * providers for an explorer.
150
         * 
151
         * @param explorer
152
         *            name
153
         */
154
        public List getStoreProviders(String name);
155

    
156
        /*
157
         * ====================================================================
158
         *
159
         * Explorer related services
160
         */
161
        /**
162
         * Returns an instance of {@link DataServerExplorerParameters} corresponding to
163
         * the given name.
164
         *
165
         * @param name
166
         *            name of a registered server explorer provider
167
         *
168
         * @throws InitializeException
169
         *                         if parameter initialization causes an error.
170
         *
171
         * @throws ProviderNotRegisteredException
172
         *                         if could not find a provider by the given name.
173
         *
174
         **/
175
        public DataServerExplorerParameters createServerExplorerParameters(
176
                        String name)
177
                        throws InitializeException, ProviderNotRegisteredException;
178

    
179
        /**
180
         * Returns an instance of {@link DataServerExplorer} given its parameters.
181
         *
182
         * @param parameters
183
         *            parameters used to instantiate and initialize the
184
         *            {@link DataServerExplorer}.
185
         *
186
         * @return an instance of {@link DataServerExplorer}.
187
         *
188
         * @throws InitializeException
189
         *
190
         * @throws ProviderNotRegisteredException
191
         * @throws ValidateDataParametersException
192
         */
193
        public DataServerExplorer openServerExplorer(
194
                        String name,
195
                        DataServerExplorerParameters parameters)
196
                        throws InitializeException, ProviderNotRegisteredException,
197
                        ValidateDataParametersException;
198

    
199
        /**
200
         * @deprecated see openServerExplorer
201
         */
202
        public DataServerExplorer createServerExplorer(
203
                        DataServerExplorerParameters parameters)
204
                        throws InitializeException, ProviderNotRegisteredException,
205
                        ValidateDataParametersException;
206

    
207
        /**
208
         * Returns a list of String containing the names of the available
209
         * DataServerExplorer providers.
210
         *
211
         * @return list of String containing the names of the available
212
         *         DataServerExplorer providers.
213
         */
214
        public List getExplorerProviders();
215

    
216
        /*
217
         * ====================================================================
218
         *
219
         * Expression evaluation related services
220
         */
221

    
222
        /**
223
         * Registers the default expression evaluator. It is used by DAL to evaluate
224
         * and resolve query filters and expressions.
225
         *
226
         * @param evaluator
227
         *            Class that will be called to evaluate the expression. It must
228
         *            implement {@link Evaluator}.
229
         */
230
        public void registerDefaultEvaluator(Class evaluator);
231

    
232
        /**
233
         * Creates an instance of Evaluator that represents the given expression.
234
         *
235
         * @param expression
236
         *            String containing a CQL expression.
237
         * @return instance of Evaluator representing the given expression.
238
         * @throws InitializeException
239
         */
240
        public Evaluator createExpresion(String expression)
241
                        throws InitializeException;
242

    
243
        /*
244
         * ====================================================================
245
         *
246
         * Index related services
247
         */
248

    
249

    
250
        /**
251
         * Returns a list of String containing the names of the available index providers.
252
         *
253
         * @return
254
         *                 list of strings with the names of the available index providers
255
         */
256
        public List getFeatureIndexProviders();
257

    
258
        /**
259
         * Sets the default DataIndexProvider for the given data type.
260
         *
261
         * @param dataType
262
         *                                 one of the data types defined in {@link DataTypes}.
263
         * @param name
264
         *                         Provider's name
265
         */
266
    public void setDefaultFeatureIndexProviderName(int dataType, String name);
267

    
268
        /**
269
         * Returns the default DataIndexProvider name, given a data type. Data types
270
         * are defined in {@link DataTypes}.
271
         *
272
         * @param dataType
273
         *            one of the constants in {@link DataTypes}.
274
         *
275
         * @return
276
         *                 the name of the default {@link FeatureIndexProvider} if there is
277
         *                 anyone available for the given data type.
278
         */
279
    public String getDefaultFeatureIndexProviderName(int dataType);
280

    
281
    /**
282
         * Returns a list of String containing the names of the available cache providers.
283
         *
284
         * @return
285
         *                 list of strings with the names of the available cache providers
286
         */    
287
    public List getFeatureCacheProviders();
288

    
289
        /**
290
         * Returns an instance of {@link DataServerExplorerParameters} corresponding
291
         * to the given name used by the cache to create a store to save the
292
         * retrieved data.
293
         * 
294
         * @param name
295
         *            name of a registered feature cache provider
296
         * 
297
         * @throws InitializeException
298
         *             if parameter initialization causes an error.
299
         * 
300
         * @throws ProviderNotRegisteredException
301
         *             if could not find a cache provider by the given name.
302
         * 
303
         */
304
        public DynObject createCacheParameters(String name)
305
                        throws InitializeException, ProviderNotRegisteredException;
306

    
307
        /**
308
         * Utility method to create the {@link DataStoreParameters} to create a
309
         * {@link FeatureStore} based on the {@link MemoryStoreProvider}.
310
         * 
311
         * @param autoOrderAttributeName
312
         *            the name of the {@link Feature} attribute to be used to order
313
         *            the store {@link Feature}s by default. Set to null if you
314
         *            don't want any order by default
315
         * @return the parameters for the memory based store
316
         * @throws InitializeException
317
         *             if there is an error initializing the parameters for the
318
         *             memory provider
319
         */
320
        public DataStoreParameters createMemoryStoreParameters(
321
                        String autoOrderAttributeName) throws InitializeException;
322

    
323
        /**
324
         * Utility method to create the a {@link FeatureStore} based on the
325
         * {@link MemoryStoreProvider}.
326
         * 
327
         * @param autoOrderAttributeName
328
         *            the name of the {@link Feature} attribute to be used to order
329
         *            the store {@link Feature}s by default. Set to null if you
330
         *            don't want any order by default
331
         * @return the the memory based store
332
         * @throws InitializeException
333
         *             if there is an error initializing the parameters for the
334
         *             memory provider
335
         */
336
        public FeatureStore createMemoryStore(String autoOrderAttributeName)
337
                        throws InitializeException;
338

    
339
    /**
340
     * Creates a {@link FeaturePagingHelper} to paginate data from a
341
     * {@link FeatureStore}.
342
     * 
343
     * @param featureStore
344
     *            to get the {@link Feature}s from
345
     * @param pageSize
346
     *            the page size
347
     * @return a {@link FeaturePagingHelper}
348
     * @throws BaseException
349
     *             if there is an error creating the helper
350
     */
351
        public FeaturePagingHelper createFeaturePagingHelper(
352
        FeatureStore featureStore, int pageSize) throws BaseException;
353

    
354
        /**
355
     * Creates a {@link FeaturePagingHelper} to paginate data from a
356
     * {@link FeatureStore}.
357
     * 
358
     * @param featureStore
359
     *            to get the {@link Feature}s from
360
     * @param featureQuery
361
     *            to filter and/or order the data
362
     * @param pageSize
363
     *            the page size
364
     * @return a {@link FeaturePagingHelper}
365
     * @throws BaseException
366
     *             if there is an error creating the helper
367
     */
368
        public FeaturePagingHelper createFeaturePagingHelper(
369
                        FeatureStore featureStore, FeatureQuery featureQuery, int pageSize)
370
        throws BaseException;
371
        
372
        public void setOpenErrorHandler(OpenErrorHandler handler);
373
        
374
        public DataStoreProviderFactory getStoreProviderFactory(String name);
375

    
376
        public EditableFeatureType createFeatureType();
377
        
378
        public List getDataTypes();
379
        
380
        /**
381
         * Registers a class that can be used to create a {@link FeatureAttributeGetter}
382
         * and associate it to a {@link FeatureAttributeDescriptor}.
383
         * 
384
            * @param name
385
            *             the name used to register the class.
386
         * @param clazz
387
         *             it has to be an instance of {@link FeatureAttributeDescriptor}         
388
         */
389
        public void registerFeatureAttributeGetter(String name, Class clazz);
390
        
391
        /**
392
         * Creates a {@link FeatureAttributeGetter} by name. If there is not any class
393
         * registered with this name or if there is any error an exception is thrown.
394
         * 
395
         * @param name
396
         *             the name that was used to register the class              
397
         * @return
398
         *             a {@link FeatureAttributeGetter}
399
         * @throws InitializeException
400
         *             if there is any error creating the object
401
         */
402
        public FeatureAttributeGetter createFeatureAttributeGetter(String name) throws InitializeException;
403
}