Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_dal / src / org / gvsig / fmap / dal / feature / FeatureStore.java @ 25481

History | View | Annotate | Download (14.3 KB)

1
package org.gvsig.fmap.dal.feature;
2

    
3
import java.util.List;
4

    
5
import org.gvsig.fmap.dal.DataServerExplorer;
6
import org.gvsig.fmap.dal.DataStore;
7
import org.gvsig.fmap.dal.DataStoreParameters;
8
import org.gvsig.fmap.dal.exception.DataException;
9
import org.gvsig.fmap.dal.exception.ReadException;
10
import org.gvsig.fmap.dal.feature.exception.FeatureIndexException;
11
import org.gvsig.fmap.dal.feature.exception.NeedEditingModeException;
12
import org.gvsig.fmap.geom.Geometry;
13
import org.gvsig.fmap.geom.primitive.Envelope;
14
import org.gvsig.tools.observer.Observer;
15
import org.gvsig.tools.undo.UndoRedoStack;
16

    
17
/**
18
 * <p>
19
 * A FeatureStore is a type of store whose data consists on sets of {@link Feature}(s). 
20
 * {@link Feature}(s) from the same FeatureStore can be of different {@link FeatureType}(s)
21
 * (as in GML format for instance).</p>
22
 *
23
 * <p>FeatureStore allows:</p>
24
 * <ul>
25
 *   <li>Obtaining the default {@link FeatureType}. A FeatureStore always has one and only one default FeatureType.
26
 *   <li>Obtaining the list of {@link FeatureType}(s) defined in the FeatureStore.
27
 *   <li>Obtaining, filtering and sorting subsets of data ({@link FeatureSet}) through {@link FeatureQuery}, as well 
28
 *   as background loading.
29
 *   <li>Obtaining the total {@link Envelope} (AKA bounding box or extent) of the store.
30
 *   <li>Support for editing {@link FeatureType}(s).
31
 *   <li>Obtaining information about contained {@link Geometry} types.
32
 *         <li>Exporting to another store.
33
 *   <li>Indexing.
34
 *   <li>Selection.
35
 *   <li>Locks management.
36
 * </ul>
37
 *
38
 */
39
public interface FeatureStore extends DataStore, UndoRedoStack {
40

    
41
        /** Indicates that this store is in query mode */
42
        final static int MODE_QUERY = 0;
43

    
44
        /** Indicates that this store is in full edit mode */
45
        final static int MODE_FULLEDIT = 1;
46

    
47
        /** Indicates that this store is in append mode */
48
        final static int MODE_APPEND = 2;
49

    
50
        /*
51
         * =============================================================
52
         *
53
         * information related services
54
         */
55

    
56
        /**
57
         * Indicates whether this store allows writing.
58
         *
59
         * @return
60
         *                 true if this store can be written, false if not.
61
         */
62
        public boolean allowWrite();
63

    
64
        /**
65
         * Returns this store's default {@link FeatureType}.
66
         *
67
         * @return
68
         *                 this store's default {@link FeatureType}.
69
         *
70
         * @throws DataException
71
         */
72
        public FeatureType getDefaultFeatureType() throws DataException;
73

    
74
        /**
75
         * Returns this store's {@link FeatureType}(s).
76
         *
77
         * @return
78
         *                 a list with this store's {@link FeatureType}(s).
79
         *
80
         * @throws DataException
81
         */
82
        public List getFeatureTypes() throws DataException;
83

    
84
        /**
85
         * Returns this store's parameters.
86
         *
87
         * @return
88
         *                 {@link DataStoreParameters} containing this store's parameters
89
         */
90
        public DataStoreParameters getParameters();
91

    
92
        /**
93
         *@throws DataException
94
         * @deprecated Mirar de cambiarlo a metadatos
95
         */
96
        public boolean canWriteGeometry(int gvSIGgeometryType) throws DataException;
97

    
98
        /**
99
         * Returns this store's total envelope (extent).
100
         *
101
         * @return
102
         *                 this store's total envelope (extent).
103
         */
104
        public Envelope getEnvelope() throws DataException;
105

    
106
        /**
107
         *
108
         * @deprecated use getDefaultFeatureType().getDefaultSRS()
109
         * @return
110
         * @throws DataException
111
         */
112
        public String getSRSDefaultGeometry() throws DataException;
113

    
114
        /**
115
         * Exports this store to another store.
116
         *
117
         * @param explorer
118
         *            {@link DataServerExplorer} target
119
         * @param params
120
         *                                 New parameters of this store that will be used on the target explorer
121
         *
122
         * @throws DataException
123
         */
124
        public void export(DataServerExplorer explorer, NewFeatureStoreParameters params)
125
                        throws DataException;
126

    
127
        /*
128
         * =============================================================
129
         *
130
         * Query related services
131
         */
132

    
133
        /**
134
         * Returns all available features in the store.
135
         *
136
         * @return a collection of features
137
         * @throws ReadException
138
         *             if there is any error while reading the features
139
         */
140
        FeatureSet getFeatureSet() throws DataException;
141

    
142
        /**
143
         * Returns a subset of features taking into account the properties and
144
         * restrictions of the FeatureQuery.
145
         *
146
         * @param featureQuery
147
         *            defines the characteristics of the features to return
148
         * @return a collection of features
149
         * @throws ReadException
150
         *             if there is any error while reading the features
151
         */
152
        FeatureSet getFeatureSet(FeatureQuery featureQuery)
153
         throws DataException;
154

    
155
        /**
156
         * Loads a subset of features taking into account the properties and
157
         * restrictions of the FeatureQuery. Feature loading is performed by calling
158
         * the Observer, once each loaded Feature.
159
         *
160
         * @param featureQuery
161
         *            defines the characteristics of the features to return
162
         * @param observer
163
         *            to be notified of each loaded Feature
164
         * @throws DataException
165
         *             if there is any error while loading the features
166
         */
167
        void getFeatureSet(FeatureQuery featureQuery, Observer observer)
168
        throws DataException;
169

    
170
        /**
171
         * Loads all available feature in the store. The loading of Features is
172
         * performed by calling the Observer, once each loaded Feature.
173
         *
174
         * @param observer
175
         *            to be notified of each loaded Feature
176
         * @throws DataException
177
         *             if there is any error while loading the features
178
         */
179
        void getFeatureSet(Observer observer) throws DataException;
180

    
181
        /**
182
         * Returns the feature given its reference.
183
         *
184
         * @param reference
185
         *            a unique FeatureReference
186
         * @return
187
         *                 The Feature
188
         *
189
         * @throws DataException
190
         *
191
         */
192
        public Feature getFeatureByReference(FeatureReference reference) throws DataException;
193

    
194
        /**
195
         * Returns the feature given its reference and feature type.
196
         *
197
         * @param reference
198
         *            a unique FeatureReference
199
         *
200
         * @param featureType
201
         *            FeatureType to which the requested Feature belongs
202
         *
203
         * @return
204
         *                 The Feature
205
         *
206
         * @throws DataException
207
         *
208
         */
209
        public Feature getFeatureByReference(FeatureReference reference, FeatureType featureType)
210
                        throws DataException;
211

    
212
        /*
213
         * =============================================================
214
         *
215
         * Editing related services
216
         */
217

    
218
        /**
219
         * Enters editing state.
220
         */
221
        public void edit() throws DataException;
222

    
223
        /**
224
         * Enters editing state specifying the editing mode.
225
         *
226
         * @param mode
227
         *
228
         * @throws DataException
229
         */
230
        public void edit(int mode) throws DataException;
231

    
232
        /**
233
         * Cancels all editing since the last edit().
234
         *
235
         * @throws DataException
236
         */
237
        public void cancelEditing() throws DataException;
238

    
239
        /**
240
         * Exits editing state.
241
         *
242
         * @throws DataException
243
         */
244
        public void finishEditing() throws DataException;
245

    
246
        /**
247
         * Indicates whether this store is in editing state.
248
         *
249
         * @return
250
         *                 true if this store is in editing state, false if not.
251
         */
252
        public boolean isEditing();
253

    
254
        /**
255
         * Indicates whether this store is in appending state. In this state
256
         * the new features are automatically inserted at the end of the 
257
         * {@link FeatureSet}.
258
         *
259
         * @return
260
         *                 true if this store is in appending state.
261
         */
262
        public boolean isAppending();
263

    
264
        /**
265
         * Updates a {@link FeatureType} in the store with the changes in the {@link EditableFeatureType}.
266
         *
267
         * @param featureType
268
         *            an {@link EditableFeatureType} with the changes.
269
         *
270
         * @throws DataException
271
         */
272
        public void update(EditableFeatureType featureType) throws DataException;
273

    
274
        /**
275
         * Updates a {@link Feature} in the store with the changes in the {@link EditableFeature}.
276
         *
277
         * @param feature
278
         *            the feature to be updated
279
         *
280
         * @throws DataException
281
         */
282
        public void update(EditableFeature feature) throws DataException;
283

    
284
        /**
285
         * Deletes a {@link Feature} from the store.
286
         *
287
         * @param feature
288
         *            The feature to be deleted.
289
         *
290
         * @throws DataException
291
         */
292
        public void delete(Feature feature) throws DataException;
293

    
294
        /**
295
         * Inserts a {@link Feature} in the store.
296
         *
297
         * @param feature
298
         *            The feature to be inserted
299
         *
300
         * @throws DataException
301
         */
302
        public void insert(EditableFeature feature) throws DataException;
303

    
304
        /**
305
         * Creates a new feature using the default feature type and 
306
         * returns it as an {@link EditableFeature}
307
         *
308
         * @return
309
         *                 a new feature in editable state
310
         *
311
         * @throws DataException
312
         */
313
        public EditableFeature createNewFeature() throws DataException;
314

    
315
        /**
316
         * Creates a new feature of the given {@link FeatureType} and uses
317
         * the given {@link Feature} as default values to initialize it.
318
         *
319
         * @param type
320
         *            the new feature's feature type
321
         *
322
         * @param defaultValues
323
         *                         a feature whose values are used as default values for the new feature.
324
         *
325
         * @return 
326
         *                 the new feature.
327
         *
328
         * @throws DataException
329
         */
330
        public EditableFeature createNewFeature(FeatureType type,
331
                        Feature defaultValues) throws DataException;
332

    
333
        /**
334
         * Creates a new feature of the given {@link FeatureType}. The flag
335
         * defaultValues is used to indicate whether the new feature should be
336
         * initialized with default values or not.
337
         *
338
         * @param type
339
         *            the new feature's feature type
340
         *
341
         * @param defaultValues
342
         *                         if true the new feature is initialized with each attribute's default value.
343
         *
344
         * @return
345
         *                 the new feature
346
         *
347
         * @throws DataException
348
         */
349
        public EditableFeature createNewFeature(FeatureType type,
350
                        boolean defaultValues) throws DataException;
351

    
352
        /**
353
         * Creates a new feature of default {@link FeatureType}. The flag
354
         * defaultValues is used to indicate whether the new feature should be
355
         * initialized with default values or not.
356
         *
357
         * @param defaultValues
358
         *                                 if true the new feature is initialized with each attribute's default value.
359
         *
360
         * @return
361
         *                 the new feature
362
         *
363
         * @throws DataException
364
         */
365
        public EditableFeature createNewFeature(boolean defaultValues)
366
                        throws DataException;
367

    
368
        /**
369
         * Applies the validation rules associated to the given mode to the active {@link FeatureSet}.
370
         *
371
         * @param mode
372
         *            can be one of {MODE_QUERY, MODE_FULLEDIT, MODE_APPEND}
373
         *
374
         * @throws DataException
375
         */
376
        public void validateFeatures(int mode) throws DataException;
377

    
378
        /**
379
         * Indicates whether this store supports append mode.
380
         *
381
         * @return
382
         *                 true if this store supports append mode.
383
         */
384
        public boolean isAppendModeSupported();
385

    
386
        /**
387
         * Initiates an editing group. This is typically used to group 
388
         * series of store editing operations.
389
         *
390
         * @param description
391
         *            Description of the editing group.
392
         *
393
         * @throws NeedEditingModeException
394
         */
395
        public void beginEditingGroup(String description)
396
                        throws NeedEditingModeException;
397

    
398
        /**
399
         * Finishes an editing group.
400
         *
401
         * @throws NeedEditingModeException
402
         */
403
        public void endEditingGroup() throws NeedEditingModeException;
404

    
405
        /*
406
         * =============================================================
407
         *
408
         * Index related services
409
         */
410

    
411
        /**
412
         * Creates a FeatureIndex with name indexName, given the attributeName and its featureType.
413
         * 
414
         * @param featureType
415
         *                                 The FeatureType to which the indexed attribute belongs.
416
         * 
417
         * @param attributeName
418
         *                                 The name of the attributed to be indexed
419
         * 
420
         * @param indexName
421
         *                                 The index name
422
         * 
423
         * @return
424
         *                 the resulting FeatureIndex 
425
         * 
426
         * 
427
         * @throws FeatureIndexException
428
         */
429
        public FeatureIndex createIndex(FeatureType featureType,
430
                        String attributeName, String indexName) throws DataException;
431

    
432
        /**
433
         * Creates a FeatureIndex with name indexName, given the attributeName and its featureType.
434
         * This method is intended for background indexing. It receives an observer that will be notified 
435
         * by the process.
436
         * 
437
         * @param featureType
438
         *                                 The FeatureType to which the indexed attribute belongs.
439
         * 
440
         * @param attributeName
441
         *                                 The name of the attributed to be indexed
442
         * 
443
         * @param indexName
444
         *                                 The index name
445
         * 
446
         * @param observer
447
         *                                 an observer that will be notified of the indexing process progress.
448
         * 
449
         * @return
450
         *                 the resulting FeatureIndex 
451
         * 
452
         * 
453
         * @throws FeatureIndexException
454
         */        
455
        public FeatureIndex createIndex(FeatureType featureType,
456
                        String attributeName, String indexName, Observer observer) throws DataException;
457
        /**
458
         * Returns a FeatureIndexes structure containing all available indexes in
459
         * the store.
460
         *
461
         * @return
462
         */
463
        public FeatureIndexes getIndexes();
464

    
465
        /*
466
         * =============================================================
467
         *
468
         * Selection related services
469
         */
470

    
471
        /**
472
         * Sets the selection to the passed {@link FeatureSet}
473
         *
474
         * @param selection
475
         *            A {@link FeatureSet} with the requested selection
476
         */
477
        public void setSelection(FeatureSet selection) throws DataException;
478

    
479
        /**
480
         * Creates a {@link FeatureSelection}
481
         *
482
         * @return
483
         *                 a {@link FeatureSelection}
484
         *
485
         * @throws DataException
486
         */
487
        public FeatureSelection createFeatureSelection() throws DataException;
488

    
489
        /**
490
         * Returns the current {@link FeatureSelection}.
491
         *
492
         * @return
493
         *                 current {@link FeatureSelection}.
494
         *
495
         * @throws DataException
496
         */
497
        public FeatureSelection getFeatureSelection() throws DataException;
498

    
499
        /*
500
         * =============================================================
501
         *
502
         * Lock related services
503
         */
504

    
505
        /**
506
         * Indicates whether this store supports locks.
507
         *
508
         * @return
509
         *                 true if this store supports locks, false if not.
510
         */
511
        public boolean isLocksSupported();
512

    
513
        /**
514
         * Returns the set of locked features
515
         *
516
         * @return
517
         *                 set of locked features
518
         *
519
         * @throws DataException
520
         */
521
        public FeatureSet getLocks() throws DataException;
522

    
523
        /*
524
         * =============================================================
525
         * Transforms related services
526
         * =============================================================
527
         */
528

    
529
        /**
530
         * Returns this store transforms
531
         *
532
         * @return
533
         *                 this store transforms
534
         */
535
        public FeatureStoreTransforms getTransforms();
536

    
537
        /**
538
         * Returns a new {@link FeatureQuery} associated to this store.
539
         *
540
         * @return
541
         *                 a new {@link FeatureQuery} associated to this store.
542
         */
543
        public FeatureQuery createFeatureQuery();
544
}
545