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

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