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

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

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

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

    
60
    public static final String CREATE_STORE_AUTHORIZATION = "dal-create-store";
61
    public static final String READ_STORE_AUTHORIZATION = "dal-read-store";
62
    public static final String WRITE_STORE_AUTHORIZATION = "dal-write-store";
63

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

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

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

    
109
    public DataStoreParameters createStoreParameters(Tags tags) throws InitializeException, ProviderNotRegisteredException;
110

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

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

    
146
    public DataStore openStore(String provider, DataStoreParameters parameters)
147
            throws InitializeException, ProviderNotRegisteredException,
148
            ValidateDataParametersException;
149

    
150
    public DataStore openStore(
151
            String providerName,
152
            Object... arguments)
153
        throws
154
            InitializeException,
155
            ProviderNotRegisteredException,
156
            ValidateDataParametersException;
157

    
158
    public DataStore openStore(DynStruct struct)
159
            throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException;
160

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

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

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

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

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

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

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

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

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

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

    
301
    /*
302
     * ====================================================================
303
     *
304
     * Index related services
305
     */
306
    /**
307
     * Returns a list of String containing the names of the available index
308
     * providers.
309
     *
310
     * @return list of strings with the names of the available index providers
311
     */
312
    public List<String> getFeatureIndexProviders();
313

    
314
    /**
315
     * Sets the default DataIndexProvider for the given data type.
316
     *
317
     * @param dataType one of the data types defined in {@link DataTypes}.
318
     * @param name Provider's name
319
     */
320
    public void setDefaultFeatureIndexProviderName(int dataType, String name);
321

    
322
    /**
323
     * Returns the default DataIndexProvider name, given a data type. Data types
324
     * are defined in {@link DataTypes}.
325
     *
326
     * @param dataType one of the constants in {@link DataTypes}.
327
     *
328
     * @return the name of the default {@link FeatureIndexProvider} if there is
329
     * anyone available for the given data type.
330
     */
331
    public String getDefaultFeatureIndexProviderName(int dataType);
332

    
333
    /**
334
     * Utility method to create the {@link DataStoreParameters} to create a
335
     * {@link FeatureStore} based on the {@link MemoryStoreProvider}.
336
     *
337
     * @param autoOrderAttributeName the name of the {@link Feature} attribute
338
     * to be used to order the store {@link Feature}s by default. Set to null if
339
     * you don't want any order by default
340
     * @return the parameters for the memory based store
341
     * @throws InitializeException if there is an error initializing the
342
     * parameters for the memory provider
343
     */
344
    public DataStoreParameters createMemoryStoreParameters(
345
            String autoOrderAttributeName) throws InitializeException;
346

    
347
    /**
348
     * Utility method to create the a {@link FeatureStore} based on the
349
     * {@link MemoryStoreProvider}.
350
     *
351
     * @param autoOrderAttributeName the name of the {@link Feature} attribute
352
     * to be used to order the store {@link Feature}s by default. Set to null if
353
     * you don't want any order by default
354
     * @return the the memory based store
355
     * @throws InitializeException if there is an error initializing the
356
     * parameters for the memory provider
357
     */
358
    public FeatureStore createMemoryStore(String autoOrderAttributeName)
359
            throws InitializeException;
360

    
361
    /**
362
     * Creates a {@link FeaturePagingHelper} to paginate data from a
363
     * {@link FeatureStore}.
364
     *
365
     * @param featureStore to get the {@link Feature}s from
366
     * @param pageSize the page size
367
     * @return a {@link FeaturePagingHelper}
368
     * @throws BaseException if there is an error creating the helper
369
     */
370
    public FeaturePagingHelper createFeaturePagingHelper(
371
            FeatureStore featureStore, int pageSize) throws BaseException;
372

    
373
    /**
374
     * Creates a {@link FeaturePagingHelper} to paginate data from a
375
     * {@link FeatureStore}.
376
     *
377
     * @param featureStore to get the {@link Feature}s from
378
     * @param featureQuery to filter and/or order the data
379
     * @param pageSize the page size
380
     * @return a {@link FeaturePagingHelper}
381
     * @throws BaseException if there is an error creating the helper
382
     */
383
    public FeaturePagingHelper createFeaturePagingHelper(
384
            FeatureStore featureStore, FeatureQuery featureQuery, int pageSize)
385
            throws BaseException;
386

    
387
    public void setOpenErrorHandler(OpenErrorHandler handler);
388

    
389
    public OpenErrorHandler getOpenErrorHandler();
390

    
391
    public DataStoreProviderFactory getStoreProviderFactory(String name);
392

    
393
    public EditableFeatureType createFeatureType();
394

    
395
    public DataServerExplorerPool getDataServerExplorerPool();
396

    
397
    public void setDataServerExplorerPool(DataServerExplorerPool pool);
398

    
399
    public void setResourcesLoader(ClassLoader loader);
400

    
401
    public void setResourcesLoader(File folder);
402

    
403
    /**
404
     * Return a list of the DataTypes supported for the type of the feature
405
     * attributes. The list is only informative.
406
     *
407
     * @return
408
     */
409
    public List<DataType> getDataTypes();
410

    
411
    public Register getStoreRegister();
412

    
413
    public Register getStoreProviderRegister();
414

    
415
    public Register getServerExplorerRegister();
416

    
417
    public Register getFeatureIndexRegister();
418

    
419
    /**
420
     * Creates a default ExpressionBuilder.
421
     *
422
     * This ExpressionBuilder is not dependent on a data source,
423
     * and is not advisable to use it.
424
     *
425
     * @return the ExpressionBuilder
426
     */
427
    public ExpressionBuilder createExpressionBuilder();
428

    
429
    /**
430
         * Returns a list of String containing the names of the available cache providers.
431
         *
432
         * @return
433
         *                 list of strings with the names of the available cache providers
434
         */
435
    public List getFeatureCacheProviders();
436

    
437
        /**
438
         * Returns an instance of {@link DataServerExplorerParameters} corresponding
439
         * to the given name used by the cache to create a store to save the
440
         * retrieved data.
441
         *
442
         * @param name
443
         *            name of a registered feature cache provider
444
     * @return 
445
         *
446
         * @throws InitializeException
447
         *             if parameter initialization causes an error.
448
         *
449
         * @throws ProviderNotRegisteredException
450
         *             if could not find a cache provider by the given name.
451
         *
452
         */
453
        public DynObject createCacheParameters(String name)
454
                        throws InitializeException, ProviderNotRegisteredException;
455

    
456
    /**
457
     * @param providerName
458
     * @param params
459
     * @param overwrite
460
     * @throws DataException
461
     */
462
    public void createFileStore(String providerName, NewDataStoreParameters params, boolean overwrite) throws DataException;
463

    
464
}