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

History | View | Annotate | Download (17.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
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.FeatureType;
40
import org.gvsig.fmap.dal.feature.paging.FeaturePagingHelper;
41
import org.gvsig.fmap.dal.resource.ResourceManager;
42
import org.gvsig.tools.dataTypes.DataType;
43
import org.gvsig.tools.dynobject.DynObject;
44
import org.gvsig.tools.dynobject.DynStruct;
45
import org.gvsig.tools.dynobject.Tags;
46
import org.gvsig.tools.evaluator.Evaluator;
47
import org.gvsig.tools.exception.BaseException;
48
import org.gvsig.tools.service.spi.Services;
49
import org.gvsig.fmap.dal.expressionevaluator.FeatureAttributeEmulatorExpression;
50

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

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

    
68
    public static final String  FEATURE_SYMBOL_TABLE = "DAL.FeatureSymbolTable";
69
    /**
70
     * Returns the default DAL's temporary directory
71
     *
72
     * @return Temporary directory name
73
     * @deprecated use FoldersManager of org.gvsig.tools
74
     */
75
    public String getTemporaryDirectory();
76

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

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

    
114
    public DataStoreParameters createStoreParameters(Tags tags) throws InitializeException, ProviderNotRegisteredException;
115

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

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

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

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

    
163
    public DataStore openStore(DynStruct struct)
164
            throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException;
165

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

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

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

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

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

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

    
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 openStore
269
     */
270
    public DataStore createStore(DataStoreParameters parameters)
271
            throws InitializeException, ProviderNotRegisteredException,
272
            ValidateDataParametersException;
273

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

    
283
    /**
284
     * Creates an instance of Evaluator that represents the given expression.
285
     *
286
     * @param expression String containing a CQL expression.
287
     * @return instance of Evaluator representing the given expression.
288
     * @throws InitializeException
289
     * @deprecated use createFilter
290
     */
291
    public Evaluator createExpresion(String expression)
292
            throws InitializeException;
293

    
294
    /**
295
     * Creates an instance of Evaluator that represents the given expression.
296
     *
297
     * @param expression a Expression with the filter
298
     * @return instance of Evaluator representing the given expression.
299
     * @throws InitializeException
300
     * @deprecated use createFilter
301
     */
302
    public Evaluator createExpresion(Expression expression)
303
            throws InitializeException;
304

    
305
    /**
306
     * Creates an instance of Evaluator that represents the given expression.
307
     *
308
     * @param expression String containing a CQL expression.
309
     * @return instance of Evaluator representing the given expression.
310
     * @throws InitializeException
311
     */
312
    public Evaluator createFilter(String expression)
313
            throws InitializeException;
314

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

    
325
    /*
326
     * ====================================================================
327
     *
328
     * Index related services
329
     */
330
    /**
331
     * Returns a list of String containing the names of the available index
332
     * providers.
333
     *
334
     * @return list of strings with the names of the available index providers
335
     */
336
    public List<String> getFeatureIndexProviders();
337

    
338
    /**
339
     * Sets the default DataIndexProvider for the given data type.
340
     *
341
     * @param dataType one of the data types defined in {@link DataTypes}.
342
     * @param name Provider's name
343
     */
344
    public void setDefaultFeatureIndexProviderName(int dataType, String name);
345

    
346
    /**
347
     * Returns the default DataIndexProvider name, given a data type. Data types
348
     * are defined in {@link DataTypes}.
349
     *
350
     * @param dataType one of the constants in {@link DataTypes}.
351
     *
352
     * @return the name of the default {@link FeatureIndexProvider} if there is
353
     * anyone available for the given data type.
354
     */
355
    public String getDefaultFeatureIndexProviderName(int dataType);
356

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

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

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

    
397
    /**
398
     * Creates a {@link FeaturePagingHelper} to paginate data from a
399
     * {@link FeatureStore}.
400
     *
401
     * @param featureStore to get the {@link Feature}s from
402
     * @param featureQuery to filter and/or order the data
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, FeatureQuery featureQuery, int pageSize)
409
            throws BaseException;
410

    
411
    public void setOpenErrorHandler(OpenErrorHandler handler);
412

    
413
    public OpenErrorHandler getOpenErrorHandler();
414

    
415
    public DataStoreProviderFactory getStoreProviderFactory(String name);
416

    
417
    public EditableFeatureType createFeatureType();
418

    
419
    public DataServerExplorerPool getDataServerExplorerPool();
420

    
421
    public void setDataServerExplorerPool(DataServerExplorerPool pool);
422

    
423
    public void setResourcesLoader(ClassLoader loader);
424

    
425
    public void setResourcesLoader(File folder);
426

    
427
    /**
428
     * Return a list of the DataTypes supported for the type of the feature
429
     * attributes. The list is only informative.
430
     *
431
     * @return
432
     */
433
    public List<DataType> getDataTypes();
434

    
435
    public Register getStoreRegister();
436

    
437
    public Register getStoreProviderRegister();
438

    
439
    public Register getServerExplorerRegister();
440

    
441
    public Register getFeatureIndexRegister();
442

    
443
    /**
444
     * Creates a default ExpressionBuilder.
445
     *
446
     * This ExpressionBuilder is not dependent on a data source,
447
     * and is not advisable to use it.
448
     *
449
     * @return the ExpressionBuilder
450
     * @deprecated use ExpressionEvaluatorManager.createExpressionBuilder()
451
     */
452
    public ExpressionBuilder createExpressionBuilder();
453

    
454
    /**
455
         * Returns a list of String containing the names of the available cache providers.
456
         *
457
         * @return
458
         *                 list of strings with the names of the available cache providers
459
         */
460
    public List getFeatureCacheProviders();
461

    
462
        /**
463
         * Returns an instance of {@link DataServerExplorerParameters} corresponding
464
         * to the given name used by the cache to create a store to save the
465
         * retrieved data.
466
         *
467
         * @param name
468
         *            name of a registered feature cache provider
469
     * @return 
470
         *
471
         * @throws InitializeException
472
         *             if parameter initialization causes an error.
473
         *
474
         * @throws ProviderNotRegisteredException
475
         *             if could not find a cache provider by the given name.
476
         *
477
         */
478
        public DynObject createCacheParameters(String name)
479
                        throws InitializeException, ProviderNotRegisteredException;
480

    
481
    /**
482
     * @param providerName
483
     * @param params
484
     * @param overwrite
485
     * @throws DataException
486
     */
487
    public void createFileStore(String providerName, NewDataStoreParameters params, boolean overwrite) throws DataException;
488

    
489
    public FeatureSymbolTable createFeatureSymbolTable();
490

    
491
    public FeatureAttributeEmulatorExpression createFeatureAttributeEmulatorExpression(FeatureType type, Expression expression);
492
}