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

History | View | Annotate | Download (18.1 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
import org.gvsig.expressionevaluator.ExpressionBuilder;
29

    
30
import org.gvsig.fmap.dal.exception.DataException;
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.expressionevaluator.FeatureSymbolTable;
35
import org.gvsig.fmap.dal.feature.EditableFeatureType;
36
import org.gvsig.fmap.dal.feature.Feature;
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.FeatureType;
41
import org.gvsig.fmap.dal.feature.paging.FeaturePagingHelper;
42
import org.gvsig.fmap.dal.resource.ResourceManager;
43
import org.gvsig.tools.dataTypes.DataType;
44
import org.gvsig.tools.dynobject.DynObject;
45
import org.gvsig.tools.dynobject.DynStruct;
46
import org.gvsig.tools.dynobject.Tags;
47
import org.gvsig.tools.evaluator.Evaluator;
48
import org.gvsig.tools.exception.BaseException;
49
import org.gvsig.tools.service.spi.Services;
50
import org.gvsig.fmap.dal.expressionevaluator.FeatureAttributeEmulatorExpression;
51
import org.gvsig.fmap.dal.feature.DataProfile;
52
import org.gvsig.tools.util.UnmodifiableBasicMap;
53

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

    
67
    public static final String CREATE_STORE_AUTHORIZATION = "dal-create-store";
68
    public static final String READ_STORE_AUTHORIZATION = "dal-read-store";
69
    public static final String WRITE_STORE_AUTHORIZATION = "dal-write-store";
70

    
71
    public static final String DAL_SYMBOL_TABLE = "DAL.SymbolTable.Global";
72
    public static final String DAL_SYMBOL_TABLE_FEATURE = "DAL.SymbolTable.Feature";
73

    
74
    public static final String FUNCTION_FOREING_VALUE = "FOREING_VALUE";
75
    
76
    /**
77
     * 
78
     * Returns the default DAL's temporary directory
79
     *
80
     * @return Temporary directory name
81
     * @deprecated use FoldersManager of org.gvsig.tools
82
     */
83
    public String getTemporaryDirectory();
84

    
85
    /*
86
     * ====================================================================
87
     *
88
     * Store related services
89
     */
90
    /**
91
     * Creates, initializes and returns an instance of DataStoreParameters given
92
     * the name with which their provider is registered.
93
     *
94
     * @param name provider name
95
     * @return the data store parameters
96
     *
97
     * @throws ProviderNotRegisteredException if the memory provider is not
98
     * registered
99
     * @throws InitializeException if there is an error initializing the
100
     * parameters for the memory provider
101
     *
102
     */
103
    public DataStoreParameters createStoreParameters(String name)
104
            throws InitializeException, ProviderNotRegisteredException;
105

    
106
    public DataStoreParameters createStoreParameters(byte[] data);
107

    
108
    /**
109
     * Creates, initializes and fill an instance of DataStoreParameters from the
110
     * tags of the DynStruct passed as parameter.
111
     *
112
     * @param struct structure from which tags were created ths parameters.
113
     * @return the data store parameters
114
     *
115
     * @throws ProviderNotRegisteredException if the memory provider is not
116
     * registered
117
     * @throws InitializeException if there is an error initializing the
118
     * parameters for the memory provider
119
     *
120
     */
121
    public DataStoreParameters createStoreParameters(DynStruct struct)
122
            throws InitializeException, ProviderNotRegisteredException;
123

    
124
    public DataStoreParameters createStoreParameters(Tags tags) throws InitializeException, ProviderNotRegisteredException;
125

    
126
    /**
127
     * Creates, initializes and returns an instance of NewDataStoreParameters
128
     * given the name with which their provider is registered.
129
     *
130
     * @param explorer
131
     * @param provider
132
     * @return
133
     *
134
     * @throws InitializeException
135
     * @throws ProviderNotRegisteredException
136
     */
137
    public NewDataStoreParameters createNewStoreParameters(String explorer, String provider)
138
            throws InitializeException, ProviderNotRegisteredException;
139

    
140
    /**
141
     *
142
     * Creates, initializes and returns an instance of DataStore given the
143
     * DataStoreParameters.
144
     *
145
     * @param provider
146
     * @param parameters parameters used to instantiate and initialize the
147
     * DataStore
148
     * @return
149
     *
150
     * @throws ProviderNotRegisteredException if the memory provider is not
151
     * registered
152
     * @throws InitializeException if there is an error initializing the
153
     * parameters for the memory provider
154
     * @throws ValidateDataParametersException if the parameters to open the
155
     * memory based store are not valid
156
     */
157
    public DataStore openStore(String provider, DynObject parameters)
158
            throws InitializeException, ProviderNotRegisteredException,
159
            ValidateDataParametersException;
160

    
161
    public DataStore openStore(String provider, DataStoreParameters parameters)
162
            throws InitializeException, ProviderNotRegisteredException,
163
            ValidateDataParametersException;
164

    
165
    public DataStore openStore(
166
            String providerName,
167
            Object... arguments)
168
        throws
169
            InitializeException,
170
            ProviderNotRegisteredException,
171
            ValidateDataParametersException;
172

    
173
    public DataStore openStore(DynStruct struct)
174
            throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException;
175

    
176
    /**
177
     * Create a new physical store
178
     *
179
     * @param explorer
180
     * @param provider
181
     * @param parameters
182
     * @param overwrite
183
     *
184
     * @throws InitializeException
185
     * @throws ProviderNotRegisteredException
186
     * @throws ValidateDataParametersException
187
     */
188
    public void newStore(String explorer, String provider, NewDataStoreParameters parameters, boolean overwrite)
189
            throws InitializeException, ProviderNotRegisteredException,
190
            ValidateDataParametersException;
191

    
192
    /**
193
     * Returns a list of Strings containing the names of all available DataStore
194
     * providers.
195
     *
196
     * @return list of String containing available DataStore provider names
197
     */
198
    public List getStoreProviders();
199

    
200
    /**
201
     * Returns a list of Strings containing the names of all available DataStore
202
     * providers for an explorer.
203
     *
204
     * @param name
205
     * @return
206
     */
207
    public List<String> getStoreProviders(String name);
208

    
209
    /*
210
     * ====================================================================
211
     *
212
     * Explorer related services
213
     */
214
    /**
215
     * Returns an instance of {@link DataServerExplorerParameters} corresponding
216
     * to the given name.
217
     *
218
     * @param name name of a registered server explorer provider
219
     * @return
220
     *
221
     * @throws InitializeException if parameter initialization causes an error.
222
     *
223
     * @throws ProviderNotRegisteredException if could not find a provider by
224
     * the given name.
225
     *
226
     *
227
     */
228
    public DataServerExplorerParameters createServerExplorerParameters(
229
            String name)
230
            throws InitializeException, ProviderNotRegisteredException;
231

    
232
    /**
233
     * Returns an instance of {@link DataServerExplorer} given its parameters.
234
     *
235
     * @param name
236
     * @param parameters parameters used to instantiate and initialize the
237
     * {@link DataServerExplorer}.
238
     *
239
     * @return an instance of {@link DataServerExplorer}.
240
     *
241
     * @throws InitializeException
242
     *
243
     * @throws ProviderNotRegisteredException
244
     * @throws ValidateDataParametersException
245
     */
246
    public DataServerExplorer openServerExplorer(
247
            String name,
248
            DataServerExplorerParameters parameters)
249
            throws InitializeException, ProviderNotRegisteredException,
250
            ValidateDataParametersException;
251

    
252
    public DataServerExplorer openServerExplorer(
253
            String explorerName,
254
            Object... arguments)
255
        throws
256
            InitializeException,
257
            ProviderNotRegisteredException,
258
            ValidateDataParametersException;
259
    /**
260
     * @param parameters
261
     * @return
262
     * @throws org.gvsig.fmap.dal.exception.InitializeException
263
     * @throws org.gvsig.fmap.dal.exception.ProviderNotRegisteredException
264
     * @throws org.gvsig.fmap.dal.exception.ValidateDataParametersException
265
     * @deprecated see openServerExplorer
266
     */
267
    public DataServerExplorer createServerExplorer(
268
            DataServerExplorerParameters parameters)
269
            throws InitializeException, ProviderNotRegisteredException,
270
            ValidateDataParametersException;
271

    
272
    /**
273
     * @param parameters
274
     * @return
275
     * @throws org.gvsig.fmap.dal.exception.InitializeException
276
     * @throws org.gvsig.fmap.dal.exception.ProviderNotRegisteredException
277
     * @throws org.gvsig.fmap.dal.exception.ValidateDataParametersException
278
     * @deprecated see openStore
279
     */
280
    public DataStore createStore(DataStoreParameters parameters)
281
            throws InitializeException, ProviderNotRegisteredException,
282
            ValidateDataParametersException;
283

    
284
    /**
285
     * Returns a list of String containing the names of the available
286
     * DataServerExplorer providers.
287
     *
288
     * @return list of String containing the names of the available
289
     * DataServerExplorer providers.
290
     */
291
    public List<String> getExplorerProviders();
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
     * @deprecated use createFilter
300
     */
301
    public Evaluator createExpresion(String expression)
302
            throws InitializeException;
303

    
304
    /**
305
     * Creates an instance of Evaluator that represents the given expression.
306
     *
307
     * @param expression a Expression with the filter
308
     * @return instance of Evaluator representing the given expression.
309
     * @throws InitializeException
310
     * @deprecated use createFilter
311
     */
312
    public Evaluator createExpresion(Expression expression)
313
            throws InitializeException;
314

    
315
    /**
316
     * Creates an instance of Evaluator that represents the given expression.
317
     *
318
     * @param expression String containing a CQL expression.
319
     * @return instance of Evaluator representing the given expression.
320
     * @throws InitializeException
321
     */
322
    public Evaluator createFilter(String expression)
323
            throws InitializeException;
324

    
325
    /**
326
     * Creates an instance of Evaluator that represents the given expression.
327
     *
328
     * @param expression a Expression with the filter
329
     * @return instance of Evaluator representing the given expression.
330
     * @throws InitializeException
331
     */
332
    public Evaluator createFilter(Expression expression)
333
            throws InitializeException;
334

    
335
    /*
336
     * ====================================================================
337
     *
338
     * Index related services
339
     */
340
    /**
341
     * Returns a list of String containing the names of the available index
342
     * providers.
343
     *
344
     * @return list of strings with the names of the available index providers
345
     */
346
    public List<String> getFeatureIndexProviders();
347

    
348
    /**
349
     * Sets the default DataIndexProvider for the given data type.
350
     *
351
     * @param dataType one of the data types defined in {@link DataTypes}.
352
     * @param name Provider's name
353
     */
354
    public void setDefaultFeatureIndexProviderName(int dataType, String name);
355

    
356
    /**
357
     * Returns the default DataIndexProvider name, given a data type. Data types
358
     * are defined in {@link DataTypes}.
359
     *
360
     * @param dataType one of the constants in {@link DataTypes}.
361
     *
362
     * @return the name of the default {@link FeatureIndexProvider} if there is
363
     * anyone available for the given data type.
364
     */
365
    public String getDefaultFeatureIndexProviderName(int dataType);
366

    
367
    /**
368
     * Utility method to create the {@link DataStoreParameters} to create a
369
     * {@link FeatureStore} based on the {@link MemoryStoreProvider}.
370
     *
371
     * @param autoOrderAttributeName the name of the {@link Feature} attribute
372
     * to be used to order the store {@link Feature}s by default. Set to null if
373
     * you don't want any order by default
374
     * @return the parameters for the memory based store
375
     * @throws InitializeException if there is an error initializing the
376
     * parameters for the memory provider
377
     */
378
    public DataStoreParameters createMemoryStoreParameters(
379
            String autoOrderAttributeName) throws InitializeException;
380

    
381
    /**
382
     * Utility method to create the a {@link FeatureStore} based on the
383
     * {@link MemoryStoreProvider}.
384
     *
385
     * @param autoOrderAttributeName the name of the {@link Feature} attribute
386
     * to be used to order the store {@link Feature}s by default. Set to null if
387
     * you don't want any order by default
388
     * @return the the memory based store
389
     * @throws InitializeException if there is an error initializing the
390
     * parameters for the memory provider
391
     */
392
    public FeatureStore createMemoryStore(String autoOrderAttributeName)
393
            throws InitializeException;
394

    
395
    /**
396
     * Creates a {@link FeaturePagingHelper} to paginate data from a
397
     * {@link FeatureStore}.
398
     *
399
     * @param featureStore to get the {@link Feature}s from
400
     * @param pageSize the page size
401
     * @return a {@link FeaturePagingHelper}
402
     * @throws BaseException if there is an error creating the helper
403
     */
404
    public FeaturePagingHelper createFeaturePagingHelper(
405
            FeatureStore featureStore, int pageSize) throws BaseException;
406

    
407
    /**
408
     * Creates a {@link FeaturePagingHelper} to paginate data from a
409
     * {@link FeatureStore}.
410
     *
411
     * @param featureStore to get the {@link Feature}s from
412
     * @param featureQuery to filter and/or order the data
413
     * @param pageSize the page size
414
     * @return a {@link FeaturePagingHelper}
415
     * @throws BaseException if there is an error creating the helper
416
     */
417
    public FeaturePagingHelper createFeaturePagingHelper(
418
            FeatureStore featureStore, FeatureQuery featureQuery, int pageSize)
419
            throws BaseException;
420

    
421
    public void setOpenErrorHandler(OpenErrorHandler handler);
422

    
423
    public OpenErrorHandler getOpenErrorHandler();
424

    
425
    public DataStoreProviderFactory getStoreProviderFactory(String name);
426

    
427
    public EditableFeatureType createFeatureType();
428

    
429
    public DataServerExplorerPool getDataServerExplorerPool();
430

    
431
    public void setDataServerExplorerPool(DataServerExplorerPool pool);
432

    
433
    public void setResourcesLoader(ClassLoader loader);
434

    
435
    public void setResourcesLoader(File folder);
436

    
437
    /**
438
     * Return a list of the DataTypes supported for the type of the feature
439
     * attributes. The list is only informative.
440
     *
441
     * @return
442
     */
443
    public List<DataType> getDataTypes();
444

    
445
    public Register getStoreRegister();
446

    
447
    public Register getStoreProviderRegister();
448

    
449
    public Register getServerExplorerRegister();
450

    
451
    public Register getFeatureIndexRegister();
452

    
453
    /**
454
     * Creates a default ExpressionBuilder.
455
     *
456
     * This ExpressionBuilder is not dependent on a data source,
457
     * and is not advisable to use it.
458
     *
459
     * @return the ExpressionBuilder
460
     * @deprecated use ExpressionEvaluatorManager.createExpressionBuilder()
461
     */
462
    public ExpressionBuilder createExpressionBuilder();
463

    
464
    /**
465
         * Returns a list of String containing the names of the available cache providers.
466
         *
467
         * @return
468
         *                 list of strings with the names of the available cache providers
469
         */
470
    public List getFeatureCacheProviders();
471

    
472
        /**
473
         * Returns an instance of {@link DataServerExplorerParameters} corresponding
474
         * to the given name used by the cache to create a store to save the
475
         * retrieved data.
476
         *
477
         * @param name
478
         *            name of a registered feature cache provider
479
     * @return 
480
         *
481
         * @throws InitializeException
482
         *             if parameter initialization causes an error.
483
         *
484
         * @throws ProviderNotRegisteredException
485
         *             if could not find a cache provider by the given name.
486
         *
487
         */
488
        public DynObject createCacheParameters(String name)
489
                        throws InitializeException, ProviderNotRegisteredException;
490

    
491
    /**
492
     * @param providerName
493
     * @param params
494
     * @param overwrite
495
     * @throws DataException
496
     */
497
    public void createFileStore(String providerName, NewDataStoreParameters params, boolean overwrite) throws DataException;
498

    
499
    public FeatureSymbolTable createFeatureSymbolTable();
500

    
501
    public FeatureAttributeEmulatorExpression createFeatureAttributeEmulatorExpression(FeatureType type, Expression expression);
502

    
503
    public void registerDataProfile(DataProfile profile);
504

    
505
    public List<DataProfile> getDataProfiles();
506

    
507
    public DataProfile getDataProfile(String name);
508
    
509
    public StoresRepository getStoresRepository();
510
    
511
    public DatabaseWorkspaceManager createDatabaseWorkspaceManager(DataServerExplorerParameters connection);
512

    
513
}