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

History | View | Annotate | Download (20.6 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.observer.Observer;
55
import org.gvsig.tools.resourcesstorage.ResourcesStorage;
56

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

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

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

    
77
    public static final String FUNCTION_FOREING_VALUE = "FOREING_VALUE";
78
    public static final String FUNCTION_SELECT = "SELECT";
79
    public static final String FUNCTION_SELECT_COUNT = "SELECT_COUNT";
80
    public static final String FUNCTION_EXISTS = "EXISTS";
81
    public static final String FUNCTION_EXISTS_TABLE = "EXISTS_TABLE";
82
    public static final String FUNCTION_ROW_TAG = "ROW_TAG";
83
    public static final String FUNCTION_SET_ROW_TAG = "SET_ROW_TAG";
84
    public static final String FUNCTION_CURRENT_ROW = "CURRENT_ROW";
85
    public static final String FUNCTION_CURRENT_STORE = "CURRENT_STORE";
86
    public static final String FUNCTION_ISSELECTED_CURRENT_ROW = "ISSELECTED_CURRENT_ROW";
87
    public static final String FUNCTION_GEOMETRY = "GEOMETRY";
88
    public static final String FUNCTION_CREATE_IN_MEMORY_TABLE = "CREATE_IN_MEMORY_TABLE";
89
    public static final String FUNCTION_INSERT_INTO_TABLE = "INSERT_INTO_TABLE";
90
    
91
    public static final String DAL_PREFERRED_COLUMNS = "DAL.Preferred.Columns";
92
    
93
    public static final String DAL_USE_LABELS = "DAL.useLabels";
94

    
95
    public static final int USE_LABELS_YES = 0;
96
    public static final int USE_LABELS_NO = 1;
97
    public static final int USE_LABELS_BOTH = 2;
98
    
99
    /**
100
     * 
101
     * Returns the default DAL's temporary directory
102
     *
103
     * @return Temporary directory name
104
     * @deprecated use FoldersManager of org.gvsig.tools
105
     */
106
    public String getTemporaryDirectory();
107

    
108
    /*
109
     * ====================================================================
110
     *
111
     * Store related services
112
     */
113
    /**
114
     * Creates, initializes and returns an instance of DataStoreParameters given
115
     * the name with which their provider is registered.
116
     *
117
     * @param name provider name
118
     * @return the data store parameters
119
     *
120
     * @throws ProviderNotRegisteredException if the memory provider is not
121
     * registered
122
     * @throws InitializeException if there is an error initializing the
123
     * parameters for the memory provider
124
     *
125
     */
126
    public DataStoreParameters createStoreParameters(String name, Object... arguments)
127
            throws InitializeException, ProviderNotRegisteredException;
128

    
129
    public DataStoreParameters createStoreParameters(byte[] data);
130

    
131
    /**
132
     * Creates, initializes and fill an instance of DataStoreParameters from the
133
     * tags of the DynStruct passed as parameter.
134
     *
135
     * @param struct structure from which tags were created ths parameters.
136
     * @return the data store parameters
137
     *
138
     * @throws ProviderNotRegisteredException if the memory provider is not
139
     * registered
140
     * @throws InitializeException if there is an error initializing the
141
     * parameters for the memory provider
142
     *
143
     */
144
    public DataStoreParameters createStoreParameters(DynStruct struct)
145
            throws InitializeException, ProviderNotRegisteredException;
146

    
147
    public DataStoreParameters createStoreParameters(Tags tags) throws InitializeException, ProviderNotRegisteredException;
148

    
149
    /**
150
     * Creates, initializes and returns an instance of NewDataStoreParameters
151
     * given the name with which their provider is registered.
152
     *
153
     * @param explorer
154
     * @param provider
155
     * @return
156
     *
157
     * @throws InitializeException
158
     * @throws ProviderNotRegisteredException
159
     */
160
    public NewDataStoreParameters createNewStoreParameters(String explorer, String provider)
161
            throws InitializeException, ProviderNotRegisteredException;
162

    
163
    /**
164
     *
165
     * Creates, initializes and returns an instance of DataStore given the
166
     * DataStoreParameters.
167
     *
168
     * @param provider
169
     * @param parameters parameters used to instantiate and initialize the
170
     * DataStore
171
     * @return
172
     *
173
     * @throws ProviderNotRegisteredException if the memory provider is not
174
     * registered
175
     * @throws InitializeException if there is an error initializing the
176
     * parameters for the memory provider
177
     * @throws ValidateDataParametersException if the parameters to open the
178
     * memory based store are not valid
179
     */
180
    public DataStore openStore(String provider, DynObject parameters)
181
            throws InitializeException, ProviderNotRegisteredException,
182
            ValidateDataParametersException;
183

    
184
    public DataStore openStore(String provider, DataStoreParameters parameters)
185
            throws InitializeException, ProviderNotRegisteredException,
186
            ValidateDataParametersException;
187

    
188
    public DataStore openStore(
189
            String providerName,
190
            Object... arguments)
191
        throws
192
            InitializeException,
193
            ProviderNotRegisteredException,
194
            ValidateDataParametersException;
195

    
196
    public DataStore openStore(DynStruct struct)
197
            throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException;
198

    
199
    /**
200
     * Create a new physical store
201
     *
202
     * @param explorer
203
     * @param provider
204
     * @param parameters
205
     * @param overwrite
206
     *
207
     * @throws InitializeException
208
     * @throws ProviderNotRegisteredException
209
     * @throws ValidateDataParametersException
210
     */
211
    public void newStore(String explorer, String provider, NewDataStoreParameters parameters, boolean overwrite)
212
            throws InitializeException, ProviderNotRegisteredException,
213
            ValidateDataParametersException;
214

    
215
    /**
216
     * Returns a list of Strings containing the names of all available DataStore
217
     * providers.
218
     *
219
     * @return list of String containing available DataStore provider names
220
     */
221
    public List getStoreProviders();
222

    
223
    /**
224
     * Returns a list of Strings containing the names of all available DataStore
225
     * providers for an explorer.
226
     *
227
     * @param name
228
     * @return
229
     */
230
    public List<String> getStoreProviders(String name);
231

    
232
    /*
233
     * ====================================================================
234
     *
235
     * Explorer related services
236
     */
237
    /**
238
     * Returns an instance of {@link DataServerExplorerParameters} corresponding
239
     * to the given name.
240
     *
241
     * @param name name of a registered server explorer provider
242
     * @return
243
     *
244
     * @throws InitializeException if parameter initialization causes an error.
245
     *
246
     * @throws ProviderNotRegisteredException if could not find a provider by
247
     * the given name.
248
     *
249
     *
250
     */
251
    public DataServerExplorerParameters createServerExplorerParameters(
252
            String name)
253
            throws InitializeException, ProviderNotRegisteredException;
254

    
255
    /**
256
     * Returns an instance of {@link DataServerExplorer} given its parameters.
257
     *
258
     * @param name
259
     * @param parameters parameters used to instantiate and initialize the
260
     * {@link DataServerExplorer}.
261
     *
262
     * @return an instance of {@link DataServerExplorer}.
263
     *
264
     * @throws InitializeException
265
     *
266
     * @throws ProviderNotRegisteredException
267
     * @throws ValidateDataParametersException
268
     */
269
    public DataServerExplorer openServerExplorer(
270
            String name,
271
            DataServerExplorerParameters parameters)
272
            throws InitializeException, ProviderNotRegisteredException,
273
            ValidateDataParametersException;
274

    
275
    public DataServerExplorer openServerExplorer(
276
            String explorerName,
277
            Object... arguments)
278
        throws
279
            InitializeException,
280
            ProviderNotRegisteredException,
281
            ValidateDataParametersException;
282
    /**
283
     * @param parameters
284
     * @return
285
     * @throws org.gvsig.fmap.dal.exception.InitializeException
286
     * @throws org.gvsig.fmap.dal.exception.ProviderNotRegisteredException
287
     * @throws org.gvsig.fmap.dal.exception.ValidateDataParametersException
288
     * @deprecated see openServerExplorer
289
     */
290
    public DataServerExplorer createServerExplorer(
291
            DataServerExplorerParameters parameters)
292
            throws InitializeException, ProviderNotRegisteredException,
293
            ValidateDataParametersException;
294

    
295
    /**
296
     * @param parameters
297
     * @return
298
     * @throws org.gvsig.fmap.dal.exception.InitializeException
299
     * @throws org.gvsig.fmap.dal.exception.ProviderNotRegisteredException
300
     * @throws org.gvsig.fmap.dal.exception.ValidateDataParametersException
301
     * @deprecated see openStore
302
     */
303
    public DataStore createStore(DataStoreParameters parameters)
304
            throws InitializeException, ProviderNotRegisteredException,
305
            ValidateDataParametersException;
306

    
307
    /**
308
     * Returns a list of String containing the names of the available
309
     * DataServerExplorer providers.
310
     *
311
     * @return list of String containing the names of the available
312
     * DataServerExplorer providers.
313
     */
314
    public List<String> getExplorerProviders();
315

    
316
    /**
317
     * Creates an instance of Evaluator that represents the given expression.
318
     *
319
     * @param expression String containing a CQL expression.
320
     * @return instance of Evaluator representing the given expression.
321
     * @throws InitializeException
322
     * @deprecated use createFilter
323
     */
324
    public Evaluator createExpresion(String expression)
325
            throws InitializeException;
326

    
327
    /**
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
     * @deprecated use createFilter
334
     */
335
    public Evaluator createExpresion(Expression expression)
336
            throws InitializeException;
337

    
338
    /**
339
     * Creates an instance of Evaluator that represents the given expression.
340
     *
341
     * @param expression String containing a CQL expression.
342
     * @return instance of Evaluator representing the given expression.
343
     * @throws InitializeException
344
     */
345
    public Evaluator createFilter(String expression)
346
            throws InitializeException;
347

    
348
    /**
349
     * Creates an instance of Evaluator that represents the given expression.
350
     *
351
     * @param expression a Expression with the filter
352
     * @return instance of Evaluator representing the given expression.
353
     * @throws InitializeException
354
     */
355
    public Evaluator createFilter(Expression expression)
356
            throws InitializeException;
357

    
358
    /*
359
     * ====================================================================
360
     *
361
     * Index related services
362
     */
363
    /**
364
     * Returns a list of String containing the names of the available index
365
     * providers.
366
     *
367
     * @return list of strings with the names of the available index providers
368
     */
369
    public List<String> getFeatureIndexProviders();
370

    
371
    /**
372
     * Sets the default DataIndexProvider for the given data type.
373
     *
374
     * @param dataType one of the data types defined in {@link DataTypes}.
375
     * @param name Provider's name
376
     */
377
    public void setDefaultFeatureIndexProviderName(int dataType, String name);
378

    
379
    /**
380
     * Returns the default DataIndexProvider name, given a data type. Data types
381
     * are defined in {@link DataTypes}.
382
     *
383
     * @param dataType one of the constants in {@link DataTypes}.
384
     *
385
     * @return the name of the default {@link FeatureIndexProvider} if there is
386
     * anyone available for the given data type.
387
     */
388
    public String getDefaultFeatureIndexProviderName(int dataType);
389

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

    
404
    /**
405
     * Utility method to create the a {@link FeatureStore} based on the
406
     * {@link MemoryStoreProvider}.
407
     *
408
     * @param autoOrderAttributeName the name of the {@link Feature} attribute
409
     * to be used to order the store {@link Feature}s by default. Set to null if
410
     * you don't want any order by default
411
     * @return the the memory based store
412
     * @throws InitializeException if there is an error initializing the
413
     * parameters for the memory provider
414
     */
415
    public FeatureStore createMemoryStore(String autoOrderAttributeName)
416
            throws InitializeException;
417

    
418
    /**
419
     * Creates a {@link FeaturePagingHelper} to paginate data from a
420
     * {@link FeatureStore}.
421
     *
422
     * @param featureStore to get the {@link Feature}s from
423
     * @param pageSize the page size
424
     * @return a {@link FeaturePagingHelper}
425
     * @throws BaseException if there is an error creating the helper
426
     */
427
    public FeaturePagingHelper createFeaturePagingHelper(
428
            FeatureStore featureStore, int pageSize) throws BaseException;
429

    
430
    /**
431
     * Creates a {@link FeaturePagingHelper} to paginate data from a
432
     * {@link FeatureStore}.
433
     *
434
     * @param featureStore to get the {@link Feature}s from
435
     * @param featureQuery to filter and/or order the data
436
     * @param pageSize the page size
437
     * @return a {@link FeaturePagingHelper}
438
     * @throws BaseException if there is an error creating the helper
439
     */
440
    public FeaturePagingHelper createFeaturePagingHelper(
441
            FeatureStore featureStore, FeatureQuery featureQuery, int pageSize)
442
            throws BaseException;
443

    
444
    public void setOpenErrorHandler(OpenErrorHandler handler);
445

    
446
    public OpenErrorHandler getOpenErrorHandler();
447

    
448
    public DataStoreProviderFactory getStoreProviderFactory(String name);
449

    
450
    public EditableFeatureType createFeatureType();
451

    
452
    public DataServerExplorerPool getDataServerExplorerPool();
453

    
454
    public void setDataServerExplorerPool(DataServerExplorerPool pool);
455

    
456
    public void setResourcesLoader(ClassLoader loader);
457

    
458
    public void setResourcesLoader(File folder);
459

    
460
    /**
461
     * Return a list of the DataTypes supported for the type of the feature
462
     * attributes. The list is only informative.
463
     *
464
     * @return
465
     */
466
    public List<DataType> getDataTypes();
467

    
468
    public Register getStoreRegister();
469

    
470
    public Register getStoreProviderRegister();
471

    
472
    public Register getServerExplorerRegister();
473

    
474
    public Register getFeatureIndexRegister();
475

    
476
    /**
477
     * Creates a default ExpressionBuilder.
478
     *
479
     * This ExpressionBuilder is not dependent on a data source,
480
     * and is not advisable to use it.
481
     *
482
     * @return the ExpressionBuilder
483
     * @deprecated use ExpressionEvaluatorManager.createExpressionBuilder()
484
     */
485
    public ExpressionBuilder createExpressionBuilder();
486

    
487
    /**
488
         * Returns a list of String containing the names of the available cache providers.
489
         *
490
         * @return
491
         *                 list of strings with the names of the available cache providers
492
         */
493
    public List getFeatureCacheProviders();
494

    
495
        /**
496
         * Returns an instance of {@link DataServerExplorerParameters} corresponding
497
         * to the given name used by the cache to create a store to save the
498
         * retrieved data.
499
         *
500
         * @param name
501
         *            name of a registered feature cache provider
502
     * @return 
503
         *
504
         * @throws InitializeException
505
         *             if parameter initialization causes an error.
506
         *
507
         * @throws ProviderNotRegisteredException
508
         *             if could not find a cache provider by the given name.
509
         *
510
         */
511
        public DynObject createCacheParameters(String name)
512
                        throws InitializeException, ProviderNotRegisteredException;
513

    
514
    /**
515
     * @param providerName
516
     * @param params
517
     * @param overwrite
518
     * @throws DataException
519
     */
520
    public void createFileStore(String providerName, NewDataStoreParameters params, boolean overwrite) throws DataException;
521

    
522
    public FeatureSymbolTable createFeatureSymbolTable();
523

    
524
    public EditableFeatureAttributeDescriptor createFeatureAttributeDescriptor();
525
    
526
    public FeatureAttributeEmulatorExpression createFeatureAttributeEmulatorExpression(FeatureType type, Expression expression);
527

    
528
    public void registerDataProfile(DataProfile profile);
529

    
530
    public List<DataProfile> getDataProfiles();
531

    
532
    public DataProfile getDataProfile(String name);
533
    
534
    public StoresRepository getStoresRepository();
535
    
536
    public DatabaseWorkspaceManager createDatabaseWorkspaceManager(DataServerExplorerParameters connection);
537
    
538
    public void addDatabaseWorkspace(DatabaseWorkspaceManager DatabaseWorkspace);
539

    
540
    public void removeDatabaseWorkspace(DatabaseWorkspaceManager DatabaseWorkspace);
541

    
542
    public void addDatabaseWorkspaceListener(DatabaseWorkspaceManager.DatabaseWorkspaceListener listener);
543
    
544
    public DatabaseWorkspaceManager getDatabaseWorkspace(String name);
545
    
546
    public DatabaseWorkspaceManager getDatabaseWorkspace(DataStoreParameters params);
547

    
548
    public void writeDALResource(ResourcesStorage resources, DataStore store);
549
    
550
    public void writeDALResource(ResourcesStorage resources, FeatureType featureType);
551

    
552
    /**
553
     * Return a 35-40 characters unique identifier.
554
     * 
555
     * @return the unique identifier
556
     */
557
    public String createUniqueID();
558

    
559
    public void clearAvailableValuesCache();
560

    
561
    public DALExpressionBuilder createDALExpressionBuilder();
562
    
563
    public boolean isTheOldRasterRegistered();
564
    
565
    public void addStoreObserver(Observer observer);
566
    
567
    public void removeStoreObserver(Observer observer);
568
    
569
}