root / branches / v2_0_0_prep / libraries / libFMap_dal / src / org / gvsig / fmap / dal / feature / FeatureStore.java @ 32735
History | View | Annotate | Download (17.2 KB)
1 |
package org.gvsig.fmap.dal.feature; |
---|---|
2 |
|
3 |
import java.util.Iterator; |
4 |
import java.util.List; |
5 |
|
6 |
import org.cresques.cts.IProjection; |
7 |
import org.gvsig.fmap.dal.DataServerExplorer; |
8 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
9 |
import org.gvsig.fmap.dal.DataStore; |
10 |
import org.gvsig.fmap.dal.DataStoreParameters; |
11 |
import org.gvsig.fmap.dal.exception.DataException; |
12 |
import org.gvsig.fmap.dal.exception.ReadException; |
13 |
import org.gvsig.fmap.dal.feature.exception.FeatureIndexException; |
14 |
import org.gvsig.fmap.dal.feature.exception.NeedEditingModeException; |
15 |
import org.gvsig.fmap.geom.Geometry; |
16 |
import org.gvsig.fmap.geom.primitive.Envelope; |
17 |
import org.gvsig.tools.dynobject.DynObject; |
18 |
import org.gvsig.tools.observer.Observer; |
19 |
import org.gvsig.tools.undo.UndoRedoStack; |
20 |
|
21 |
/**
|
22 |
* <p>
|
23 |
* A FeatureStore is a type of store whose data consists on sets of
|
24 |
* {@link Feature}(s). {@link Feature}(s) from the same FeatureStore can be of
|
25 |
* different {@link FeatureType}(s) (as in GML format for instance).
|
26 |
* </p>
|
27 |
*
|
28 |
* <p>
|
29 |
* FeatureStore allows:
|
30 |
* </p>
|
31 |
* <ul>
|
32 |
* <li>Obtaining the default {@link FeatureType}. A FeatureStore always has one
|
33 |
* and only one default FeatureType.
|
34 |
* <li>Obtaining the list of {@link FeatureType}(s) defined in the FeatureStore.
|
35 |
* <li>Obtaining, filtering and sorting subsets of data ({@link FeatureSet})
|
36 |
* through {@link FeatureQuery}, as well as background loading.
|
37 |
* <li>Obtaining the total {@link Envelope} (AKA bounding box or extent) of the
|
38 |
* store.
|
39 |
* <li>Support for editing {@link FeatureType}(s).
|
40 |
* <li>Obtaining information about contained {@link Geometry} types.
|
41 |
* <li>Exporting to another store.
|
42 |
* <li>Indexing.
|
43 |
* <li>Selection.
|
44 |
* <li>Locks management.
|
45 |
* </ul>
|
46 |
*
|
47 |
*/
|
48 |
public interface FeatureStore extends DataStore, UndoRedoStack { |
49 |
|
50 |
public static final String DYNCLASS_NAME = "FeatureStore"; |
51 |
|
52 |
/** Indicates that this store is in query mode */
|
53 |
final static int MODE_QUERY = 0; |
54 |
|
55 |
/** Indicates that this store is in full edit mode */
|
56 |
final static int MODE_FULLEDIT = 1; |
57 |
|
58 |
/** Indicates that this store is in append mode */
|
59 |
final static int MODE_APPEND = 2; |
60 |
|
61 |
/*
|
62 |
* =============================================================
|
63 |
*
|
64 |
* information related services
|
65 |
*/
|
66 |
|
67 |
/**
|
68 |
* Indicates whether this store allows writing.
|
69 |
*
|
70 |
* @return
|
71 |
* true if this store can be written, false if not.
|
72 |
*/
|
73 |
public boolean allowWrite(); |
74 |
|
75 |
/**
|
76 |
* Returns this store's default {@link FeatureType}.
|
77 |
*
|
78 |
* @return
|
79 |
* this store's default {@link FeatureType}.
|
80 |
*
|
81 |
* @throws DataException
|
82 |
*/
|
83 |
public FeatureType getDefaultFeatureType() throws DataException; |
84 |
|
85 |
/**
|
86 |
* Returns this store's featureType {@link FeatureType} matches with
|
87 |
* featureTypeId.
|
88 |
*
|
89 |
* @param featureTypeId
|
90 |
*
|
91 |
* @return this store's default {@link FeatureType}.
|
92 |
*
|
93 |
* @throws DataException
|
94 |
*/
|
95 |
public FeatureType getFeatureType(String featureTypeId) |
96 |
throws DataException;
|
97 |
|
98 |
/**
|
99 |
* Returns this store's {@link FeatureType}(s).
|
100 |
*
|
101 |
* @return a list with this store's {@link FeatureType}(s).
|
102 |
*
|
103 |
* @throws DataException
|
104 |
*/
|
105 |
public List getFeatureTypes() throws DataException; |
106 |
|
107 |
/**
|
108 |
* Returns this store's parameters.
|
109 |
*
|
110 |
* @return
|
111 |
* {@link DataStoreParameters} containing this store's parameters
|
112 |
*/
|
113 |
public DataStoreParameters getParameters();
|
114 |
|
115 |
/**
|
116 |
*@throws DataException
|
117 |
* @deprecated Mirar de cambiarlo a metadatos
|
118 |
*/
|
119 |
public boolean canWriteGeometry(int gvSIGgeometryType) throws DataException; |
120 |
|
121 |
/**
|
122 |
* Returns this store's total envelope (extent).
|
123 |
*
|
124 |
* @return this store's total envelope (extent) or <code>null</code> if
|
125 |
* store not have geometry information
|
126 |
*/
|
127 |
public Envelope getEnvelope() throws DataException; |
128 |
|
129 |
/**
|
130 |
*
|
131 |
* @deprecated use getDefaultFeatureType().getDefaultSRS()
|
132 |
* @return
|
133 |
* @throws DataException
|
134 |
*/
|
135 |
public IProjection getSRSDefaultGeometry() throws DataException; |
136 |
|
137 |
/**
|
138 |
* Exports this store to another store.
|
139 |
*
|
140 |
* @param explorer
|
141 |
* {@link DataServerExplorer} target
|
142 |
* @param params
|
143 |
* New parameters of this store that will be used on the target
|
144 |
* explorer
|
145 |
*
|
146 |
* @throws DataException
|
147 |
*
|
148 |
* @Deprecated this method is unstable
|
149 |
*/
|
150 |
public void export(DataServerExplorer explorer, NewFeatureStoreParameters params) |
151 |
throws DataException;
|
152 |
|
153 |
/*
|
154 |
* =============================================================
|
155 |
*
|
156 |
* Query related services
|
157 |
*/
|
158 |
|
159 |
/**
|
160 |
* Returns all available features in the store.
|
161 |
* <p>
|
162 |
* <em>
|
163 |
* <strong>NOTE:</strong> if you use this method to get a
|
164 |
* {@link FeatureSet}, you must get sure it is disposed
|
165 |
* (@see {@link DisposableIterator#dispose()}) in any case, even if an
|
166 |
* error occurs while getting the data. It is recommended to use the
|
167 |
* <code>accept</code> methods instead, which handle everything for you.
|
168 |
* Take into account the accept methods may use a fast iterator to
|
169 |
* get the features.
|
170 |
* </em>
|
171 |
* </p>
|
172 |
*
|
173 |
* @see #accept(org.gvsig.tools.visitor.Visitor)
|
174 |
*
|
175 |
* @return a collection of features
|
176 |
* @throws ReadException
|
177 |
* if there is any error while reading the features
|
178 |
*/
|
179 |
FeatureSet getFeatureSet() throws DataException;
|
180 |
|
181 |
/**
|
182 |
* Returns a subset of features taking into account the properties and
|
183 |
* restrictions of the FeatureQuery.
|
184 |
* <p>
|
185 |
* <em>
|
186 |
* <strong>NOTE:</strong> if you use this method to get a
|
187 |
* {@link FeatureSet}, you must get sure it is disposed
|
188 |
* (@see {@link DisposableIterator#dispose()}) in any case, even if an
|
189 |
* error occurs while getting the data. It is recommended to use the
|
190 |
* <code>accept</code> methods instead, which handle everything for you.
|
191 |
* Take into account the accept methods may use a fast iterator to
|
192 |
* get the features.
|
193 |
* </em>
|
194 |
* </p>
|
195 |
*
|
196 |
* @see #accept(org.gvsig.tools.visitor.Visitor,
|
197 |
* org.gvsig.fmap.dal.DataQuery)
|
198 |
*
|
199 |
* @param featureQuery
|
200 |
* defines the characteristics of the features to return
|
201 |
* @return a collection of features
|
202 |
* @throws ReadException
|
203 |
* if there is any error while reading the features
|
204 |
*/
|
205 |
FeatureSet getFeatureSet(FeatureQuery featureQuery) |
206 |
throws DataException;
|
207 |
|
208 |
/**
|
209 |
* Loads a subset of features taking into account the properties and
|
210 |
* restrictions of the FeatureQuery. Feature loading is performed by calling
|
211 |
* the Observer, once each loaded Feature.
|
212 |
*
|
213 |
* @param featureQuery
|
214 |
* defines the characteristics of the features to return
|
215 |
* @param observer
|
216 |
* to be notified of each loaded Feature
|
217 |
* @throws DataException
|
218 |
* if there is any error while loading the features
|
219 |
*/
|
220 |
void getFeatureSet(FeatureQuery featureQuery, Observer observer) |
221 |
throws DataException;
|
222 |
|
223 |
/**
|
224 |
* Loads all available feature in the store. The loading of Features is
|
225 |
* performed by calling the Observer, once each loaded Feature.
|
226 |
*
|
227 |
* @param observer
|
228 |
* to be notified of each loaded Feature
|
229 |
* @throws DataException
|
230 |
* if there is any error while loading the features
|
231 |
*/
|
232 |
void getFeatureSet(Observer observer) throws DataException; |
233 |
|
234 |
/**
|
235 |
* Returns the feature given its reference.
|
236 |
*
|
237 |
* @param reference
|
238 |
* a unique FeatureReference
|
239 |
* @return
|
240 |
* The Feature
|
241 |
*
|
242 |
* @throws DataException
|
243 |
*
|
244 |
*/
|
245 |
public Feature getFeatureByReference(FeatureReference reference) throws DataException; |
246 |
|
247 |
/**
|
248 |
* Returns the feature given its reference and feature type.
|
249 |
*
|
250 |
* @param reference
|
251 |
* a unique FeatureReference
|
252 |
*
|
253 |
* @param featureType
|
254 |
* FeatureType to which the requested Feature belongs
|
255 |
*
|
256 |
* @return
|
257 |
* The Feature
|
258 |
*
|
259 |
* @throws DataException
|
260 |
*
|
261 |
*/
|
262 |
public Feature getFeatureByReference(FeatureReference reference, FeatureType featureType)
|
263 |
throws DataException;
|
264 |
|
265 |
/*
|
266 |
* =============================================================
|
267 |
*
|
268 |
* Editing related services
|
269 |
*/
|
270 |
|
271 |
/**
|
272 |
* Enters editing state.
|
273 |
*/
|
274 |
public void edit() throws DataException; |
275 |
|
276 |
/**
|
277 |
* Enters editing state specifying the editing mode.
|
278 |
*
|
279 |
* @param mode
|
280 |
*
|
281 |
* @throws DataException
|
282 |
*/
|
283 |
public void edit(int mode) throws DataException; |
284 |
|
285 |
/**
|
286 |
* Cancels all editing since the last edit().
|
287 |
*
|
288 |
* @throws DataException
|
289 |
*/
|
290 |
public void cancelEditing() throws DataException; |
291 |
|
292 |
/**
|
293 |
* Exits editing state.
|
294 |
*
|
295 |
* @throws DataException
|
296 |
*/
|
297 |
public void finishEditing() throws DataException; |
298 |
|
299 |
/**
|
300 |
* Indicates whether this store is in editing state.
|
301 |
*
|
302 |
* @return
|
303 |
* true if this store is in editing state, false if not.
|
304 |
*/
|
305 |
public boolean isEditing(); |
306 |
|
307 |
/**
|
308 |
* Indicates whether this store is in appending state. In this state the new
|
309 |
* features are automatically inserted at the end of the {@link FeatureSet}.
|
310 |
*
|
311 |
* @return true if this store is in appending state.
|
312 |
*/
|
313 |
public boolean isAppending(); |
314 |
|
315 |
/**
|
316 |
* Updates a {@link FeatureType} in the store with the changes in the
|
317 |
* {@link EditableFeatureType}.<br>
|
318 |
*
|
319 |
* Any {@link FeatureSet} from this store that are used will be invalidated.
|
320 |
*
|
321 |
* @param featureType
|
322 |
* an {@link EditableFeatureType} with the changes.
|
323 |
*
|
324 |
* @throws DataException
|
325 |
*/
|
326 |
public void update(EditableFeatureType featureType) throws DataException; |
327 |
|
328 |
/**
|
329 |
* Updates a {@link Feature} in the store with the changes in the
|
330 |
* {@link EditableFeature}.<br>
|
331 |
*
|
332 |
* Any {@link FeatureSet} from this store that was still in use will be
|
333 |
* invalidated. You can override this using
|
334 |
* {@link FeatureSet#update(EditableFeature)}.
|
335 |
*
|
336 |
* @param feature
|
337 |
* the feature to be updated
|
338 |
*
|
339 |
* @throws DataException
|
340 |
*/
|
341 |
public void update(EditableFeature feature) throws DataException; |
342 |
|
343 |
/**
|
344 |
* Deletes a {@link Feature} from the store.<br>
|
345 |
*
|
346 |
* Any {@link FeatureSet} from this store that was still in use will be
|
347 |
* invalidated. You can override this using {@link Iterator#remove()} from
|
348 |
* {@link FeatureSet}.
|
349 |
*
|
350 |
* @param feature
|
351 |
* The feature to be deleted.
|
352 |
*
|
353 |
* @throws DataException
|
354 |
*/
|
355 |
public void delete(Feature feature) throws DataException; |
356 |
|
357 |
/**
|
358 |
* Inserts a {@link Feature} in the store.<br>
|
359 |
*
|
360 |
* Any {@link FeatureSet} from this store that was still in use will be
|
361 |
* invalidated. You can override this using
|
362 |
* {@link FeatureSet#insert(EditableFeature)}.
|
363 |
*
|
364 |
* @param feature
|
365 |
* The feature to be inserted
|
366 |
*
|
367 |
* @throws DataException
|
368 |
*/
|
369 |
public void insert(EditableFeature feature) throws DataException; |
370 |
|
371 |
/**
|
372 |
* Creates a new feature using the default feature type and returns it as an
|
373 |
* {@link EditableFeature}
|
374 |
*
|
375 |
* @return a new feature in editable state
|
376 |
*
|
377 |
* @throws DataException
|
378 |
*/
|
379 |
public EditableFeature createNewFeature() throws DataException; |
380 |
|
381 |
/**
|
382 |
* Creates a new feature of the given {@link FeatureType} and uses the given
|
383 |
* {@link Feature} as default values to initialize it.
|
384 |
*
|
385 |
* @param type
|
386 |
* the new feature's feature type
|
387 |
*
|
388 |
* @param defaultValues
|
389 |
* a feature whose values are used as default values for the new
|
390 |
* feature.
|
391 |
*
|
392 |
* @return the new feature.
|
393 |
*
|
394 |
* @throws DataException
|
395 |
*/
|
396 |
public EditableFeature createNewFeature(FeatureType type,
|
397 |
Feature defaultValues) throws DataException;
|
398 |
|
399 |
/**
|
400 |
* Creates a new feature of the given {@link FeatureType}. The flag
|
401 |
* defaultValues is used to indicate whether the new feature should be
|
402 |
* initialized with default values or not.
|
403 |
*
|
404 |
* @param type
|
405 |
* the new feature's feature type
|
406 |
*
|
407 |
* @param defaultValues
|
408 |
* if true the new feature is initialized with each attribute's default value.
|
409 |
*
|
410 |
* @return
|
411 |
* the new feature
|
412 |
*
|
413 |
* @throws DataException
|
414 |
*/
|
415 |
public EditableFeature createNewFeature(FeatureType type,
|
416 |
boolean defaultValues) throws DataException; |
417 |
|
418 |
/**
|
419 |
* Creates a new feature of default {@link FeatureType}. The flag
|
420 |
* defaultValues is used to indicate whether the new feature should be
|
421 |
* initialized with default values or not.
|
422 |
*
|
423 |
* @param defaultValues
|
424 |
* if true the new feature is initialized with each attribute's default value.
|
425 |
*
|
426 |
* @return
|
427 |
* the new feature
|
428 |
*
|
429 |
* @throws DataException
|
430 |
*/
|
431 |
public EditableFeature createNewFeature(boolean defaultValues) |
432 |
throws DataException;
|
433 |
|
434 |
/**
|
435 |
* Applies the validation rules associated to the given mode to the active {@link FeatureSet}.
|
436 |
*
|
437 |
* @param mode
|
438 |
* can be one of {MODE_QUERY, MODE_FULLEDIT, MODE_APPEND}
|
439 |
*
|
440 |
* @throws DataException
|
441 |
*/
|
442 |
public void validateFeatures(int mode) throws DataException; |
443 |
|
444 |
/**
|
445 |
* Indicates whether this store supports append mode.
|
446 |
*
|
447 |
* @return
|
448 |
* true if this store supports append mode.
|
449 |
*/
|
450 |
public boolean isAppendModeSupported(); |
451 |
|
452 |
/**
|
453 |
* Initiates an editing group. This is typically used to group series of
|
454 |
* store editing operations.
|
455 |
*
|
456 |
* @param description
|
457 |
* Description of the editing group.
|
458 |
*
|
459 |
* @throws NeedEditingModeException
|
460 |
*/
|
461 |
public void beginEditingGroup(String description) |
462 |
throws NeedEditingModeException;
|
463 |
|
464 |
/**
|
465 |
* Finishes an editing group.
|
466 |
*
|
467 |
* @throws NeedEditingModeException
|
468 |
*/
|
469 |
public void endEditingGroup() throws NeedEditingModeException; |
470 |
|
471 |
/*
|
472 |
* =============================================================
|
473 |
*
|
474 |
* Index related services
|
475 |
*/
|
476 |
|
477 |
/**
|
478 |
* Creates a FeatureIndex with name indexName, given the attributeName and
|
479 |
* its featureType.
|
480 |
*
|
481 |
* @param featureType
|
482 |
* The FeatureType to which the indexed attribute belongs.
|
483 |
*
|
484 |
* @param attributeName
|
485 |
* The name of the attributed to be indexed
|
486 |
*
|
487 |
* @param indexName
|
488 |
* The index name
|
489 |
*
|
490 |
* @return the resulting FeatureIndex
|
491 |
*
|
492 |
*
|
493 |
* @throws FeatureIndexException
|
494 |
*/
|
495 |
public FeatureIndex createIndex(FeatureType featureType,
|
496 |
String attributeName, String indexName) throws DataException; |
497 |
|
498 |
/**
|
499 |
* Creates a FeatureIndex with name indexName, given the attributeName and
|
500 |
* its featureType. This method is intended for background indexing. It
|
501 |
* receives an observer that will be notified by the process.
|
502 |
*
|
503 |
* @param featureType
|
504 |
* The FeatureType to which the indexed attribute belongs.
|
505 |
*
|
506 |
* @param attributeName
|
507 |
* The name of the attributed to be indexed
|
508 |
*
|
509 |
* @param indexName
|
510 |
* The index name
|
511 |
*
|
512 |
* @param observer
|
513 |
* an observer that will be notified of the indexing process
|
514 |
* progress.
|
515 |
*
|
516 |
* @return the resulting FeatureIndex
|
517 |
*
|
518 |
*
|
519 |
* @throws FeatureIndexException
|
520 |
*/
|
521 |
public FeatureIndex createIndex(FeatureType featureType,
|
522 |
String attributeName, String indexName, Observer observer) throws DataException; |
523 |
/**
|
524 |
* Returns a FeatureIndexes structure containing all available indexes in
|
525 |
* the store.
|
526 |
*
|
527 |
* @return
|
528 |
*/
|
529 |
public FeatureIndexes getIndexes();
|
530 |
|
531 |
/*
|
532 |
* =============================================================
|
533 |
*
|
534 |
* Selection related services
|
535 |
*/
|
536 |
|
537 |
/**
|
538 |
* Sets the selection to the passed {@link FeatureSet}
|
539 |
*
|
540 |
* @param selection
|
541 |
* A {@link FeatureSet} with the requested selection
|
542 |
*/
|
543 |
public void setSelection(FeatureSet selection) throws DataException; |
544 |
|
545 |
/**
|
546 |
* Creates a {@link FeatureSelection}
|
547 |
*
|
548 |
* @return
|
549 |
* a {@link FeatureSelection}
|
550 |
*
|
551 |
* @throws DataException
|
552 |
*/
|
553 |
public FeatureSelection createFeatureSelection() throws DataException; |
554 |
|
555 |
/**
|
556 |
* Returns the current {@link FeatureSelection}.
|
557 |
*
|
558 |
* @return
|
559 |
* current {@link FeatureSelection}.
|
560 |
*
|
561 |
* @throws DataException
|
562 |
*/
|
563 |
public FeatureSelection getFeatureSelection() throws DataException; |
564 |
|
565 |
/*
|
566 |
* =============================================================
|
567 |
*
|
568 |
* Lock related services
|
569 |
*/
|
570 |
|
571 |
/**
|
572 |
* Indicates whether this store supports locks.
|
573 |
*
|
574 |
* @return
|
575 |
* true if this store supports locks, false if not.
|
576 |
*/
|
577 |
public boolean isLocksSupported(); |
578 |
|
579 |
/**
|
580 |
* Returns the set of locked features
|
581 |
*
|
582 |
* @return
|
583 |
* set of locked features
|
584 |
*
|
585 |
* @throws DataException
|
586 |
*/
|
587 |
public FeatureLocks getLocks() throws DataException; |
588 |
|
589 |
/*
|
590 |
* =============================================================
|
591 |
* Transforms related services
|
592 |
* =============================================================
|
593 |
*/
|
594 |
|
595 |
/**
|
596 |
* Returns this store transforms
|
597 |
*
|
598 |
* @return
|
599 |
* this store transforms
|
600 |
*/
|
601 |
public FeatureStoreTransforms getTransforms();
|
602 |
|
603 |
/**
|
604 |
* Returns a new {@link FeatureQuery} associated to this store.
|
605 |
*
|
606 |
* @return
|
607 |
* a new {@link FeatureQuery} associated to this store.
|
608 |
*/
|
609 |
public FeatureQuery createFeatureQuery();
|
610 |
|
611 |
/**
|
612 |
* Returns featue count of this store.
|
613 |
*
|
614 |
* @return
|
615 |
* @throws DataException
|
616 |
*/
|
617 |
public long getFeatureCount() throws DataException; |
618 |
|
619 |
/**
|
620 |
* Creates a vectorial cache that is used to save and retrieve data.
|
621 |
* @param name the cache name.
|
622 |
* @param parameters parameters to create the stores used to save data.
|
623 |
* @throws DataException
|
624 |
*/
|
625 |
public void createCache(String name, DynObject parameters) throws DataException; |
626 |
|
627 |
|
628 |
/**
|
629 |
* @return the vectorial cache
|
630 |
*/
|
631 |
public FeatureCache getCache();
|
632 |
} |
633 |
|