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

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