Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_dal / src / org / gvsig / fmap / dal / feature / FeatureStore.java @ 24961

History | View | Annotate | Download (13.4 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). A Feature is a tabular structure 
20
 * that contains alphanumeric and vectorial attributes. {@link Feature}(s) from the same FeatureStore can be of different
21
 * {@link FeatureType}(s) (as in GML format for instance).</p>
22
 * 
23
 * <p>The following are FeatureStore functionalities:</p>
24
 * <ul>
25
 *   <il>Obtaining the default {@link FeatureType}. A FeatureStore always has one and only one default FeatureType.</il>
26
 *   <il>Obtaining the list of {@link FeatureType}(s) defined in the FeatureStore.</il>
27
 *   <il>Obtaining, filtering and sorting subsets of data ({@link FeatureSet}) through {@link FeatureQuery}, as well 
28
 *   as background loading.</il>
29
 *   <il>Obtaining the total {@link Envelope} (AKA bounding box or extent) of the store.
30
 *   <il>Support for editing {@link FeatureType}(s).</il>
31
 *   <il>Obtaining information about contained {@link Geometry} types.</il>
32
 *         <il>Exporting to another store.</il>
33
 *   <il>Indexing.</il>
34
 *   <il>Selection.</il>
35
 *   <il>Locks management.</il>
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();
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 edition state.
220
         */
221
        public void edit() throws DataException;
222

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

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

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

    
246
        /**
247
         * Indicates whether this store is in edition state.
248
         * 
249
         * @return
250
         *                 true if this store is in edition 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 edition group. This is typically used to group 
388
         * series of store edition operations.
389
         * 
390
         * @param description
391
         *                                 Description of the edition group.                
392
         *         
393
         * @throws NeedEditingModeException
394
         */
395
        public void beginEditingGroup(String description)
396
                        throws NeedEditingModeException;
397

    
398
        /**
399
         * Finishes an edition 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 DataIndex with name indexName, given the attributeName and its featureType.
413
         * @param featureType
414
         * @param attributeName
415
         * @param indexName
416
         * @return
417
         * @throws FeatureIndexException
418
         */
419
        public FeatureIndex createIndex(FeatureType featureType,
420
                        String attributeName, String indexName) throws DataException;
421

    
422
        /**
423
         * Returns a FeatureIndexes structure containing all available indexes in
424
         * the store.
425
         *
426
         * @return
427
         */
428
        public FeatureIndexes getIndexes();
429

    
430
        /*
431
         * =============================================================
432
         *
433
         * Selection related services
434
         */
435
        
436
        /**
437
         * Sets the selection to the passed {@link FeatureSet}
438
         * 
439
         * @param selection
440
         *                                 A {@link FeatureSet} with the requested selection 
441
         */
442
        public void setSelection(FeatureSet selection) throws DataException;
443

    
444
        /**
445
         * Creates a {@link FeatureSelection}
446
         * 
447
         * @return
448
         *                 a {@link FeatureSelection}
449
         * 
450
         * @throws DataException
451
         */
452
        public FeatureSelection createFeatureSelection() throws DataException;
453

    
454
        /**
455
         * Returns the current {@link FeatureSelection}.
456
         * 
457
         * @return
458
         *                 current {@link FeatureSelection}.
459
         * 
460
         * @throws DataException
461
         */
462
        public FeatureSelection getFeatureSelection() throws DataException;
463

    
464
        /*
465
         * =============================================================
466
         *
467
         * Lock related services
468
         */
469

    
470
        /**
471
         * Indicates whether this store supports locks.
472
         * 
473
         * @return
474
         *                 true if this store supports locks, false if not.
475
         */
476
        public boolean isLocksSupported();
477

    
478
        /**
479
         * Returns the set of locked features
480
         * 
481
         * @return
482
         *                 set of locked features
483
         * 
484
         * @throws DataException
485
         */
486
        public FeatureSet getLocks() throws DataException;
487

    
488
        /*
489
         * =============================================================
490
         * Transforms related services
491
         * =============================================================
492
         */
493

    
494
        /**
495
         * Returns this store transforms
496
         * 
497
         * @return
498
         *                 this store transforms
499
         */
500
        public FeatureStoreTransforms getTransforms();
501
        
502
        /**
503
         * Returns a new {@link FeatureQuery} associated to this store.
504
         * 
505
         * @return
506
         *                 a new {@link FeatureQuery} associated to this store.
507
         */
508
        public FeatureQuery createFeatureQuery();
509
}
510