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

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