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

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
     * @deprecated use FoldersManager of org.gvsig.tools
70
     */
71
    public String getTemporaryDirectory();
72

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
396
    public void setOpenErrorHandler(OpenErrorHandler handler);
397

    
398
    public OpenErrorHandler getOpenErrorHandler();
399

    
400
    public DataStoreProviderFactory getStoreProviderFactory(String name);
401

    
402
    public EditableFeatureType createFeatureType();
403

    
404
    public DataServerExplorerPool getDataServerExplorerPool();
405

    
406
    public void setDataServerExplorerPool(DataServerExplorerPool pool);
407

    
408
    public void setResourcesLoader(ClassLoader loader);
409

    
410
    public void setResourcesLoader(File folder);
411

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

    
420
    public Register getStoreRegister();
421

    
422
    public Register getStoreProviderRegister();
423

    
424
    public Register getServerExplorerRegister();
425

    
426
    public Register getFeatureIndexRegister();
427

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

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

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

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

    
473
}