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

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