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

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