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

History | View | Annotate | Download (18.3 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
    // Constant to manage ResourcesStorage in a DDBB.
77
    public static final String RESOURCES_TABLE_NAME = "gvsigd_resources";
78
    public static final String RESOURCES_FIELD_NAME = "name";
79
    public static final String RESOURCES_FIELD_RESOURCE = "resource";
80

    
81
    /**
82
     * 
83
     * Returns the default DAL's temporary directory
84
     *
85
     * @return Temporary directory name
86
     * @deprecated use FoldersManager of org.gvsig.tools
87
     */
88
    public String getTemporaryDirectory();
89

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

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

    
127
    public DataStoreParameters createStoreParameters(Tags tags) throws InitializeException, ProviderNotRegisteredException;
128

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

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

    
164
    public DataStore openStore(String provider, DataStoreParameters parameters)
165
            throws InitializeException, ProviderNotRegisteredException,
166
            ValidateDataParametersException;
167

    
168
    public DataStore openStore(
169
            String providerName,
170
            Object... arguments)
171
        throws
172
            InitializeException,
173
            ProviderNotRegisteredException,
174
            ValidateDataParametersException;
175

    
176
    public DataStore openStore(DynStruct struct)
177
            throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException;
178

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

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

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

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

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

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

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

    
287
    /**
288
     * Returns a list of String containing the names of the available
289
     * DataServerExplorer providers.
290
     *
291
     * @return list of String containing the names of the available
292
     * DataServerExplorer providers.
293
     */
294
    public List<String> getExplorerProviders();
295

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

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

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

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

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

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

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

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

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

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

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

    
424
    public void setOpenErrorHandler(OpenErrorHandler handler);
425

    
426
    public OpenErrorHandler getOpenErrorHandler();
427

    
428
    public DataStoreProviderFactory getStoreProviderFactory(String name);
429

    
430
    public EditableFeatureType createFeatureType();
431

    
432
    public DataServerExplorerPool getDataServerExplorerPool();
433

    
434
    public void setDataServerExplorerPool(DataServerExplorerPool pool);
435

    
436
    public void setResourcesLoader(ClassLoader loader);
437

    
438
    public void setResourcesLoader(File folder);
439

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

    
448
    public Register getStoreRegister();
449

    
450
    public Register getStoreProviderRegister();
451

    
452
    public Register getServerExplorerRegister();
453

    
454
    public Register getFeatureIndexRegister();
455

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

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

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

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

    
502
    public FeatureSymbolTable createFeatureSymbolTable();
503

    
504
    public FeatureAttributeEmulatorExpression createFeatureAttributeEmulatorExpression(FeatureType type, Expression expression);
505

    
506
    public void registerDataProfile(DataProfile profile);
507

    
508
    public List<DataProfile> getDataProfiles();
509

    
510
    public DataProfile getDataProfile(String name);
511
    
512
    public StoresRepository getStoresRepository();
513
    
514
    public void addStoresRepository(String name, UnmodifiableBasicMap<String,DataStoreParameters> repository);
515
}