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

History | View | Annotate | Download (19.8 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.DALExpressionBuilder;
35
import org.gvsig.fmap.dal.expressionevaluator.FeatureSymbolTable;
36
import org.gvsig.fmap.dal.feature.EditableFeatureType;
37
import org.gvsig.fmap.dal.feature.Feature;
38
import org.gvsig.fmap.dal.feature.FeatureIndex;
39
import org.gvsig.fmap.dal.feature.FeatureQuery;
40
import org.gvsig.fmap.dal.feature.FeatureStore;
41
import org.gvsig.fmap.dal.feature.FeatureType;
42
import org.gvsig.fmap.dal.feature.paging.FeaturePagingHelper;
43
import org.gvsig.fmap.dal.resource.ResourceManager;
44
import org.gvsig.tools.dataTypes.DataType;
45
import org.gvsig.tools.dynobject.DynObject;
46
import org.gvsig.tools.dynobject.DynStruct;
47
import org.gvsig.tools.dynobject.Tags;
48
import org.gvsig.tools.evaluator.Evaluator;
49
import org.gvsig.tools.exception.BaseException;
50
import org.gvsig.tools.service.spi.Services;
51
import org.gvsig.fmap.dal.expressionevaluator.FeatureAttributeEmulatorExpression;
52
import org.gvsig.fmap.dal.feature.DataProfile;
53
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
54
import org.gvsig.tools.resourcesstorage.ResourcesStorage;
55

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

    
69
    public static final String CREATE_STORE_AUTHORIZATION = "dal-create-store";
70
    public static final String READ_STORE_AUTHORIZATION = "dal-read-store";
71
    public static final String WRITE_STORE_AUTHORIZATION = "dal-write-store";
72

    
73
    public static final String DAL_SYMBOL_TABLE = "DAL.SymbolTable.Global";
74
//    public static final String DAL_SYMBOL_TABLE_FEATURE = "DAL.SymbolTable.Feature";
75

    
76
    public static final String FUNCTION_FOREING_VALUE = "FOREING_VALUE";
77
    public static final String FUNCTION_SELECT = "SELECT";
78
    public static final String FUNCTION_SELECT_COUNT = "SELECT_COUNT";
79
    public static final String FUNCTION_EXISTS = "EXISTS";
80
    public static final String FUNCTION_CURRENT_ROW = "CURRENT_ROW";
81
    public static final String FUNCTION_CURRENT_STORE = "CURRENT_STORE";
82
    public static final String FUNCTION_ISSELECTED_CURRENT_ROW = "ISSELECTED_CURRENT_ROW";
83
    
84
    public static final String DAL_PREFERRED_COLUMNS = "DAL.Preferred.Columns";
85
    
86
    public static final String DAL_USE_LABELS = "DAL.useLabels";
87
    public static final int USE_LABELS_YES = 0;
88
    public static final int USE_LABELS_NO = 1;
89
    public static final int USE_LABELS_BOTH = 2;
90
    
91
    /**
92
     * 
93
     * Returns the default DAL's temporary directory
94
     *
95
     * @return Temporary directory name
96
     * @deprecated use FoldersManager of org.gvsig.tools
97
     */
98
    public String getTemporaryDirectory();
99

    
100
    /*
101
     * ====================================================================
102
     *
103
     * Store related services
104
     */
105
    /**
106
     * Creates, initializes and returns an instance of DataStoreParameters given
107
     * the name with which their provider is registered.
108
     *
109
     * @param name provider name
110
     * @return the data store parameters
111
     *
112
     * @throws ProviderNotRegisteredException if the memory provider is not
113
     * registered
114
     * @throws InitializeException if there is an error initializing the
115
     * parameters for the memory provider
116
     *
117
     */
118
    public DataStoreParameters createStoreParameters(String name, Object... arguments)
119
            throws InitializeException, ProviderNotRegisteredException;
120

    
121
    public DataStoreParameters createStoreParameters(byte[] data);
122

    
123
    /**
124
     * Creates, initializes and fill an instance of DataStoreParameters from the
125
     * tags of the DynStruct passed as parameter.
126
     *
127
     * @param struct structure from which tags were created ths parameters.
128
     * @return the data store parameters
129
     *
130
     * @throws ProviderNotRegisteredException if the memory provider is not
131
     * registered
132
     * @throws InitializeException if there is an error initializing the
133
     * parameters for the memory provider
134
     *
135
     */
136
    public DataStoreParameters createStoreParameters(DynStruct struct)
137
            throws InitializeException, ProviderNotRegisteredException;
138

    
139
    public DataStoreParameters createStoreParameters(Tags tags) throws InitializeException, ProviderNotRegisteredException;
140

    
141
    /**
142
     * Creates, initializes and returns an instance of NewDataStoreParameters
143
     * given the name with which their provider is registered.
144
     *
145
     * @param explorer
146
     * @param provider
147
     * @return
148
     *
149
     * @throws InitializeException
150
     * @throws ProviderNotRegisteredException
151
     */
152
    public NewDataStoreParameters createNewStoreParameters(String explorer, String provider)
153
            throws InitializeException, ProviderNotRegisteredException;
154

    
155
    /**
156
     *
157
     * Creates, initializes and returns an instance of DataStore given the
158
     * DataStoreParameters.
159
     *
160
     * @param provider
161
     * @param parameters parameters used to instantiate and initialize the
162
     * DataStore
163
     * @return
164
     *
165
     * @throws ProviderNotRegisteredException if the memory provider is not
166
     * registered
167
     * @throws InitializeException if there is an error initializing the
168
     * parameters for the memory provider
169
     * @throws ValidateDataParametersException if the parameters to open the
170
     * memory based store are not valid
171
     */
172
    public DataStore openStore(String provider, DynObject parameters)
173
            throws InitializeException, ProviderNotRegisteredException,
174
            ValidateDataParametersException;
175

    
176
    public DataStore openStore(String provider, DataStoreParameters parameters)
177
            throws InitializeException, ProviderNotRegisteredException,
178
            ValidateDataParametersException;
179

    
180
    public DataStore openStore(
181
            String providerName,
182
            Object... arguments)
183
        throws
184
            InitializeException,
185
            ProviderNotRegisteredException,
186
            ValidateDataParametersException;
187

    
188
    public DataStore openStore(DynStruct struct)
189
            throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException;
190

    
191
    /**
192
     * Create a new physical store
193
     *
194
     * @param explorer
195
     * @param provider
196
     * @param parameters
197
     * @param overwrite
198
     *
199
     * @throws InitializeException
200
     * @throws ProviderNotRegisteredException
201
     * @throws ValidateDataParametersException
202
     */
203
    public void newStore(String explorer, String provider, NewDataStoreParameters parameters, boolean overwrite)
204
            throws InitializeException, ProviderNotRegisteredException,
205
            ValidateDataParametersException;
206

    
207
    /**
208
     * Returns a list of Strings containing the names of all available DataStore
209
     * providers.
210
     *
211
     * @return list of String containing available DataStore provider names
212
     */
213
    public List getStoreProviders();
214

    
215
    /**
216
     * Returns a list of Strings containing the names of all available DataStore
217
     * providers for an explorer.
218
     *
219
     * @param name
220
     * @return
221
     */
222
    public List<String> getStoreProviders(String name);
223

    
224
    /*
225
     * ====================================================================
226
     *
227
     * Explorer related services
228
     */
229
    /**
230
     * Returns an instance of {@link DataServerExplorerParameters} corresponding
231
     * to the given name.
232
     *
233
     * @param name name of a registered server explorer provider
234
     * @return
235
     *
236
     * @throws InitializeException if parameter initialization causes an error.
237
     *
238
     * @throws ProviderNotRegisteredException if could not find a provider by
239
     * the given name.
240
     *
241
     *
242
     */
243
    public DataServerExplorerParameters createServerExplorerParameters(
244
            String name)
245
            throws InitializeException, ProviderNotRegisteredException;
246

    
247
    /**
248
     * Returns an instance of {@link DataServerExplorer} given its parameters.
249
     *
250
     * @param name
251
     * @param parameters parameters used to instantiate and initialize the
252
     * {@link DataServerExplorer}.
253
     *
254
     * @return an instance of {@link DataServerExplorer}.
255
     *
256
     * @throws InitializeException
257
     *
258
     * @throws ProviderNotRegisteredException
259
     * @throws ValidateDataParametersException
260
     */
261
    public DataServerExplorer openServerExplorer(
262
            String name,
263
            DataServerExplorerParameters parameters)
264
            throws InitializeException, ProviderNotRegisteredException,
265
            ValidateDataParametersException;
266

    
267
    public DataServerExplorer openServerExplorer(
268
            String explorerName,
269
            Object... arguments)
270
        throws
271
            InitializeException,
272
            ProviderNotRegisteredException,
273
            ValidateDataParametersException;
274
    /**
275
     * @param parameters
276
     * @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
     * @deprecated see openServerExplorer
281
     */
282
    public DataServerExplorer createServerExplorer(
283
            DataServerExplorerParameters parameters)
284
            throws InitializeException, ProviderNotRegisteredException,
285
            ValidateDataParametersException;
286

    
287
    /**
288
     * @param parameters
289
     * @return
290
     * @throws org.gvsig.fmap.dal.exception.InitializeException
291
     * @throws org.gvsig.fmap.dal.exception.ProviderNotRegisteredException
292
     * @throws org.gvsig.fmap.dal.exception.ValidateDataParametersException
293
     * @deprecated see openStore
294
     */
295
    public DataStore createStore(DataStoreParameters parameters)
296
            throws InitializeException, ProviderNotRegisteredException,
297
            ValidateDataParametersException;
298

    
299
    /**
300
     * Returns a list of String containing the names of the available
301
     * DataServerExplorer providers.
302
     *
303
     * @return list of String containing the names of the available
304
     * DataServerExplorer providers.
305
     */
306
    public List<String> getExplorerProviders();
307

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

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

    
330
    /**
331
     * Creates an instance of Evaluator that represents the given expression.
332
     *
333
     * @param expression String containing a CQL expression.
334
     * @return instance of Evaluator representing the given expression.
335
     * @throws InitializeException
336
     */
337
    public Evaluator createFilter(String expression)
338
            throws InitializeException;
339

    
340
    /**
341
     * Creates an instance of Evaluator that represents the given expression.
342
     *
343
     * @param expression a Expression with the filter
344
     * @return instance of Evaluator representing the given expression.
345
     * @throws InitializeException
346
     */
347
    public Evaluator createFilter(Expression expression)
348
            throws InitializeException;
349

    
350
    /*
351
     * ====================================================================
352
     *
353
     * Index related services
354
     */
355
    /**
356
     * Returns a list of String containing the names of the available index
357
     * providers.
358
     *
359
     * @return list of strings with the names of the available index providers
360
     */
361
    public List<String> getFeatureIndexProviders();
362

    
363
    /**
364
     * Sets the default DataIndexProvider for the given data type.
365
     *
366
     * @param dataType one of the data types defined in {@link DataTypes}.
367
     * @param name Provider's name
368
     */
369
    public void setDefaultFeatureIndexProviderName(int dataType, String name);
370

    
371
    /**
372
     * Returns the default DataIndexProvider name, given a data type. Data types
373
     * are defined in {@link DataTypes}.
374
     *
375
     * @param dataType one of the constants in {@link DataTypes}.
376
     *
377
     * @return the name of the default {@link FeatureIndexProvider} if there is
378
     * anyone available for the given data type.
379
     */
380
    public String getDefaultFeatureIndexProviderName(int dataType);
381

    
382
    /**
383
     * Utility method to create the {@link DataStoreParameters} to create a
384
     * {@link FeatureStore} based on the {@link MemoryStoreProvider}.
385
     *
386
     * @param autoOrderAttributeName the name of the {@link Feature} attribute
387
     * to be used to order the store {@link Feature}s by default. Set to null if
388
     * you don't want any order by default
389
     * @return the parameters for the memory based store
390
     * @throws InitializeException if there is an error initializing the
391
     * parameters for the memory provider
392
     */
393
    public DataStoreParameters createMemoryStoreParameters(
394
            String autoOrderAttributeName) throws InitializeException;
395

    
396
    /**
397
     * Utility method to create the a {@link FeatureStore} based on the
398
     * {@link MemoryStoreProvider}.
399
     *
400
     * @param autoOrderAttributeName the name of the {@link Feature} attribute
401
     * to be used to order the store {@link Feature}s by default. Set to null if
402
     * you don't want any order by default
403
     * @return the the memory based store
404
     * @throws InitializeException if there is an error initializing the
405
     * parameters for the memory provider
406
     */
407
    public FeatureStore createMemoryStore(String autoOrderAttributeName)
408
            throws InitializeException;
409

    
410
    /**
411
     * Creates a {@link FeaturePagingHelper} to paginate data from a
412
     * {@link FeatureStore}.
413
     *
414
     * @param featureStore to get the {@link Feature}s from
415
     * @param pageSize the page size
416
     * @return a {@link FeaturePagingHelper}
417
     * @throws BaseException if there is an error creating the helper
418
     */
419
    public FeaturePagingHelper createFeaturePagingHelper(
420
            FeatureStore featureStore, int pageSize) throws BaseException;
421

    
422
    /**
423
     * Creates a {@link FeaturePagingHelper} to paginate data from a
424
     * {@link FeatureStore}.
425
     *
426
     * @param featureStore to get the {@link Feature}s from
427
     * @param featureQuery to filter and/or order the data
428
     * @param pageSize the page size
429
     * @return a {@link FeaturePagingHelper}
430
     * @throws BaseException if there is an error creating the helper
431
     */
432
    public FeaturePagingHelper createFeaturePagingHelper(
433
            FeatureStore featureStore, FeatureQuery featureQuery, int pageSize)
434
            throws BaseException;
435

    
436
    public void setOpenErrorHandler(OpenErrorHandler handler);
437

    
438
    public OpenErrorHandler getOpenErrorHandler();
439

    
440
    public DataStoreProviderFactory getStoreProviderFactory(String name);
441

    
442
    public EditableFeatureType createFeatureType();
443

    
444
    public DataServerExplorerPool getDataServerExplorerPool();
445

    
446
    public void setDataServerExplorerPool(DataServerExplorerPool pool);
447

    
448
    public void setResourcesLoader(ClassLoader loader);
449

    
450
    public void setResourcesLoader(File folder);
451

    
452
    /**
453
     * Return a list of the DataTypes supported for the type of the feature
454
     * attributes. The list is only informative.
455
     *
456
     * @return
457
     */
458
    public List<DataType> getDataTypes();
459

    
460
    public Register getStoreRegister();
461

    
462
    public Register getStoreProviderRegister();
463

    
464
    public Register getServerExplorerRegister();
465

    
466
    public Register getFeatureIndexRegister();
467

    
468
    /**
469
     * Creates a default ExpressionBuilder.
470
     *
471
     * This ExpressionBuilder is not dependent on a data source,
472
     * and is not advisable to use it.
473
     *
474
     * @return the ExpressionBuilder
475
     * @deprecated use ExpressionEvaluatorManager.createExpressionBuilder()
476
     */
477
    public ExpressionBuilder createExpressionBuilder();
478

    
479
    /**
480
         * Returns a list of String containing the names of the available cache providers.
481
         *
482
         * @return
483
         *                 list of strings with the names of the available cache providers
484
         */
485
    public List getFeatureCacheProviders();
486

    
487
        /**
488
         * Returns an instance of {@link DataServerExplorerParameters} corresponding
489
         * to the given name used by the cache to create a store to save the
490
         * retrieved data.
491
         *
492
         * @param name
493
         *            name of a registered feature cache provider
494
     * @return 
495
         *
496
         * @throws InitializeException
497
         *             if parameter initialization causes an error.
498
         *
499
         * @throws ProviderNotRegisteredException
500
         *             if could not find a cache provider by the given name.
501
         *
502
         */
503
        public DynObject createCacheParameters(String name)
504
                        throws InitializeException, ProviderNotRegisteredException;
505

    
506
    /**
507
     * @param providerName
508
     * @param params
509
     * @param overwrite
510
     * @throws DataException
511
     */
512
    public void createFileStore(String providerName, NewDataStoreParameters params, boolean overwrite) throws DataException;
513

    
514
    public FeatureSymbolTable createFeatureSymbolTable();
515

    
516
    public EditableFeatureAttributeDescriptor createFeatureAttributeDescriptor();
517
    
518
    public FeatureAttributeEmulatorExpression createFeatureAttributeEmulatorExpression(FeatureType type, Expression expression);
519

    
520
    public void registerDataProfile(DataProfile profile);
521

    
522
    public List<DataProfile> getDataProfiles();
523

    
524
    public DataProfile getDataProfile(String name);
525
    
526
    public StoresRepository getStoresRepository();
527
    
528
    public DatabaseWorkspaceManager createDatabaseWorkspaceManager(DataServerExplorerParameters connection);
529
    
530
    public void addDatabaseWorkspace(DatabaseWorkspaceManager DatabaseWorkspace);
531

    
532
    public void addDatabaseWorkspaceListener(DatabaseWorkspaceManager.AddDatabaseWorkspaceListener listener);
533
    
534
    public DatabaseWorkspaceManager getDatabaseWorkspace(String name);
535
    
536
    public DatabaseWorkspaceManager getDatabaseWorkspace(DataStoreParameters params);
537

    
538
    public void writeDALResource(ResourcesStorage resources, DataStore store);
539
    
540
    public void writeDALResource(ResourcesStorage resources, FeatureType featureType);
541

    
542
    /**
543
     * Return a 35-40 characters unique identifier.
544
     * 
545
     * @return the unique identifier
546
     */
547
    public String createUniqueID();
548

    
549
    public void clearAvailableValuesCache();
550

    
551
    public DALExpressionBuilder createDALExpressionBuilder();
552
}