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

History | View | Annotate | Download (16.4 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 modify it under
7
 * the terms of the GNU General Public License as published by the Free Software
8
 * Foundation; either version 3 of the License, or (at your option) any later
9
 * version.
10
 *
11
 * This program is distributed in the hope that it will be useful, but WITHOUT
12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14
 * details.
15
 *
16
 * You should have received a copy of the GNU General Public License along with
17
 * this program; if not, write to the Free Software Foundation, Inc., 51
18
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us at info AT
21
 * gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.fmap.dal;
24

    
25
import java.io.File;
26
import java.util.List;
27

    
28
import org.gvsig.fmap.dal.exception.DataException;
29
import org.gvsig.fmap.dal.exception.InitializeException;
30
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
31
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
32
import org.gvsig.fmap.dal.feature.EditableFeatureType;
33
import org.gvsig.fmap.dal.feature.Feature;
34
import org.gvsig.fmap.dal.feature.FeatureIndex;
35
import org.gvsig.fmap.dal.feature.FeatureQuery;
36
import org.gvsig.fmap.dal.feature.FeatureStore;
37
import org.gvsig.fmap.dal.feature.paging.FeaturePagingHelper;
38
import org.gvsig.fmap.dal.raster.NewRasterStoreParameters;
39
import org.gvsig.fmap.dal.resource.ResourceManager;
40
import org.gvsig.tools.dataTypes.DataType;
41
import org.gvsig.tools.dynobject.DynObject;
42
import org.gvsig.tools.dynobject.DynStruct;
43
import org.gvsig.tools.dynobject.Tags;
44
import org.gvsig.tools.evaluator.Evaluator;
45
import org.gvsig.tools.exception.BaseException;
46
import org.gvsig.tools.service.spi.Services;
47

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

    
61
    public static final String CREATE_STORE_AUTHORIZATION = "dal-create-store";
62
    public static final String READ_STORE_AUTHORIZATION = "dal-read-store";
63
    public static final String WRITE_STORE_AUTHORIZATION = "dal-write-store";
64

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

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

    
93
    /**
94
     * Creates, initializes and fill an instance of DataStoreParameters from the
95
     * tags of the DynStruct passed as parameter.
96
     *
97
     * @param struct structure from which tags were created ths parameters.
98
     * @return the data store parameters
99
     *
100
     * @throws ProviderNotRegisteredException if the memory provider is not
101
     * registered
102
     * @throws InitializeException if there is an error initializing the
103
     * parameters for the memory provider
104
     *
105
     */
106
    public DataStoreParameters createStoreParameters(DynStruct struct)
107
            throws InitializeException, ProviderNotRegisteredException;
108

    
109
    public DataStoreParameters createStoreParameters(Tags tags) throws InitializeException, ProviderNotRegisteredException;
110

    
111
    /**
112
     * Creates, initializes and returns an instance of NewDataStoreParameters
113
     * given the name with which their provider is registered.
114
     *
115
     * @param explorer
116
     * @param provider
117
     * @return
118
     *
119
     * @throws InitializeException
120
     * @throws ProviderNotRegisteredException
121
     */
122
    public NewDataStoreParameters createNewStoreParameters(String explorer, String provider)
123
            throws InitializeException, ProviderNotRegisteredException;
124

    
125
    /**
126
     *
127
     * Creates, initializes and returns an instance of DataStore given the
128
     * DataStoreParameters.
129
     *
130
     * @param provider
131
     * @param parameters parameters used to instantiate and initialize the
132
     * DataStore
133
     * @return
134
     *
135
     * @throws ProviderNotRegisteredException if the memory provider is not
136
     * registered
137
     * @throws InitializeException if there is an error initializing the
138
     * parameters for the memory provider
139
     * @throws ValidateDataParametersException if the parameters to open the
140
     * memory based store are not valid
141
     */
142
    public DataStore openStore(String provider, DynObject parameters)
143
            throws InitializeException, ProviderNotRegisteredException,
144
            ValidateDataParametersException;
145

    
146
    public DataStore openStore(String provider, DataStoreParameters parameters)
147
            throws InitializeException, ProviderNotRegisteredException,
148
            ValidateDataParametersException;
149

    
150
    public DataStore openStore(
151
            String providerName,
152
            Object... arguments)
153
        throws
154
            InitializeException,
155
            ProviderNotRegisteredException,
156
            ValidateDataParametersException;
157

    
158
    public DataStore openStore(DynStruct struct)
159
            throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException;
160

    
161
    /**
162
     * Create a new physical store
163
     *
164
     * @param explorer
165
     * @param provider
166
     * @param parameters
167
     * @param overwrite
168
     *
169
     * @throws InitializeException
170
     * @throws ProviderNotRegisteredException
171
     * @throws ValidateDataParametersException
172
     */
173
    public void newStore(String explorer, String provider, NewDataStoreParameters parameters, boolean overwrite)
174
            throws InitializeException, ProviderNotRegisteredException,
175
            ValidateDataParametersException;
176

    
177
    /**
178
     * Returns a list of Strings containing the names of all available DataStore
179
     * providers.
180
     *
181
     * @return list of String containing available DataStore provider names
182
     */
183
    public List getStoreProviders();
184

    
185
    /**
186
     * Returns a list of Strings containing the names of all available DataStore
187
     * providers for an explorer.
188
     *
189
     * @param name
190
     * @return
191
     */
192
    public List<String> getStoreProviders(String name);
193

    
194
    /*
195
     * ====================================================================
196
     *
197
     * Explorer related services
198
     */
199
    /**
200
     * Returns an instance of {@link DataServerExplorerParameters} corresponding
201
     * to the given name.
202
     *
203
     * @param name name of a registered server explorer provider
204
     * @return
205
     *
206
     * @throws InitializeException if parameter initialization causes an error.
207
     *
208
     * @throws ProviderNotRegisteredException if could not find a provider by
209
     * the given name.
210
     *
211
     *
212
     */
213
    public DataServerExplorerParameters createServerExplorerParameters(
214
            String name)
215
            throws InitializeException, ProviderNotRegisteredException;
216

    
217
    /**
218
     * Returns an instance of {@link DataServerExplorer} given its parameters.
219
     *
220
     * @param name
221
     * @param parameters parameters used to instantiate and initialize the
222
     * {@link DataServerExplorer}.
223
     *
224
     * @return an instance of {@link DataServerExplorer}.
225
     *
226
     * @throws InitializeException
227
     *
228
     * @throws ProviderNotRegisteredException
229
     * @throws ValidateDataParametersException
230
     */
231
    public DataServerExplorer openServerExplorer(
232
            String name,
233
            DataServerExplorerParameters parameters)
234
            throws InitializeException, ProviderNotRegisteredException,
235
            ValidateDataParametersException;
236

    
237
    public DataServerExplorer openServerExplorer(
238
            String explorerName,
239
            Object... arguments)
240
        throws
241
            InitializeException,
242
            ProviderNotRegisteredException,
243
            ValidateDataParametersException;
244
    /**
245
     * @param parameters
246
     * @return
247
     * @throws org.gvsig.fmap.dal.exception.InitializeException
248
     * @throws org.gvsig.fmap.dal.exception.ProviderNotRegisteredException
249
     * @throws org.gvsig.fmap.dal.exception.ValidateDataParametersException
250
     * @deprecated see openServerExplorer
251
     */
252
    public DataServerExplorer createServerExplorer(
253
            DataServerExplorerParameters parameters)
254
            throws InitializeException, ProviderNotRegisteredException,
255
            ValidateDataParametersException;
256

    
257
    /**
258
     * @param parameters
259
     * @return
260
     * @throws org.gvsig.fmap.dal.exception.InitializeException
261
     * @throws org.gvsig.fmap.dal.exception.ProviderNotRegisteredException
262
     * @throws org.gvsig.fmap.dal.exception.ValidateDataParametersException
263
     * @deprecated see openStore
264
     */
265
    public DataStore createStore(DataStoreParameters parameters)
266
            throws InitializeException, ProviderNotRegisteredException,
267
            ValidateDataParametersException;
268

    
269
    /**
270
     * Returns a list of String containing the names of the available
271
     * DataServerExplorer providers.
272
     *
273
     * @return list of String containing the names of the available
274
     * DataServerExplorer providers.
275
     */
276
    public List<String> getExplorerProviders();
277

    
278
    /*
279
     * ====================================================================
280
     *
281
     * Expression evaluation related services
282
     */
283
    /**
284
     * Registers the default expression evaluator. It is used by DAL to evaluate
285
     * and resolve query filters and expressions.
286
     *
287
     * @param evaluator Class that will be called to evaluate the expression. It
288
     * must implement {@link Evaluator}.
289
     */
290
    public void registerDefaultEvaluator(Class evaluator);
291

    
292
    /**
293
     * Creates an instance of Evaluator that represents the given expression.
294
     *
295
     * @param expression String containing a CQL expression.
296
     * @return instance of Evaluator representing the given expression.
297
     * @throws InitializeException
298
     */
299
    public Evaluator createExpresion(String expression)
300
            throws InitializeException;
301

    
302
    /**
303
     * Creates an instance of Evaluator to evaluate a expression.
304
     *
305
     * @return instance of ExpressionEvaluator representing the given expression.
306
     */
307
    public ExpressionEvaluator createExpresion();
308

    
309
    /*
310
     * ====================================================================
311
     *
312
     * Index related services
313
     */
314
    /**
315
     * Returns a list of String containing the names of the available index
316
     * providers.
317
     *
318
     * @return list of strings with the names of the available index providers
319
     */
320
    public List<String> getFeatureIndexProviders();
321

    
322
    /**
323
     * Sets the default DataIndexProvider for the given data type.
324
     *
325
     * @param dataType one of the data types defined in {@link DataTypes}.
326
     * @param name Provider's name
327
     */
328
    public void setDefaultFeatureIndexProviderName(int dataType, String name);
329

    
330
    /**
331
     * Returns the default DataIndexProvider name, given a data type. Data types
332
     * are defined in {@link DataTypes}.
333
     *
334
     * @param dataType one of the constants in {@link DataTypes}.
335
     *
336
     * @return the name of the default {@link FeatureIndexProvider} if there is
337
     * anyone available for the given data type.
338
     */
339
    public String getDefaultFeatureIndexProviderName(int dataType);
340

    
341
    /**
342
     * Utility method to create the {@link DataStoreParameters} to create a
343
     * {@link FeatureStore} based on the {@link MemoryStoreProvider}.
344
     *
345
     * @param autoOrderAttributeName the name of the {@link Feature} attribute
346
     * to be used to order the store {@link Feature}s by default. Set to null if
347
     * you don't want any order by default
348
     * @return the parameters for the memory based store
349
     * @throws InitializeException if there is an error initializing the
350
     * parameters for the memory provider
351
     */
352
    public DataStoreParameters createMemoryStoreParameters(
353
            String autoOrderAttributeName) throws InitializeException;
354

    
355
    /**
356
     * Utility method to create the a {@link FeatureStore} based on the
357
     * {@link MemoryStoreProvider}.
358
     *
359
     * @param autoOrderAttributeName the name of the {@link Feature} attribute
360
     * to be used to order the store {@link Feature}s by default. Set to null if
361
     * you don't want any order by default
362
     * @return the the memory based store
363
     * @throws InitializeException if there is an error initializing the
364
     * parameters for the memory provider
365
     */
366
    public FeatureStore createMemoryStore(String autoOrderAttributeName)
367
            throws InitializeException;
368

    
369
    /**
370
     * Creates a {@link FeaturePagingHelper} to paginate data from a
371
     * {@link FeatureStore}.
372
     *
373
     * @param featureStore to get the {@link Feature}s from
374
     * @param pageSize the page size
375
     * @return a {@link FeaturePagingHelper}
376
     * @throws BaseException if there is an error creating the helper
377
     */
378
    public FeaturePagingHelper createFeaturePagingHelper(
379
            FeatureStore featureStore, int pageSize) throws BaseException;
380

    
381
    /**
382
     * Creates a {@link FeaturePagingHelper} to paginate data from a
383
     * {@link FeatureStore}.
384
     *
385
     * @param featureStore to get the {@link Feature}s from
386
     * @param featureQuery to filter and/or order the data
387
     * @param pageSize the page size
388
     * @return a {@link FeaturePagingHelper}
389
     * @throws BaseException if there is an error creating the helper
390
     */
391
    public FeaturePagingHelper createFeaturePagingHelper(
392
            FeatureStore featureStore, FeatureQuery featureQuery, int pageSize)
393
            throws BaseException;
394

    
395
    public void setOpenErrorHandler(OpenErrorHandler handler);
396

    
397
    public OpenErrorHandler getOpenErrorHandler();
398

    
399
    public DataStoreProviderFactory getStoreProviderFactory(String name);
400

    
401
    public EditableFeatureType createFeatureType();
402

    
403
    public DataServerExplorerPool getDataServerExplorerPool();
404

    
405
    public void setDataServerExplorerPool(DataServerExplorerPool pool);
406

    
407
    public void setResourcesLoader(ClassLoader loader);
408

    
409
    public void setResourcesLoader(File folder);
410

    
411
    /**
412
     * Return a list of the DataTypes supported for the type of the feature
413
     * attributes. The list is only informative.
414
     *
415
     * @return
416
     */
417
    public List<DataType> getDataTypes();
418

    
419
    public Register getStoreRegister();
420

    
421
    public Register getStoreProviderRegister();
422

    
423
    public Register getServerExplorerRegister();
424

    
425
    public Register getFeatureIndexRegister();
426

    
427
    /**
428
     * Creates a default ExpressionBuilder.
429
     *
430
     * This ExpressionBuilder is not dependent on a data source,
431
     * and is not advisable to use it.
432
     *
433
     * @return the ExpressionBuilder
434
     */
435
    public ExpressionBuilder createExpressionBuilder();
436

    
437
    /**
438
         * Returns a list of String containing the names of the available cache providers.
439
         *
440
         * @return
441
         *                 list of strings with the names of the available cache providers
442
         */
443
    public List getFeatureCacheProviders();
444

    
445
        /**
446
         * Returns an instance of {@link DataServerExplorerParameters} corresponding
447
         * to the given name used by the cache to create a store to save the
448
         * retrieved data.
449
         *
450
         * @param name
451
         *            name of a registered feature cache provider
452
         *
453
         * @throws InitializeException
454
         *             if parameter initialization causes an error.
455
         *
456
         * @throws ProviderNotRegisteredException
457
         *             if could not find a cache provider by the given name.
458
         *
459
         */
460
        public DynObject createCacheParameters(String name)
461
                        throws InitializeException, ProviderNotRegisteredException;
462

    
463
    /**
464
     * @param providerName
465
     * @param params
466
     * @param overwrite
467
     * @throws DataException
468
     */
469
    public void createFileStore(String providerName, NewRasterStoreParameters params, boolean overwrite) throws DataException;
470

    
471
}