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

History | View | Annotate | Download (17.7 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

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

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

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

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

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

    
116
    public DataStoreParameters createStoreParameters(Tags tags) throws InitializeException, ProviderNotRegisteredException;
117

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

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

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

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

    
165
    public DataStore openStore(DynStruct struct)
166
            throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException;
167

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
413
    public void setOpenErrorHandler(OpenErrorHandler handler);
414

    
415
    public OpenErrorHandler getOpenErrorHandler();
416

    
417
    public DataStoreProviderFactory getStoreProviderFactory(String name);
418

    
419
    public EditableFeatureType createFeatureType();
420

    
421
    public DataServerExplorerPool getDataServerExplorerPool();
422

    
423
    public void setDataServerExplorerPool(DataServerExplorerPool pool);
424

    
425
    public void setResourcesLoader(ClassLoader loader);
426

    
427
    public void setResourcesLoader(File folder);
428

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

    
437
    public Register getStoreRegister();
438

    
439
    public Register getStoreProviderRegister();
440

    
441
    public Register getServerExplorerRegister();
442

    
443
    public Register getFeatureIndexRegister();
444

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

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

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

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

    
491
    public FeatureSymbolTable createFeatureSymbolTable();
492

    
493
    public FeatureAttributeEmulatorExpression createFeatureAttributeEmulatorExpression(FeatureType type, Expression expression);
494

    
495
    public void registerDataProfile(DataProfile profile);
496

    
497
    public List<DataProfile> getDataProfiles();
498

    
499
    public DataProfile getDataProfile(String name);
500
}