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

History | View | Annotate | Download (18.3 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 44253 jjdelcerro
import org.gvsig.tools.util.GetItemByKey;
53 40435 jjdelcerro
54
/**
55 43020 jjdelcerro
 * There are two top level management roles within DAL: data access and resource
56
 * management.
57 40435 jjdelcerro
 *
58 43020 jjdelcerro
 * 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 40435 jjdelcerro
 *
62
 * @see ResourceManager
63
 *
64
 */
65 43020 jjdelcerro
public interface DataManager extends Services {
66 40435 jjdelcerro
67 43020 jjdelcerro
    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 40435 jjdelcerro
71 44253 jjdelcerro
    public static final String  DAL_SYMBOL_TABLE = "DAL.SymbolTable";
72 43987 jjdelcerro
    public static final String  FEATURE_SYMBOL_TABLE = "DAL.FeatureSymbolTable";
73 44253 jjdelcerro
74 44259 jjdelcerro
    public static final String DAL_FOREING_CODE = "DAL.foreingCode";
75
    public static final String DAL_FOREING_TABLE = "DAL.foreingTable";
76
    public static final String DAL_FOREING_LABEL = "DAL.foreingLabel";
77
78
    public static final String DAL_FOREING_KEY = "DAL.ForeingKey";
79
    public static final String DAL_SELECTABLE_FOREING_KEY = "DAL.SelectableForeingKey";
80
81 43020 jjdelcerro
    /**
82
     * Returns the default DAL's temporary directory
83
     *
84
     * @return Temporary directory name
85 43241 jjdelcerro
     * @deprecated use FoldersManager of org.gvsig.tools
86 43020 jjdelcerro
     */
87
    public String getTemporaryDirectory();
88 40435 jjdelcerro
89 43020 jjdelcerro
    /*
90
     * ====================================================================
91
     *
92
     * Store related services
93
     */
94
    /**
95
     * Creates, initializes and returns an instance of DataStoreParameters given
96
     * the name with which their provider is registered.
97
     *
98
     * @param name provider name
99
     * @return the data store parameters
100
     *
101
     * @throws ProviderNotRegisteredException if the memory provider is not
102
     * registered
103
     * @throws InitializeException if there is an error initializing the
104
     * parameters for the memory provider
105
     *
106
     */
107
    public DataStoreParameters createStoreParameters(String name)
108
            throws InitializeException, ProviderNotRegisteredException;
109 40435 jjdelcerro
110 43020 jjdelcerro
    /**
111
     * Creates, initializes and fill an instance of DataStoreParameters from the
112
     * tags of the DynStruct passed as parameter.
113
     *
114
     * @param struct structure from which tags were created ths parameters.
115
     * @return the data store parameters
116
     *
117
     * @throws ProviderNotRegisteredException if the memory provider is not
118
     * registered
119
     * @throws InitializeException if there is an error initializing the
120
     * parameters for the memory provider
121
     *
122
     */
123
    public DataStoreParameters createStoreParameters(DynStruct struct)
124
            throws InitializeException, ProviderNotRegisteredException;
125 40435 jjdelcerro
126 43020 jjdelcerro
    public DataStoreParameters createStoreParameters(Tags tags) throws InitializeException, ProviderNotRegisteredException;
127 42778 jjdelcerro
128 43020 jjdelcerro
    /**
129
     * Creates, initializes and returns an instance of NewDataStoreParameters
130
     * given the name with which their provider is registered.
131
     *
132
     * @param explorer
133
     * @param provider
134
     * @return
135
     *
136
     * @throws InitializeException
137
     * @throws ProviderNotRegisteredException
138
     */
139
    public NewDataStoreParameters createNewStoreParameters(String explorer, String provider)
140
            throws InitializeException, ProviderNotRegisteredException;
141 40435 jjdelcerro
142 43020 jjdelcerro
    /**
143
     *
144
     * Creates, initializes and returns an instance of DataStore given the
145
     * DataStoreParameters.
146
     *
147
     * @param provider
148
     * @param parameters parameters used to instantiate and initialize the
149
     * DataStore
150
     * @return
151
     *
152
     * @throws ProviderNotRegisteredException if the memory provider is not
153
     * registered
154
     * @throws InitializeException if there is an error initializing the
155
     * parameters for the memory provider
156
     * @throws ValidateDataParametersException if the parameters to open the
157
     * memory based store are not valid
158
     */
159
    public DataStore openStore(String provider, DynObject parameters)
160
            throws InitializeException, ProviderNotRegisteredException,
161
            ValidateDataParametersException;
162 40435 jjdelcerro
163 43020 jjdelcerro
    public DataStore openStore(String provider, DataStoreParameters parameters)
164
            throws InitializeException, ProviderNotRegisteredException,
165
            ValidateDataParametersException;
166 42775 jjdelcerro
167 43093 jjdelcerro
    public DataStore openStore(
168 43205 fdiaz
            String providerName,
169
            Object... arguments)
170
        throws
171
            InitializeException,
172
            ProviderNotRegisteredException,
173
            ValidateDataParametersException;
174
175 43020 jjdelcerro
    public DataStore openStore(DynStruct struct)
176
            throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException;
177 42775 jjdelcerro
178 43020 jjdelcerro
    /**
179
     * Create a new physical store
180
     *
181
     * @param explorer
182
     * @param provider
183
     * @param parameters
184
     * @param overwrite
185
     *
186
     * @throws InitializeException
187
     * @throws ProviderNotRegisteredException
188
     * @throws ValidateDataParametersException
189
     */
190
    public void newStore(String explorer, String provider, NewDataStoreParameters parameters, boolean overwrite)
191
            throws InitializeException, ProviderNotRegisteredException,
192
            ValidateDataParametersException;
193 40435 jjdelcerro
194 43020 jjdelcerro
    /**
195
     * Returns a list of Strings containing the names of all available DataStore
196
     * providers.
197
     *
198
     * @return list of String containing available DataStore provider names
199
     */
200
    public List getStoreProviders();
201 42624 jjdelcerro
202 43020 jjdelcerro
    /**
203
     * Returns a list of Strings containing the names of all available DataStore
204
     * providers for an explorer.
205
     *
206
     * @param name
207
     * @return
208
     */
209
    public List<String> getStoreProviders(String name);
210 42624 jjdelcerro
211 43020 jjdelcerro
    /*
212
     * ====================================================================
213
     *
214
     * Explorer related services
215
     */
216
    /**
217
     * Returns an instance of {@link DataServerExplorerParameters} corresponding
218
     * to the given name.
219
     *
220
     * @param name name of a registered server explorer provider
221
     * @return
222
     *
223
     * @throws InitializeException if parameter initialization causes an error.
224
     *
225
     * @throws ProviderNotRegisteredException if could not find a provider by
226
     * the given name.
227
     *
228
     *
229
     */
230
    public DataServerExplorerParameters createServerExplorerParameters(
231
            String name)
232
            throws InitializeException, ProviderNotRegisteredException;
233 40435 jjdelcerro
234 43020 jjdelcerro
    /**
235
     * Returns an instance of {@link DataServerExplorer} given its parameters.
236
     *
237
     * @param name
238
     * @param parameters parameters used to instantiate and initialize the
239
     * {@link DataServerExplorer}.
240
     *
241
     * @return an instance of {@link DataServerExplorer}.
242
     *
243
     * @throws InitializeException
244
     *
245
     * @throws ProviderNotRegisteredException
246
     * @throws ValidateDataParametersException
247
     */
248
    public DataServerExplorer openServerExplorer(
249
            String name,
250
            DataServerExplorerParameters parameters)
251
            throws InitializeException, ProviderNotRegisteredException,
252
            ValidateDataParametersException;
253 43205 fdiaz
254 43093 jjdelcerro
    public DataServerExplorer openServerExplorer(
255 43205 fdiaz
            String explorerName,
256 43093 jjdelcerro
            Object... arguments)
257 43205 fdiaz
        throws
258
            InitializeException,
259
            ProviderNotRegisteredException,
260 43093 jjdelcerro
            ValidateDataParametersException;
261 43020 jjdelcerro
    /**
262 43045 jjdelcerro
     * @param parameters
263 43205 fdiaz
     * @return
264
     * @throws org.gvsig.fmap.dal.exception.InitializeException
265
     * @throws org.gvsig.fmap.dal.exception.ProviderNotRegisteredException
266
     * @throws org.gvsig.fmap.dal.exception.ValidateDataParametersException
267 43020 jjdelcerro
     * @deprecated see openServerExplorer
268
     */
269
    public DataServerExplorer createServerExplorer(
270
            DataServerExplorerParameters parameters)
271
            throws InitializeException, ProviderNotRegisteredException,
272
            ValidateDataParametersException;
273 43205 fdiaz
274 43020 jjdelcerro
    /**
275 43045 jjdelcerro
     * @param parameters
276 43205 fdiaz
     * @return
277
     * @throws org.gvsig.fmap.dal.exception.InitializeException
278
     * @throws org.gvsig.fmap.dal.exception.ProviderNotRegisteredException
279
     * @throws org.gvsig.fmap.dal.exception.ValidateDataParametersException
280 43045 jjdelcerro
     * @deprecated see openStore
281
     */
282
    public DataStore createStore(DataStoreParameters parameters)
283
            throws InitializeException, ProviderNotRegisteredException,
284
            ValidateDataParametersException;
285 43205 fdiaz
286 43045 jjdelcerro
    /**
287 43020 jjdelcerro
     * Returns a list of String containing the names of the available
288
     * DataServerExplorer providers.
289
     *
290
     * @return list of String containing the names of the available
291
     * DataServerExplorer providers.
292
     */
293
    public List<String> getExplorerProviders();
294 40435 jjdelcerro
295 44023 jjdelcerro
    /**
296
     * Creates an instance of Evaluator that represents the given expression.
297 43020 jjdelcerro
     *
298 44023 jjdelcerro
     * @param expression String containing a CQL expression.
299
     * @return instance of Evaluator representing the given expression.
300
     * @throws InitializeException
301
     * @deprecated use createFilter
302 43020 jjdelcerro
     */
303 44023 jjdelcerro
    public Evaluator createExpresion(String expression)
304
            throws InitializeException;
305
306 43020 jjdelcerro
    /**
307 44023 jjdelcerro
     * Creates an instance of Evaluator that represents the given expression.
308 43020 jjdelcerro
     *
309 44023 jjdelcerro
     * @param expression a Expression with the filter
310
     * @return instance of Evaluator representing the given expression.
311
     * @throws InitializeException
312
     * @deprecated use createFilter
313 43020 jjdelcerro
     */
314 44023 jjdelcerro
    public Evaluator createExpresion(Expression expression)
315
            throws InitializeException;
316 40435 jjdelcerro
317 43020 jjdelcerro
    /**
318
     * Creates an instance of Evaluator that represents the given expression.
319
     *
320
     * @param expression String containing a CQL expression.
321
     * @return instance of Evaluator representing the given expression.
322
     * @throws InitializeException
323
     */
324 44023 jjdelcerro
    public Evaluator createFilter(String expression)
325 43020 jjdelcerro
            throws InitializeException;
326 43205 fdiaz
327 44023 jjdelcerro
    /**
328
     * Creates an instance of Evaluator that represents the given expression.
329
     *
330
     * @param expression a Expression with the filter
331
     * @return instance of Evaluator representing the given expression.
332
     * @throws InitializeException
333
     */
334
    public Evaluator createFilter(Expression expression)
335 43984 jjdelcerro
            throws InitializeException;
336
337 43020 jjdelcerro
    /*
338
     * ====================================================================
339
     *
340
     * Index related services
341
     */
342
    /**
343
     * Returns a list of String containing the names of the available index
344
     * providers.
345
     *
346
     * @return list of strings with the names of the available index providers
347
     */
348
    public List<String> getFeatureIndexProviders();
349 40435 jjdelcerro
350 43020 jjdelcerro
    /**
351
     * Sets the default DataIndexProvider for the given data type.
352
     *
353
     * @param dataType one of the data types defined in {@link DataTypes}.
354
     * @param name Provider's name
355
     */
356 40435 jjdelcerro
    public void setDefaultFeatureIndexProviderName(int dataType, String name);
357
358 43020 jjdelcerro
    /**
359
     * Returns the default DataIndexProvider name, given a data type. Data types
360
     * are defined in {@link DataTypes}.
361
     *
362
     * @param dataType one of the constants in {@link DataTypes}.
363
     *
364
     * @return the name of the default {@link FeatureIndexProvider} if there is
365
     * anyone available for the given data type.
366
     */
367 40435 jjdelcerro
    public String getDefaultFeatureIndexProviderName(int dataType);
368
369
    /**
370 43020 jjdelcerro
     * Utility method to create the {@link DataStoreParameters} to create a
371
     * {@link FeatureStore} based on the {@link MemoryStoreProvider}.
372
     *
373
     * @param autoOrderAttributeName the name of the {@link Feature} attribute
374
     * to be used to order the store {@link Feature}s by default. Set to null if
375
     * you don't want any order by default
376
     * @return the parameters for the memory based store
377
     * @throws InitializeException if there is an error initializing the
378
     * parameters for the memory provider
379
     */
380
    public DataStoreParameters createMemoryStoreParameters(
381
            String autoOrderAttributeName) throws InitializeException;
382 40435 jjdelcerro
383 43020 jjdelcerro
    /**
384
     * Utility method to create the a {@link FeatureStore} based on the
385
     * {@link MemoryStoreProvider}.
386
     *
387
     * @param autoOrderAttributeName the name of the {@link Feature} attribute
388
     * to be used to order the store {@link Feature}s by default. Set to null if
389
     * you don't want any order by default
390
     * @return the the memory based store
391
     * @throws InitializeException if there is an error initializing the
392
     * parameters for the memory provider
393
     */
394
    public FeatureStore createMemoryStore(String autoOrderAttributeName)
395
            throws InitializeException;
396 40435 jjdelcerro
397
    /**
398
     * Creates a {@link FeaturePagingHelper} to paginate data from a
399
     * {@link FeatureStore}.
400 43020 jjdelcerro
     *
401
     * @param featureStore to get the {@link Feature}s from
402
     * @param pageSize the page size
403 40435 jjdelcerro
     * @return a {@link FeaturePagingHelper}
404 43020 jjdelcerro
     * @throws BaseException if there is an error creating the helper
405 40435 jjdelcerro
     */
406 43020 jjdelcerro
    public FeaturePagingHelper createFeaturePagingHelper(
407
            FeatureStore featureStore, int pageSize) throws BaseException;
408 40435 jjdelcerro
409 43020 jjdelcerro
    /**
410 40435 jjdelcerro
     * Creates a {@link FeaturePagingHelper} to paginate data from a
411
     * {@link FeatureStore}.
412 43020 jjdelcerro
     *
413
     * @param featureStore to get the {@link Feature}s from
414
     * @param featureQuery to filter and/or order the data
415
     * @param pageSize the page size
416 40435 jjdelcerro
     * @return a {@link FeaturePagingHelper}
417 43020 jjdelcerro
     * @throws BaseException if there is an error creating the helper
418 40435 jjdelcerro
     */
419 43020 jjdelcerro
    public FeaturePagingHelper createFeaturePagingHelper(
420
            FeatureStore featureStore, FeatureQuery featureQuery, int pageSize)
421
            throws BaseException;
422 40435 jjdelcerro
423 43020 jjdelcerro
    public void setOpenErrorHandler(OpenErrorHandler handler);
424 42775 jjdelcerro
425 43020 jjdelcerro
    public OpenErrorHandler getOpenErrorHandler();
426
427
    public DataStoreProviderFactory getStoreProviderFactory(String name);
428
429
    public EditableFeatureType createFeatureType();
430
431
    public DataServerExplorerPool getDataServerExplorerPool();
432
433
    public void setDataServerExplorerPool(DataServerExplorerPool pool);
434
435
    public void setResourcesLoader(ClassLoader loader);
436
437
    public void setResourcesLoader(File folder);
438
439
    /**
440
     * Return a list of the DataTypes supported for the type of the feature
441
     * attributes. The list is only informative.
442
     *
443
     * @return
444
     */
445
    public List<DataType> getDataTypes();
446
447
    public Register getStoreRegister();
448
449
    public Register getStoreProviderRegister();
450
451
    public Register getServerExplorerRegister();
452
453
    public Register getFeatureIndexRegister();
454 43040 jjdelcerro
455
    /**
456
     * Creates a default ExpressionBuilder.
457 43205 fdiaz
     *
458
     * This ExpressionBuilder is not dependent on a data source,
459 43040 jjdelcerro
     * and is not advisable to use it.
460 43205 fdiaz
     *
461 43040 jjdelcerro
     * @return the ExpressionBuilder
462 44023 jjdelcerro
     * @deprecated use ExpressionEvaluatorManager.createExpressionBuilder()
463 43040 jjdelcerro
     */
464
    public ExpressionBuilder createExpressionBuilder();
465 43205 fdiaz
466 43056 jjdelcerro
    /**
467
         * Returns a list of String containing the names of the available cache providers.
468
         *
469
         * @return
470
         *                 list of strings with the names of the available cache providers
471 43205 fdiaz
         */
472 43056 jjdelcerro
    public List getFeatureCacheProviders();
473
474
        /**
475
         * Returns an instance of {@link DataServerExplorerParameters} corresponding
476
         * to the given name used by the cache to create a store to save the
477
         * retrieved data.
478 43205 fdiaz
         *
479 43056 jjdelcerro
         * @param name
480
         *            name of a registered feature cache provider
481 43212 jjdelcerro
     * @return
482 43205 fdiaz
         *
483 43056 jjdelcerro
         * @throws InitializeException
484
         *             if parameter initialization causes an error.
485 43205 fdiaz
         *
486 43056 jjdelcerro
         * @throws ProviderNotRegisteredException
487
         *             if could not find a cache provider by the given name.
488 43205 fdiaz
         *
489 43056 jjdelcerro
         */
490
        public DynObject createCacheParameters(String name)
491
                        throws InitializeException, ProviderNotRegisteredException;
492 43205 fdiaz
493
    /**
494
     * @param providerName
495
     * @param params
496
     * @param overwrite
497
     * @throws DataException
498
     */
499 43212 jjdelcerro
    public void createFileStore(String providerName, NewDataStoreParameters params, boolean overwrite) throws DataException;
500 43205 fdiaz
501 43983 jjdelcerro
    public FeatureSymbolTable createFeatureSymbolTable();
502 43989 jjdelcerro
503
    public FeatureAttributeEmulatorExpression createFeatureAttributeEmulatorExpression(FeatureType type, Expression expression);
504 44128 jjdelcerro
505
    public void registerDataProfile(DataProfile profile);
506
507
    public List<DataProfile> getDataProfiles();
508
509
    public DataProfile getDataProfile(String name);
510 44253 jjdelcerro
511
    public StoresRepository getStoresRepository();
512
513
    public void addStoresRepository(String name, GetItemByKey<String,DataStoreParameters> repository);
514 40596 jjdelcerro
}