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

History | View | Annotate | Download (15.6 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

    
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
import org.gvsig.fmap.dal.resource.ResourceManager;
38
import org.gvsig.tools.dataTypes.DataType;
39
import org.gvsig.tools.dynobject.DynObject;
40
import org.gvsig.tools.dynobject.DynStruct;
41
import org.gvsig.tools.dynobject.Tags;
42
import org.gvsig.tools.evaluator.Evaluator;
43
import org.gvsig.tools.exception.BaseException;
44
import org.gvsig.tools.service.spi.Services;
45

    
46
/**
47
 * There are two top level management roles within DAL: data access and resource
48
 * management.
49
 *
50
 * 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
 *
54
 * @see ResourceManager
55
 *
56
 */
57
public interface DataManager extends Services {
58

    
59
    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

    
63
    /**
64
     * Returns the default DAL's temporary directory
65
     *
66
     * @return Temporary directory name
67
     */
68
    public String getTemporaryDirectory();
69

    
70
    /*
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

    
91
    /**
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

    
107
    public DataStoreParameters createStoreParameters(Tags tags) throws InitializeException, ProviderNotRegisteredException;
108

    
109
    /**
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

    
123
    /**
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

    
144
    public DataStore openStore(String provider, DataStoreParameters parameters)
145
            throws InitializeException, ProviderNotRegisteredException,
146
            ValidateDataParametersException;
147

    
148
    public DataStore openStore(DynStruct struct)
149
            throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException;
150

    
151
    /**
152
     * Create a new physical store
153
     *
154
     * @param explorer
155
     * @param provider
156
     * @param parameters
157
     * @param overwrite
158
     *
159
     * @throws InitializeException
160
     * @throws ProviderNotRegisteredException
161
     * @throws ValidateDataParametersException
162
     */
163
    public void newStore(String explorer, String provider, NewDataStoreParameters parameters, boolean overwrite)
164
            throws InitializeException, ProviderNotRegisteredException,
165
            ValidateDataParametersException;
166

    
167
    /**
168
     * Returns a list of Strings containing the names of all available DataStore
169
     * providers.
170
     *
171
     * @return list of String containing available DataStore provider names
172
     */
173
    public List getStoreProviders();
174

    
175
    /**
176
     * Returns a list of Strings containing the names of all available DataStore
177
     * providers for an explorer.
178
     *
179
     * @param name
180
     * @return
181
     */
182
    public List<String> getStoreProviders(String name);
183

    
184
    /*
185
     * ====================================================================
186
     *
187
     * Explorer related services
188
     */
189
    /**
190
     * Returns an instance of {@link DataServerExplorerParameters} corresponding
191
     * to the given name.
192
     *
193
     * @param name name of a registered server explorer provider
194
     * @return
195
     *
196
     * @throws InitializeException if parameter initialization causes an error.
197
     *
198
     * @throws ProviderNotRegisteredException if could not find a provider by
199
     * the given name.
200
     *
201
     *
202
     */
203
    public DataServerExplorerParameters createServerExplorerParameters(
204
            String name)
205
            throws InitializeException, ProviderNotRegisteredException;
206

    
207
    /**
208
     * Returns an instance of {@link DataServerExplorer} given its parameters.
209
     *
210
     * @param name
211
     * @param parameters parameters used to instantiate and initialize the
212
     * {@link DataServerExplorer}.
213
     *
214
     * @return an instance of {@link DataServerExplorer}.
215
     *
216
     * @throws InitializeException
217
     *
218
     * @throws ProviderNotRegisteredException
219
     * @throws ValidateDataParametersException
220
     */
221
    public DataServerExplorer openServerExplorer(
222
            String name,
223
            DataServerExplorerParameters parameters)
224
            throws InitializeException, ProviderNotRegisteredException,
225
            ValidateDataParametersException;
226

    
227
    /**
228
     * @param parameters
229
     * @return 
230
     * @throws org.gvsig.fmap.dal.exception.InitializeException 
231
     * @throws org.gvsig.fmap.dal.exception.ProviderNotRegisteredException 
232
     * @throws org.gvsig.fmap.dal.exception.ValidateDataParametersException 
233
     * @deprecated see openServerExplorer
234
     */
235
    public DataServerExplorer createServerExplorer(
236
            DataServerExplorerParameters parameters)
237
            throws InitializeException, ProviderNotRegisteredException,
238
            ValidateDataParametersException;
239
    
240
    /**
241
     * @param parameters
242
     * @return 
243
     * @throws org.gvsig.fmap.dal.exception.InitializeException 
244
     * @throws org.gvsig.fmap.dal.exception.ProviderNotRegisteredException 
245
     * @throws org.gvsig.fmap.dal.exception.ValidateDataParametersException 
246
     * @deprecated see openStore
247
     */
248
    public DataStore createStore(DataStoreParameters parameters)
249
            throws InitializeException, ProviderNotRegisteredException,
250
            ValidateDataParametersException;
251
        
252
    /**
253
     * Returns a list of String containing the names of the available
254
     * DataServerExplorer providers.
255
     *
256
     * @return list of String containing the names of the available
257
     * DataServerExplorer providers.
258
     */
259
    public List<String> getExplorerProviders();
260

    
261
    /*
262
     * ====================================================================
263
     *
264
     * Expression evaluation related services
265
     */
266
    /**
267
     * Registers the default expression evaluator. It is used by DAL to evaluate
268
     * and resolve query filters and expressions.
269
     *
270
     * @param evaluator Class that will be called to evaluate the expression. It
271
     * must implement {@link Evaluator}.
272
     */
273
    public void registerDefaultEvaluator(Class evaluator);
274

    
275
    /**
276
     * Creates an instance of Evaluator that represents the given expression.
277
     *
278
     * @param expression String containing a CQL expression.
279
     * @return instance of Evaluator representing the given expression.
280
     * @throws InitializeException
281
     */
282
    public Evaluator createExpresion(String expression)
283
            throws InitializeException;
284
    
285
    /**
286
     * Creates an instance of Evaluator to evaluate a expression.
287
     *
288
     * @return instance of ExpressionEvaluator representing the given expression.
289
     */
290
    public ExpressionEvaluator createExpresion();
291
    
292
    /*
293
     * ====================================================================
294
     *
295
     * Index related services
296
     */
297
    /**
298
     * Returns a list of String containing the names of the available index
299
     * providers.
300
     *
301
     * @return list of strings with the names of the available index providers
302
     */
303
    public List<String> getFeatureIndexProviders();
304

    
305
    /**
306
     * Sets the default DataIndexProvider for the given data type.
307
     *
308
     * @param dataType one of the data types defined in {@link DataTypes}.
309
     * @param name Provider's name
310
     */
311
    public void setDefaultFeatureIndexProviderName(int dataType, String name);
312

    
313
    /**
314
     * Returns the default DataIndexProvider name, given a data type. Data types
315
     * are defined in {@link DataTypes}.
316
     *
317
     * @param dataType one of the constants in {@link DataTypes}.
318
     *
319
     * @return the name of the default {@link FeatureIndexProvider} if there is
320
     * anyone available for the given data type.
321
     */
322
    public String getDefaultFeatureIndexProviderName(int dataType);
323

    
324
    /**
325
     * Utility method to create the {@link DataStoreParameters} to create a
326
     * {@link FeatureStore} based on the {@link MemoryStoreProvider}.
327
     *
328
     * @param autoOrderAttributeName the name of the {@link Feature} attribute
329
     * to be used to order the store {@link Feature}s by default. Set to null if
330
     * you don't want any order by default
331
     * @return the parameters for the memory based store
332
     * @throws InitializeException if there is an error initializing the
333
     * parameters for the memory provider
334
     */
335
    public DataStoreParameters createMemoryStoreParameters(
336
            String autoOrderAttributeName) throws InitializeException;
337

    
338
    /**
339
     * Utility method to create the a {@link FeatureStore} based on the
340
     * {@link MemoryStoreProvider}.
341
     *
342
     * @param autoOrderAttributeName the name of the {@link Feature} attribute
343
     * to be used to order the store {@link Feature}s by default. Set to null if
344
     * you don't want any order by default
345
     * @return the the memory based store
346
     * @throws InitializeException if there is an error initializing the
347
     * parameters for the memory provider
348
     */
349
    public FeatureStore createMemoryStore(String autoOrderAttributeName)
350
            throws InitializeException;
351

    
352
    /**
353
     * Creates a {@link FeaturePagingHelper} to paginate data from a
354
     * {@link FeatureStore}.
355
     *
356
     * @param featureStore to get the {@link Feature}s from
357
     * @param pageSize the page size
358
     * @return a {@link FeaturePagingHelper}
359
     * @throws BaseException if there is an error creating the helper
360
     */
361
    public FeaturePagingHelper createFeaturePagingHelper(
362
            FeatureStore featureStore, int pageSize) throws BaseException;
363

    
364
    /**
365
     * Creates a {@link FeaturePagingHelper} to paginate data from a
366
     * {@link FeatureStore}.
367
     *
368
     * @param featureStore to get the {@link Feature}s from
369
     * @param featureQuery to filter and/or order the data
370
     * @param pageSize the page size
371
     * @return a {@link FeaturePagingHelper}
372
     * @throws BaseException if there is an error creating the helper
373
     */
374
    public FeaturePagingHelper createFeaturePagingHelper(
375
            FeatureStore featureStore, FeatureQuery featureQuery, int pageSize)
376
            throws BaseException;
377

    
378
    public void setOpenErrorHandler(OpenErrorHandler handler);
379

    
380
    public OpenErrorHandler getOpenErrorHandler();
381

    
382
    public DataStoreProviderFactory getStoreProviderFactory(String name);
383

    
384
    public EditableFeatureType createFeatureType();
385

    
386
    public DataServerExplorerPool getDataServerExplorerPool();
387

    
388
    public void setDataServerExplorerPool(DataServerExplorerPool pool);
389

    
390
    public void setResourcesLoader(ClassLoader loader);
391

    
392
    public void setResourcesLoader(File folder);
393

    
394
    /**
395
     * Return a list of the DataTypes supported for the type of the feature
396
     * attributes. The list is only informative.
397
     *
398
     * @return
399
     */
400
    public List<DataType> getDataTypes();
401

    
402
    public Register getStoreRegister();
403

    
404
    public Register getStoreProviderRegister();
405

    
406
    public Register getServerExplorerRegister();
407

    
408
    public Register getFeatureIndexRegister();
409

    
410
    /**
411
     * Creates a default ExpressionBuilder.
412
     * 
413
     * This ExpressionBuilder is not dependent on a data source, 
414
     * and is not advisable to use it.
415
     * 
416
     * @return the ExpressionBuilder
417
     */
418
    public ExpressionBuilder createExpressionBuilder();
419
    
420
    /**
421
         * Returns a list of String containing the names of the available cache providers.
422
         *
423
         * @return
424
         *                 list of strings with the names of the available cache providers
425
         */    
426
    public List getFeatureCacheProviders();
427

    
428
        /**
429
         * Returns an instance of {@link DataServerExplorerParameters} corresponding
430
         * to the given name used by the cache to create a store to save the
431
         * retrieved data.
432
         * 
433
         * @param name
434
         *            name of a registered feature cache provider
435
         * 
436
         * @throws InitializeException
437
         *             if parameter initialization causes an error.
438
         * 
439
         * @throws ProviderNotRegisteredException
440
         *             if could not find a cache provider by the given name.
441
         * 
442
         */
443
        public DynObject createCacheParameters(String name)
444
                        throws InitializeException, ProviderNotRegisteredException;
445
    
446
}