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
/* 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.fmap.dal.feature.spi.index.FeatureIndexProvider;
43
import org.gvsig.fmap.dal.resource.ResourceManager;
44
import org.gvsig.fmap.dal.store.memory.MemoryStoreProvider;
45
import org.gvsig.tools.dynobject.DynObject;
46
import org.gvsig.tools.evaluator.Evaluator;
47
import org.gvsig.tools.exception.BaseException;
48

    
49
/**
50
 * 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
 * @see ResourceManager
57
 *
58
 */
59

    
60
public interface DataManager {
61

    
62
        /**
63
         * Returns the default DAL's temporary directory
64
         *
65
         * @return Temporary directory name
66
         */
67
        public String getTemporaryDirectory();
68

    
69
        /*
70
         * ====================================================================
71
         *
72
         * Store related services
73
         */
74

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

    
91
        /**
92
         * 
93
         * 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
         * Creates, initializes and returns an instance of DataStore given the
107
         * DataStoreParameters.
108
         * 
109
         * @param parameters
110
         *            parameters used to instantiate and initialize the DataStore
111
         * 
112
         * @throws ProviderNotRegisteredException
113
         *             if the memory provider is not registered
114
         * @throws InitializeException
115
         *             if there is an error initializing the parameters for the
116
         *             memory provider
117
         * @throws ValidateDataParametersException
118
         *             if the parameters to open the memory based store are not
119
         *             valid
120
         */
121
        public DataStore openStore(String provider, DataStoreParameters parameters)
122
                        throws InitializeException, ProviderNotRegisteredException,
123
                        ValidateDataParametersException;
124

    
125
        /**
126
         * @deprecated see openStore
127
         */
128
        public DataStore createStore(DataStoreParameters parameters)
129
                        throws InitializeException, ProviderNotRegisteredException,
130
                        ValidateDataParametersException;
131

    
132
        /**
133
         * 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
         * Returns a list of Strings containing the names of all available DataStore
147
         * providers.
148
         *
149
         * @return list of String containing available DataStore provider names
150
         */
151
        public List getStoreProviders();
152

    
153
        /**
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
        /*
163
         * ====================================================================
164
         *
165
         * Explorer related services
166
         */
167
        /**
168
         * Returns an instance of {@link DataServerExplorerParameters} corresponding to
169
         * the given name.
170
         *
171
         * @param name
172
         *            name of a registered server explorer provider
173
         *
174
         * @throws InitializeException
175
         *                         if parameter initialization causes an error.
176
         *
177
         * @throws ProviderNotRegisteredException
178
         *                         if could not find a provider by the given name.
179
         *
180
         **/
181
        public DataServerExplorerParameters createServerExplorerParameters(
182
                        String name)
183
                        throws InitializeException, ProviderNotRegisteredException;
184

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

    
205
        /**
206
         * @deprecated see openServerExplorer
207
         */
208
        public DataServerExplorer createServerExplorer(
209
                        DataServerExplorerParameters parameters)
210
                        throws InitializeException, ProviderNotRegisteredException,
211
                        ValidateDataParametersException;
212

    
213
        /**
214
         * Returns a list of String containing the names of the available
215
         * DataServerExplorer providers.
216
         *
217
         * @return list of String containing the names of the available
218
         *         DataServerExplorer providers.
219
         */
220
        public List getExplorerProviders();
221

    
222
        /*
223
         * ====================================================================
224
         *
225
         * Expression evaluation related services
226
         */
227

    
228
        /**
229
         * Registers the default expression evaluator. It is used by DAL to evaluate
230
         * and resolve query filters and expressions.
231
         *
232
         * @param evaluator
233
         *            Class that will be called to evaluate the expression. It must
234
         *            implement {@link Evaluator}.
235
         */
236
        public void registerDefaultEvaluator(Class evaluator);
237

    
238
        /**
239
         * Creates an instance of Evaluator that represents the given expression.
240
         *
241
         * @param expression
242
         *            String containing a CQL expression.
243
         * @return instance of Evaluator representing the given expression.
244
         * @throws InitializeException
245
         */
246
        public Evaluator createExpresion(String expression)
247
                        throws InitializeException;
248

    
249
        /*
250
         * ====================================================================
251
         *
252
         * Index related services
253
         */
254

    
255

    
256
        /**
257
         * 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
         */
262
        public List getFeatureIndexProviders();
263

    
264
        /**
265
         * Sets the default DataIndexProvider for the given data type.
266
         *
267
         * @param dataType
268
         *                                 one of the data types defined in {@link DataTypes}.
269
         * @param name
270
         *                         Provider's name
271
         */
272
    public void setDefaultFeatureIndexProviderName(int dataType, String name);
273

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

    
287
    /**
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
        /**
296
         * 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
         * 
300
         * @param name
301
         *            name of a registered feature cache provider
302
         * 
303
         * @throws InitializeException
304
         *             if parameter initialization causes an error.
305
         * 
306
         * @throws ProviderNotRegisteredException
307
         *             if could not find a cache provider by the given name.
308
         * 
309
         */
310
        public DynObject createCacheParameters(String name)
311
                        throws InitializeException, ProviderNotRegisteredException;
312

    
313
        /**
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

    
329
        /**
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

    
345
    /**
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
        public FeaturePagingHelper createFeaturePagingHelper(
358
        FeatureStore featureStore, int pageSize) throws BaseException;
359

    
360
        /**
361
     * 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
        public FeaturePagingHelper createFeaturePagingHelper(
375
                        FeatureStore featureStore, FeatureQuery featureQuery, int pageSize)
376
        throws BaseException;
377
        
378
        public void setOpenErrorHandler(OpenErrorHandler handler);
379
        
380
        public DataStoreProviderFactory getStoreProviderFactory(String name);
381

    
382
        public EditableFeatureType createFeatureType();
383
        
384
        public List getDataTypes();
385
        
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
}