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

History | View | Annotate | Download (17.7 KB)

1 40559 jjdelcerro
/**
2
 * gvSIG. Desktop Geographic Information System.
3 40435 jjdelcerro
 *
4 40559 jjdelcerro
 * Copyright (C) 2007-2013 gvSIG Association.
5 40435 jjdelcerro
 *
6 43020 jjdelcerro
 * 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 40435 jjdelcerro
 *
11 43020 jjdelcerro
 * 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 40435 jjdelcerro
 *
16 43020 jjdelcerro
 * 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 40435 jjdelcerro
 *
20 43020 jjdelcerro
 * For any additional information, do not hesitate to contact us at info AT
21
 * gvsig.com, or visit our website www.gvsig.com.
22 40435 jjdelcerro
 */
23
package org.gvsig.fmap.dal;
24
25 43020 jjdelcerro
import java.io.File;
26 40435 jjdelcerro
import java.util.List;
27 43984 jjdelcerro
import org.gvsig.expressionevaluator.Expression;
28 44042 jjdelcerro
import org.gvsig.expressionevaluator.ExpressionBuilder;
29 40435 jjdelcerro
30 43205 fdiaz
import org.gvsig.fmap.dal.exception.DataException;
31 40435 jjdelcerro
import org.gvsig.fmap.dal.exception.InitializeException;
32
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
33
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
34 43983 jjdelcerro
import org.gvsig.fmap.dal.expressionevaluator.FeatureSymbolTable;
35 40435 jjdelcerro
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 43989 jjdelcerro
import org.gvsig.fmap.dal.feature.FeatureType;
41 40435 jjdelcerro
import org.gvsig.fmap.dal.feature.paging.FeaturePagingHelper;
42 42775 jjdelcerro
import org.gvsig.fmap.dal.resource.ResourceManager;
43 43020 jjdelcerro
import org.gvsig.tools.dataTypes.DataType;
44 40435 jjdelcerro
import org.gvsig.tools.dynobject.DynObject;
45 42775 jjdelcerro
import org.gvsig.tools.dynobject.DynStruct;
46 42778 jjdelcerro
import org.gvsig.tools.dynobject.Tags;
47 40435 jjdelcerro
import org.gvsig.tools.evaluator.Evaluator;
48
import org.gvsig.tools.exception.BaseException;
49 43020 jjdelcerro
import org.gvsig.tools.service.spi.Services;
50 43989 jjdelcerro
import org.gvsig.fmap.dal.expressionevaluator.FeatureAttributeEmulatorExpression;
51 44128 jjdelcerro
import org.gvsig.fmap.dal.feature.DataProfile;
52 40435 jjdelcerro
53
/**
54 43020 jjdelcerro
 * There are two top level management roles within DAL: data access and resource
55
 * management.
56 40435 jjdelcerro
 *
57 43020 jjdelcerro
 * 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 40435 jjdelcerro
 *
61
 * @see ResourceManager
62
 *
63
 */
64 43020 jjdelcerro
public interface DataManager extends Services {
65 40435 jjdelcerro
66 43020 jjdelcerro
    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 40435 jjdelcerro
70 43987 jjdelcerro
    public static final String  FEATURE_SYMBOL_TABLE = "DAL.FeatureSymbolTable";
71 43020 jjdelcerro
    /**
72
     * Returns the default DAL's temporary directory
73
     *
74
     * @return Temporary directory name
75 43241 jjdelcerro
     * @deprecated use FoldersManager of org.gvsig.tools
76 43020 jjdelcerro
     */
77
    public String getTemporaryDirectory();
78 40435 jjdelcerro
79 43020 jjdelcerro
    /*
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 40435 jjdelcerro
100 43020 jjdelcerro
    /**
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 40435 jjdelcerro
116 43020 jjdelcerro
    public DataStoreParameters createStoreParameters(Tags tags) throws InitializeException, ProviderNotRegisteredException;
117 42778 jjdelcerro
118 43020 jjdelcerro
    /**
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 40435 jjdelcerro
132 43020 jjdelcerro
    /**
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 40435 jjdelcerro
153 43020 jjdelcerro
    public DataStore openStore(String provider, DataStoreParameters parameters)
154
            throws InitializeException, ProviderNotRegisteredException,
155
            ValidateDataParametersException;
156 42775 jjdelcerro
157 43093 jjdelcerro
    public DataStore openStore(
158 43205 fdiaz
            String providerName,
159
            Object... arguments)
160
        throws
161
            InitializeException,
162
            ProviderNotRegisteredException,
163
            ValidateDataParametersException;
164
165 43020 jjdelcerro
    public DataStore openStore(DynStruct struct)
166
            throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException;
167 42775 jjdelcerro
168 43020 jjdelcerro
    /**
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 40435 jjdelcerro
184 43020 jjdelcerro
    /**
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 42624 jjdelcerro
192 43020 jjdelcerro
    /**
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 42624 jjdelcerro
201 43020 jjdelcerro
    /*
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 40435 jjdelcerro
224 43020 jjdelcerro
    /**
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 43205 fdiaz
244 43093 jjdelcerro
    public DataServerExplorer openServerExplorer(
245 43205 fdiaz
            String explorerName,
246 43093 jjdelcerro
            Object... arguments)
247 43205 fdiaz
        throws
248
            InitializeException,
249
            ProviderNotRegisteredException,
250 43093 jjdelcerro
            ValidateDataParametersException;
251 43020 jjdelcerro
    /**
252 43045 jjdelcerro
     * @param parameters
253 43205 fdiaz
     * @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 43020 jjdelcerro
     * @deprecated see openServerExplorer
258
     */
259
    public DataServerExplorer createServerExplorer(
260
            DataServerExplorerParameters parameters)
261
            throws InitializeException, ProviderNotRegisteredException,
262
            ValidateDataParametersException;
263 43205 fdiaz
264 43020 jjdelcerro
    /**
265 43045 jjdelcerro
     * @param parameters
266 43205 fdiaz
     * @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 43045 jjdelcerro
     * @deprecated see openStore
271
     */
272
    public DataStore createStore(DataStoreParameters parameters)
273
            throws InitializeException, ProviderNotRegisteredException,
274
            ValidateDataParametersException;
275 43205 fdiaz
276 43045 jjdelcerro
    /**
277 43020 jjdelcerro
     * 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 40435 jjdelcerro
285 44023 jjdelcerro
    /**
286
     * Creates an instance of Evaluator that represents the given expression.
287 43020 jjdelcerro
     *
288 44023 jjdelcerro
     * @param expression String containing a CQL expression.
289
     * @return instance of Evaluator representing the given expression.
290
     * @throws InitializeException
291
     * @deprecated use createFilter
292 43020 jjdelcerro
     */
293 44023 jjdelcerro
    public Evaluator createExpresion(String expression)
294
            throws InitializeException;
295
296 43020 jjdelcerro
    /**
297 44023 jjdelcerro
     * Creates an instance of Evaluator that represents the given expression.
298 43020 jjdelcerro
     *
299 44023 jjdelcerro
     * @param expression a Expression with the filter
300
     * @return instance of Evaluator representing the given expression.
301
     * @throws InitializeException
302
     * @deprecated use createFilter
303 43020 jjdelcerro
     */
304 44023 jjdelcerro
    public Evaluator createExpresion(Expression expression)
305
            throws InitializeException;
306 40435 jjdelcerro
307 43020 jjdelcerro
    /**
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 44023 jjdelcerro
    public Evaluator createFilter(String expression)
315 43020 jjdelcerro
            throws InitializeException;
316 43205 fdiaz
317 44023 jjdelcerro
    /**
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 43984 jjdelcerro
            throws InitializeException;
326
327 43020 jjdelcerro
    /*
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 40435 jjdelcerro
340 43020 jjdelcerro
    /**
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 40435 jjdelcerro
    public void setDefaultFeatureIndexProviderName(int dataType, String name);
347
348 43020 jjdelcerro
    /**
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 40435 jjdelcerro
    public String getDefaultFeatureIndexProviderName(int dataType);
358
359
    /**
360 43020 jjdelcerro
     * 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 40435 jjdelcerro
373 43020 jjdelcerro
    /**
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 40435 jjdelcerro
387
    /**
388
     * Creates a {@link FeaturePagingHelper} to paginate data from a
389
     * {@link FeatureStore}.
390 43020 jjdelcerro
     *
391
     * @param featureStore to get the {@link Feature}s from
392
     * @param pageSize the page size
393 40435 jjdelcerro
     * @return a {@link FeaturePagingHelper}
394 43020 jjdelcerro
     * @throws BaseException if there is an error creating the helper
395 40435 jjdelcerro
     */
396 43020 jjdelcerro
    public FeaturePagingHelper createFeaturePagingHelper(
397
            FeatureStore featureStore, int pageSize) throws BaseException;
398 40435 jjdelcerro
399 43020 jjdelcerro
    /**
400 40435 jjdelcerro
     * Creates a {@link FeaturePagingHelper} to paginate data from a
401
     * {@link FeatureStore}.
402 43020 jjdelcerro
     *
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 40435 jjdelcerro
     * @return a {@link FeaturePagingHelper}
407 43020 jjdelcerro
     * @throws BaseException if there is an error creating the helper
408 40435 jjdelcerro
     */
409 43020 jjdelcerro
    public FeaturePagingHelper createFeaturePagingHelper(
410
            FeatureStore featureStore, FeatureQuery featureQuery, int pageSize)
411
            throws BaseException;
412 40435 jjdelcerro
413 43020 jjdelcerro
    public void setOpenErrorHandler(OpenErrorHandler handler);
414 42775 jjdelcerro
415 43020 jjdelcerro
    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 43040 jjdelcerro
445
    /**
446
     * Creates a default ExpressionBuilder.
447 43205 fdiaz
     *
448
     * This ExpressionBuilder is not dependent on a data source,
449 43040 jjdelcerro
     * and is not advisable to use it.
450 43205 fdiaz
     *
451 43040 jjdelcerro
     * @return the ExpressionBuilder
452 44023 jjdelcerro
     * @deprecated use ExpressionEvaluatorManager.createExpressionBuilder()
453 43040 jjdelcerro
     */
454
    public ExpressionBuilder createExpressionBuilder();
455 43205 fdiaz
456 43056 jjdelcerro
    /**
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 43205 fdiaz
         */
462 43056 jjdelcerro
    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 43205 fdiaz
         *
469 43056 jjdelcerro
         * @param name
470
         *            name of a registered feature cache provider
471 43212 jjdelcerro
     * @return
472 43205 fdiaz
         *
473 43056 jjdelcerro
         * @throws InitializeException
474
         *             if parameter initialization causes an error.
475 43205 fdiaz
         *
476 43056 jjdelcerro
         * @throws ProviderNotRegisteredException
477
         *             if could not find a cache provider by the given name.
478 43205 fdiaz
         *
479 43056 jjdelcerro
         */
480
        public DynObject createCacheParameters(String name)
481
                        throws InitializeException, ProviderNotRegisteredException;
482 43205 fdiaz
483
    /**
484
     * @param providerName
485
     * @param params
486
     * @param overwrite
487
     * @throws DataException
488
     */
489 43212 jjdelcerro
    public void createFileStore(String providerName, NewDataStoreParameters params, boolean overwrite) throws DataException;
490 43205 fdiaz
491 43983 jjdelcerro
    public FeatureSymbolTable createFeatureSymbolTable();
492 43989 jjdelcerro
493
    public FeatureAttributeEmulatorExpression createFeatureAttributeEmulatorExpression(FeatureType type, Expression expression);
494 44128 jjdelcerro
495
    public void registerDataProfile(DataProfile profile);
496
497
    public List<DataProfile> getDataProfiles();
498
499
    public DataProfile getDataProfile(String name);
500 40596 jjdelcerro
}