Statistics
| Revision:

svn-gvsig-desktop / tags / dal_time_support_Build_1 / libraries / libFMap_dal / src / org / gvsig / fmap / dal / DataManager.java @ 36111

History | View | Annotate | Download (12.9 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.Feature;
35
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
36
import org.gvsig.fmap.dal.feature.FeatureAttributeGetter;
37
import org.gvsig.fmap.dal.feature.FeatureIndex;
38
import org.gvsig.fmap.dal.feature.FeatureQuery;
39
import org.gvsig.fmap.dal.feature.FeatureStore;
40
import org.gvsig.fmap.dal.feature.paging.FeaturePagingHelper;
41
import org.gvsig.fmap.dal.feature.spi.index.FeatureIndexProvider;
42
import org.gvsig.fmap.dal.resource.ResourceManager;
43
import org.gvsig.fmap.dal.store.memory.MemoryStoreProvider;
44
import org.gvsig.tools.dynobject.DynObject;
45
import org.gvsig.tools.evaluator.Evaluator;
46
import org.gvsig.tools.exception.BaseException;
47

    
48
/**
49
 * There are two top level management roles within DAL: data access and resource management.
50
 *
51
 * This class is responsible of the data access management role. It provides ways
52
 * for registering and instantiating {@link DataServerExplorer}(s), {@link DataStore}(s),
53
 * {@link Evaluator}(s) and {@link FeatureIndex}(es).
54
 *
55
 * @see ResourceManager
56
 *
57
 */
58

    
59
public interface DataManager {
60

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

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

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

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

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

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

    
131
        /**
132
         * Create a new physical store 
133
         *  
134
         * @param parameters
135
         *
136
         * @throws InitializeException
137
         * @throws ProviderNotRegisteredException
138
         * @throws ValidateDataParametersException
139
         */
140
        public void newStore(String explorer, String provider, NewDataStoreParameters parameters, boolean overwrite)
141
                        throws InitializeException, ProviderNotRegisteredException,
142
                        ValidateDataParametersException;
143

    
144
        /**
145
         * Returns a list of Strings containing the names of all available DataStore
146
         * providers.
147
         *
148
         * @return list of String containing available DataStore provider names
149
         */
150
        public List getStoreProviders();
151

    
152
        /**
153
         * Returns a list of Strings containing the names of all available DataStore
154
         * providers for an explorer.
155
         * 
156
         * @param explorer
157
         *            name
158
         */
159
        public List getStoreProviders(String name);
160

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

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

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

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

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

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

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

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

    
254

    
255
        /**
256
         * Returns a list of String containing the names of the available index providers.
257
         *
258
         * @return
259
         *                 list of strings with the names of the available index providers
260
         */
261
        public List getFeatureIndexProviders();
262

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

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

    
286
    /**
287
         * Returns a list of String containing the names of the available cache providers.
288
         *
289
         * @return
290
         *                 list of strings with the names of the available cache providers
291
         */    
292
    public List getFeatureCacheProviders();
293

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

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

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

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

    
359
        /**
360
     * Creates a {@link FeaturePagingHelper} to paginate data from a
361
     * {@link FeatureStore}.
362
     * 
363
     * @param featureStore
364
     *            to get the {@link Feature}s from
365
     * @param featureQuery
366
     *            to filter and/or order the data
367
     * @param pageSize
368
     *            the page size
369
     * @return a {@link FeaturePagingHelper}
370
     * @throws BaseException
371
     *             if there is an error creating the helper
372
     */
373
        public FeaturePagingHelper createFeaturePagingHelper(
374
                        FeatureStore featureStore, FeatureQuery featureQuery, int pageSize)
375
        throws BaseException;
376
        
377
        /**
378
         * Registers a class that can be used to create a {@link FeatureAttributeGetter}
379
         * and associate it to a {@link FeatureAttributeDescriptor}.
380
         * 
381
            * @param name
382
            *             the name used to register the class.
383
         * @param clazz
384
         *             it has to be an instance of {@link FeatureAttributeDescriptor}         
385
         */
386
        public void registerFeatureAttributeGetter(String name, Class clazz);
387
        
388
        /**
389
         * Creates a {@link FeatureAttributeGetter} by name. If there is not any class
390
         * registered with this name or if there is any error an exception is thrown.
391
         * 
392
         * @param name
393
         *             the name that was used to register the class              
394
         * @return
395
         *             a {@link FeatureAttributeGetter}
396
         * @throws InitializeException
397
         *             if there is any error creating the object
398
         */
399
        public FeatureAttributeGetter createFeatureAttributeGetter(String name) throws InitializeException;
400
        
401
        public void setOpenErrorHandler(OpenErrorHandler handler);
402

    
403
}