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

History | View | Annotate | Download (16.5 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
import org.gvsig.expressionevaluator.Expression;
28

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

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

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

    
67
    /**
68
     * Returns the default DAL's temporary directory
69
     *
70
     * @return Temporary directory name
71
     * @deprecated use FoldersManager of org.gvsig.tools
72
     */
73
    public String getTemporaryDirectory();
74

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

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

    
112
    public DataStoreParameters createStoreParameters(Tags tags) throws InitializeException, ProviderNotRegisteredException;
113

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

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

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

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

    
161
    public DataStore openStore(DynStruct struct)
162
            throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException;
163

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

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

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

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

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

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

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

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

    
281
    /*
282
     * ====================================================================
283
     *
284
     * Expression evaluation related services
285
     */
286
    /**
287
     * Registers the default expression evaluator. It is used by DAL to evaluate
288
     * and resolve query filters and expressions.
289
     *
290
     * @param evaluatorFactory
291
     */
292
    public void registerDefaultEvaluator(EvaluatorFactory evaluatorFactory);
293

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

    
304
    public Evaluator createExpresion(Expression expression)
305
            throws InitializeException;
306

    
307
    public EvaluatorFactory createEvaluatorFactory();
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
     * @return 
453
         *
454
         * @throws InitializeException
455
         *             if parameter initialization causes an error.
456
         *
457
         * @throws ProviderNotRegisteredException
458
         *             if could not find a cache provider by the given name.
459
         *
460
         */
461
        public DynObject createCacheParameters(String name)
462
                        throws InitializeException, ProviderNotRegisteredException;
463

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

    
472
    public FeatureSymbolTable createFeatureSymbolTable();
473
}