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

History | View | Annotate | Download (20.4 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_EXISTS_TABLE = "EXISTS_TABLE";
81
    public static final String FUNCTION_ROW_TAG = "ROW_TAG";
82
    public static final String FUNCTION_SET_ROW_TAG = "SET_ROW_TAG";
83
    public static final String FUNCTION_CURRENT_ROW = "CURRENT_ROW";
84
    public static final String FUNCTION_CURRENT_STORE = "CURRENT_STORE";
85
    public static final String FUNCTION_ISSELECTED_CURRENT_ROW = "ISSELECTED_CURRENT_ROW";
86
    public static final String FUNCTION_GEOMETRY = "GEOMETRY";
87
    public static final String FUNCTION_CREATE_IN_MEMORY_TABLE = "CREATE_IN_MEMORY_TABLE";
88
    public static final String FUNCTION_INSERT_INTO_TABLE = "INSERT_INTO_TABLE";
89
    
90
    public static final String DAL_PREFERRED_COLUMNS = "DAL.Preferred.Columns";
91
    
92
    public static final String DAL_USE_LABELS = "DAL.useLabels";
93
    public static final int USE_LABELS_YES = 0;
94
    public static final int USE_LABELS_NO = 1;
95
    public static final int USE_LABELS_BOTH = 2;
96
    
97
    /**
98
     * 
99
     * Returns the default DAL's temporary directory
100
     *
101
     * @return Temporary directory name
102
     * @deprecated use FoldersManager of org.gvsig.tools
103
     */
104
    public String getTemporaryDirectory();
105

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

    
127
    public DataStoreParameters createStoreParameters(byte[] data);
128

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

    
145
    public DataStoreParameters createStoreParameters(Tags tags) throws InitializeException, ProviderNotRegisteredException;
146

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

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

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

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

    
194
    public DataStore openStore(DynStruct struct)
195
            throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException;
196

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

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

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

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

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

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

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

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

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

    
325
    /**
326
     * Creates an instance of Evaluator that represents the given expression.
327
     *
328
     * @param expression a Expression with the filter
329
     * @return instance of Evaluator representing the given expression.
330
     * @throws InitializeException
331
     * @deprecated use createFilter
332
     */
333
    public Evaluator createExpresion(Expression expression)
334
            throws InitializeException;
335

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

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

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

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

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

    
388
    /**
389
     * Utility method to create the {@link DataStoreParameters} to create a
390
     * {@link FeatureStore} based on the {@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 parameters for the memory based store
396
     * @throws InitializeException if there is an error initializing the
397
     * parameters for the memory provider
398
     */
399
    public DataStoreParameters createMemoryStoreParameters(
400
            String autoOrderAttributeName) throws InitializeException;
401

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

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

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

    
442
    public void setOpenErrorHandler(OpenErrorHandler handler);
443

    
444
    public OpenErrorHandler getOpenErrorHandler();
445

    
446
    public DataStoreProviderFactory getStoreProviderFactory(String name);
447

    
448
    public EditableFeatureType createFeatureType();
449

    
450
    public DataServerExplorerPool getDataServerExplorerPool();
451

    
452
    public void setDataServerExplorerPool(DataServerExplorerPool pool);
453

    
454
    public void setResourcesLoader(ClassLoader loader);
455

    
456
    public void setResourcesLoader(File folder);
457

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

    
466
    public Register getStoreRegister();
467

    
468
    public Register getStoreProviderRegister();
469

    
470
    public Register getServerExplorerRegister();
471

    
472
    public Register getFeatureIndexRegister();
473

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

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

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

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

    
520
    public FeatureSymbolTable createFeatureSymbolTable();
521

    
522
    public EditableFeatureAttributeDescriptor createFeatureAttributeDescriptor();
523
    
524
    public FeatureAttributeEmulatorExpression createFeatureAttributeEmulatorExpression(FeatureType type, Expression expression);
525

    
526
    public void registerDataProfile(DataProfile profile);
527

    
528
    public List<DataProfile> getDataProfiles();
529

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

    
538
    public void removeDatabaseWorkspace(DatabaseWorkspaceManager DatabaseWorkspace);
539

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

    
546
    public void writeDALResource(ResourcesStorage resources, DataStore store);
547
    
548
    public void writeDALResource(ResourcesStorage resources, FeatureType featureType);
549

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

    
557
    public void clearAvailableValuesCache();
558

    
559
    public DALExpressionBuilder createDALExpressionBuilder();
560
    
561
    public boolean isTheOldRasterRegistered();
562
}