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 / feature / FeatureStore.java @ 44023

History | View | Annotate | Download (29.5 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
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.dal.feature;
25

    
26
import java.util.Iterator;
27
import java.util.List;
28

    
29
import org.cresques.cts.IProjection;
30
import org.gvsig.expressionevaluator.Expression;
31

    
32
import org.gvsig.fmap.dal.DataServerExplorer;
33
import org.gvsig.fmap.dal.DataStore;
34
import org.gvsig.fmap.dal.DataStoreParameters;
35
import org.gvsig.fmap.dal.ExpressionBuilder;
36
import org.gvsig.fmap.dal.exception.DataException;
37
import org.gvsig.fmap.dal.exception.ReadException;
38
import org.gvsig.fmap.dal.feature.exception.FeatureIndexException;
39
import org.gvsig.fmap.dal.feature.exception.NeedEditingModeException;
40
import org.gvsig.fmap.geom.Geometry;
41
import org.gvsig.fmap.geom.SpatialIndex;
42
import org.gvsig.fmap.geom.primitive.Envelope;
43
import org.gvsig.tools.dispose.DisposableIterator;
44
import org.gvsig.tools.dynobject.DynObject;
45
import org.gvsig.tools.lang.Cloneable;
46
import org.gvsig.tools.observer.Observer;
47
import org.gvsig.tools.undo.UndoRedoStack;
48

    
49
/**
50
 * <p>
51
 * A FeatureStore is a type of store whose data consists on sets of
52
 * {@link Feature}(s). {@link Feature}(s) from the same FeatureStore can be of
53
 * different {@link FeatureType}(s) (as in GML format for instance).
54
 * </p>
55
 *
56
 * <p>
57
 * FeatureStore allows:
58
 * </p>
59
 * <ul>
60
 * <li>Obtaining the default {@link FeatureType}. A FeatureStore always has one
61
 * and only one default FeatureType.
62
 * <li>Obtaining the list of {@link FeatureType}(s) defined in the FeatureStore.
63
 * <li>Obtaining, filtering and sorting subsets of data ({@link FeatureSet})
64
 * through {@link FeatureQuery}, as well as background loading.
65
 * <li>Obtaining the total {@link Envelope} (AKA bounding box or extent) of the
66
 * store.
67
 * <li>Support for editing {@link FeatureType}(s).
68
 * <li>Obtaining information about contained {@link Geometry} types.
69
 * <li>Exporting to another store.
70
 * <li>Indexing.
71
 * <li>Selection.
72
 * <li>Locks management.
73
 * </ul>
74
 *
75
 */
76
public interface FeatureStore extends DataStore, UndoRedoStack, Cloneable {
77

    
78
    public static final String METADATA_DEFINITION_NAME = "FeatureStore";
79

    
80
    /** Indicates that this store is in query mode */
81
    final static int MODE_QUERY = 0;
82

    
83
    /** Indicates that this store is in full edit mode */
84
    final static int MODE_FULLEDIT = 1;
85

    
86
    /** Indicates that this store is in append mode */
87
    final static int MODE_APPEND = 2;
88

    
89
    /*
90
     * =============================================================
91
     *
92
     * information related services
93
     */
94

    
95
    /**
96
     * Indicates whether this store allows writing.
97
     *
98
     * @return
99
     *         true if this store can be written, false if not.
100
     */
101
    public boolean allowWrite();
102

    
103
    /**
104
     * Returns this store's default {@link FeatureType}.
105
     *
106
     * @return
107
     *         this store's default {@link FeatureType}.
108
     *
109
     * @throws DataException
110
     */
111
    public FeatureType getDefaultFeatureType() throws DataException;
112

    
113
    /**
114
     * Returns this store's featureType {@link FeatureType} matches with
115
     * featureTypeId.
116
     *
117
     * @param featureTypeId
118
     *
119
     * @return this store's default {@link FeatureType}.
120
     *
121
     * @throws DataException
122
     */
123
    public FeatureType getFeatureType(String featureTypeId)
124
        throws DataException;
125

    
126
    /**
127
     * Returns this store's {@link FeatureType}(s).
128
     *
129
     * @return a list with this store's {@link FeatureType}(s).
130
     *
131
     * @throws DataException
132
     */
133
    public List getFeatureTypes() throws DataException;
134

    
135
    /**
136
     * Returns this store's parameters.
137
     *
138
     * @return
139
     *         {@link DataStoreParameters} containing this store's parameters
140
     */
141
    public DataStoreParameters getParameters();
142

    
143
    /**
144
     *@throws DataException
145
     * @deprecated Mirar de cambiarlo a metadatos
146
     */
147
    public boolean canWriteGeometry(int gvSIGgeometryType) throws DataException;
148

    
149
    /**
150
     * Returns this store's total envelope (extent).
151
     *
152
     * @return this store's total envelope (extent) or <code>null</code> if
153
     *         store not have geometry information
154
     */
155
    public Envelope getEnvelope() throws DataException;
156

    
157
    /**
158
     *
159
     * @deprecated use getDefaultFeatureType().getDefaultSRS()
160
     * @return
161
     * @throws DataException
162
     */
163
    public IProjection getSRSDefaultGeometry() throws DataException;
164

    
165
    /**
166
     * Exports this store to another store.
167
     *
168
     * @param explorer
169
     *            {@link DataServerExplorer} target
170
     * @param params
171
     *            New parameters of this store that will be used on the target
172
     *            explorer
173
     *
174
     * @throws DataException
175
     *
176
     * @Deprecated this method is unstable
177
     */
178
    public void export(DataServerExplorer explorer, String provider,
179
        NewFeatureStoreParameters params) throws DataException;
180

    
181
    /*
182
     * =============================================================
183
     *
184
     * Query related services
185
     */
186

    
187
    /**
188
     * Returns all available features in the store.
189
     * <p>
190
     * <em>
191
     * <strong>NOTE:</strong> if you use this method to get a
192
     * {@link FeatureSet}, you  must get sure it is disposed
193
     * (@see {@link DisposableIterator#dispose()}) in any case, even if an
194
     * error occurs while getting the data. It is recommended to use the
195
     * <code>accept</code> methods instead, which handle everything for you.
196
     * Take into account the accept methods may use a fast iterator to
197
     * get the features.
198
     * </em>
199
     * </p>
200
     *
201
     * @see #accept(org.gvsig.tools.visitor.Visitor)
202
     *
203
     * @return a collection of features
204
     * @throws ReadException
205
     *             if there is any error while reading the features
206
     */
207
    FeatureSet getFeatureSet() throws DataException;
208

    
209
    FeatureSet getFeatureSet(String filter) throws DataException;
210

    
211
    FeatureSet getFeatureSet(String filter, String sortBy) throws DataException;
212

    
213
    FeatureSet getFeatureSet(String filter, String sortBy, boolean asc) throws DataException;
214

    
215
    FeatureSet getFeatureSet(Expression filter) throws DataException;
216

    
217
    FeatureSet getFeatureSet(Expression filter, String sortBy) throws DataException;
218

    
219
    FeatureSet getFeatureSet(Expression filter, String sortBy, boolean asc) throws DataException;
220
    /**
221
     * Returns a subset of features taking into account the properties and
222
     * restrictions of the FeatureQuery.
223
     * <p>
224
     * <em>
225
     * <strong>NOTE:</strong> if you use this method to get a
226
     * {@link FeatureSet}, you  must get sure it is disposed
227
     * (@see {@link DisposableIterator#dispose()}) in any case, even if an
228
     * error occurs while getting the data. It is recommended to use the
229
     * <code>accept</code> methods instead, which handle everything for you.
230
     * Take into account the accept methods may use a fast iterator to
231
     * get the features.
232
     * </em>
233
     * </p>
234
     *
235
     * @see #accept(org.gvsig.tools.visitor.Visitor,
236
     *      org.gvsig.fmap.dal.DataQuery)
237
     *
238
     * @param featureQuery
239
     *            defines the characteristics of the features to return
240
     * @return a collection of features
241
     * @throws ReadException
242
     *             if there is any error while reading the features
243
     */
244
    FeatureSet getFeatureSet(FeatureQuery featureQuery) throws DataException;
245

    
246
    /**
247
     * Loads a subset of features taking into account the properties and
248
     * restrictions of the FeatureQuery. Feature loading is performed by calling
249
     * the Observer, once each loaded Feature.
250
     *
251
     * @param featureQuery
252
     *            defines the characteristics of the features to return
253
     * @param observer
254
     *            to be notified of each loaded Feature
255
     * @throws DataException
256
     *             if there is any error while loading the features
257
     */
258
    void getFeatureSet(FeatureQuery featureQuery, Observer observer)
259
        throws DataException;
260

    
261
    /**
262
     * Loads all available feature in the store. The loading of Features is
263
     * performed by calling the Observer, once each loaded Feature.
264
     *
265
     * @param observer
266
     *            to be notified of each loaded Feature
267
     * @throws DataException
268
     *             if there is any error while loading the features
269
     */
270
    void getFeatureSet(Observer observer) throws DataException;
271

    
272
    /**
273
     * Return a paginated list of Features filtered by the query.
274
     *
275
     * The returned List of Features is paginated, and the page size
276
     * used is "pageSize".
277
     *
278
     * @param query to filter the returned feature list
279
     * @param pageSize the page size of the list
280
     * @return the list of features
281
     */
282
    public List<Feature> getFeatures(FeatureQuery query, int pageSize);
283

    
284
    public List<Feature> getFeatures(FeatureQuery query);
285

    
286
    public List<Feature> getFeatures();
287

    
288
    public List<Feature> getFeatures(String filter);
289

    
290
    public List<Feature> getFeatures(String filter, String sortBy);
291

    
292
    public List<Feature> getFeatures(String filter, String sortBy, boolean asc);
293

    
294
    public List<Feature> getFeatures(Expression filter);
295

    
296
    public List<Feature> getFeatures(Expression filter, String sortBy);
297

    
298
    public List<Feature> getFeatures(Expression filter, String sortBy, boolean asc);
299

    
300
    public Feature findFirst(String filter) throws DataException;
301

    
302
    public Feature findFirst(String filter, String sortBy) throws DataException;
303

    
304
    public Feature findFirst(String filter, String sortBy, boolean asc) throws DataException;
305

    
306
    public Feature findFirst(Expression filter) throws DataException;
307

    
308
    public Feature findFirst(Expression filter, String sortBy) throws DataException;
309

    
310
    public Feature findFirst(Expression filter, String sortBy, boolean asc) throws DataException;
311

    
312
    /**
313
     * Returns the feature given its reference.
314
     *
315
     * @param reference
316
     *            a unique FeatureReference
317
     * @return
318
     *         The Feature
319
     *
320
     * @throws DataException
321
     *
322
     */
323
    public Feature getFeatureByReference(FeatureReference reference)
324
        throws DataException;
325

    
326
    /**
327
     * Returns the feature given its reference and feature type.
328
     *
329
     * @param reference
330
     *            a unique FeatureReference
331
     *
332
     * @param featureType
333
     *            FeatureType to which the requested Feature belongs
334
     *
335
     * @return
336
     *         The Feature
337
     *
338
     * @throws DataException
339
     *
340
     */
341
    public Feature getFeatureByReference(FeatureReference reference,
342
        FeatureType featureType) throws DataException;
343

    
344
    /*
345
     * =============================================================
346
     *
347
     * Editing related services
348
     */
349

    
350
    /**
351
     * Enters editing state.
352
     */
353
    public void edit() throws DataException;
354

    
355
    /**
356
     * Enters editing state specifying the editing mode.
357
     *
358
     * @param mode
359
     *
360
     * @throws DataException
361
     */
362
    public void edit(int mode) throws DataException;
363

    
364
    /**
365
     * Cancels all editing since the last edit().
366
     *
367
     * @throws DataException
368
     */
369
    public void cancelEditing() throws DataException;
370

    
371
    /**
372
     * Exits editing state.
373
     *
374
     * @throws DataException
375
     */
376
    public void finishEditing() throws DataException;
377

    
378
    /**
379
     * Save changes in the provider without leaving the edit mode.
380
     * Do not call observers to communicate a change of ediding mode.
381
     * The operation's history is eliminated to prevent inconsistencies
382
     * in the data.
383
     *
384
     * @throws DataException
385
     */
386
    public void commitChanges() throws DataException ;
387

    
388
    /**
389
     *
390
     * Returns true if you can call CommitChanges method.
391
     * If not in editing or changes have been made in the structure
392
     * return false.
393
     *
394
     * @return true if can call commitChanges
395
     * @throws DataException
396
     */
397
    public boolean canCommitChanges() throws DataException;
398

    
399

    
400
    /**
401
     * Indicates whether this store is in editing state.
402
     *
403
     * @return
404
     *         true if this store is in editing state, false if not.
405
     */
406
    public boolean isEditing();
407

    
408
    /**
409
     * Indicates whether this store is in appending state. In this state the new
410
     * features are automatically inserted at the end of the {@link FeatureSet}.
411
     *
412
     * @return true if this store is in appending state.
413
     */
414
    public boolean isAppending();
415

    
416
    /**
417
     * Updates a {@link FeatureType} in the store with the changes in the
418
     * {@link EditableFeatureType}.<br>
419
     *
420
     * Any {@link FeatureSet} from this store that are used will be invalidated.
421
     *
422
     * @param featureType
423
     *            an {@link EditableFeatureType} with the changes.
424
     *
425
     * @throws DataException
426
     */
427
    public void update(EditableFeatureType featureType) throws DataException;
428

    
429
    /**
430
     * Updates a {@link Feature} in the store with the changes in the
431
     * {@link EditableFeature}.<br>
432
     *
433
     * Any {@link FeatureSet} from this store that was still in use will be
434
     * invalidated. You can override this using
435
     * {@link FeatureSet#update(EditableFeature)}.
436
     *
437
     * @param feature
438
     *            the feature to be updated
439
     *
440
     * @throws DataException
441
     */
442
    public void update(EditableFeature feature) throws DataException;
443

    
444
    /**
445
     * Deletes a {@link Feature} from the store.<br>
446
     *
447
     * Any {@link FeatureSet} from this store that was still in use will be
448
     * invalidated. You can override this using {@link Iterator#remove()} from
449
     * {@link FeatureSet}.
450
     *
451
     * @param feature
452
     *            The feature to be deleted.
453
     *
454
     * @throws DataException
455
     */
456
    public void delete(Feature feature) throws DataException;
457

    
458
    /**
459
     * Inserts a {@link Feature} in the store.<br>
460
     *
461
     * Any {@link FeatureSet} from this store that was still in use will be
462
     * invalidated. You can override this using
463
     * {@link FeatureSet#insert(EditableFeature)}.
464
     *
465
     * @param feature
466
     *            The feature to be inserted
467
     *
468
     * @throws DataException
469
     */
470
    public void insert(EditableFeature feature) throws DataException;
471

    
472
    /**
473
     * Creates a new feature using the default feature type and returns it as an
474
     * {@link EditableFeature}
475
     *
476
     * @return a new feature in editable state
477
     *
478
     * @throws DataException
479
     */
480
    public EditableFeature createNewFeature() throws DataException;
481

    
482
    /**
483
     * Creates a new feature of the given {@link FeatureType} and uses the given
484
     * {@link Feature} as default values to initialize it.
485
     *
486
     * @param type
487
     *            the new feature's feature type
488
     *
489
     * @param defaultValues
490
     *            a feature whose values are used as default values for the new
491
     *            feature.
492
     *
493
     * @return the new feature.
494
     *
495
     * @throws DataException
496
     */
497
    public EditableFeature createNewFeature(FeatureType type,
498
        Feature defaultValues) throws DataException;
499

    
500
    /**
501
     * Creates a new feature of the given {@link FeatureType}. The flag
502
     * defaultValues is used to indicate whether the new feature should be
503
     * initialized with default values or not.
504
     *
505
     * @param type
506
     *            the new feature's feature type
507
     *
508
     * @param defaultValues
509
     *            if true the new feature is initialized with each attribute's
510
     *            default value.
511
     *
512
     * @return
513
     *         the new feature
514
     *
515
     * @throws DataException
516
     */
517
    public EditableFeature createNewFeature(FeatureType type,
518
        boolean defaultValues) throws DataException;
519

    
520
    /**
521
     * Creates a new feature of default {@link FeatureType}. The flag
522
     * defaultValues is used to indicate whether the new feature should be
523
     * initialized with default values or not.
524
     *
525
     * @param defaultValues
526
     *            if true the new feature is initialized with each attribute's
527
     *            default value.
528
     *
529
     * @return
530
     *         the new feature
531
     *
532
     * @throws DataException
533
     */
534
    public EditableFeature createNewFeature(boolean defaultValues)
535
        throws DataException;
536

    
537
    /**
538
     * Creates a new feature of default {@link FeatureType}.
539
     * The new feature should be initialized with the values of the feature
540
     * passed as parameter.
541
     * Values are inicialiced by name from the feature specified. Error in
542
     * value assignement are ignoreds.
543
     *
544
     * @param defaultValues the values to initialize the new feature.
545
     * @return the new feature
546
     * @throws DataException
547
     */
548
    public EditableFeature createNewFeature(Feature defaultValues)
549
        throws DataException;
550

    
551
    /**
552
     * Applies the validation rules associated to the given mode to the active
553
     * {@link FeatureSet}.
554
     *
555
     * @param mode
556
     *            can be one of {MODE_QUERY, MODE_FULLEDIT, MODE_APPEND}
557
     *
558
     * @throws DataException
559
     */
560
    public void validateFeatures(int mode) throws DataException;
561

    
562
    /**
563
     * Indicates whether this store supports append mode.
564
     *
565
     * @return
566
     *         true if this store supports append mode.
567
     */
568
    public boolean isAppendModeSupported();
569

    
570
    /**
571
     * Initiates an editing group. This is typically used to group series of
572
     * store editing operations.
573
     *
574
     * @param description
575
     *            Description of the editing group.
576
     *
577
     * @throws NeedEditingModeException
578
     */
579
    public void beginEditingGroup(String description)
580
        throws NeedEditingModeException;
581

    
582
    /**
583
     * Finishes an editing group.
584
     *
585
     * @throws NeedEditingModeException
586
     */
587
    public void endEditingGroup() throws NeedEditingModeException;
588

    
589
    /*
590
     * =============================================================
591
     *
592
     * Index related services
593
     */
594

    
595
    /**
596
     * Creates an index which will be applied to the features of the given type,
597
     * by using the data of the given attribute.
598
     *
599
     * @param featureType
600
     *            The FeatureType to which the indexed attribute belongs.
601
     *
602
     * @param attributeName
603
     *            The name of the attributed to be indexed
604
     *
605
     * @param indexName
606
     *            The index name
607
     *
608
     * @return the resulting {@link FeatureIndex}
609
     *
610
     *
611
     * @throws FeatureIndexException
612
     *             if there is an error creating the index
613
     */
614
    public FeatureIndex createIndex(FeatureType featureType,
615
        String attributeName, String indexName) throws DataException;
616

    
617
    /**
618
     * Creates an index which will be applied to the features of the given type,
619
     * by using the data of the given attribute.
620
     *
621
     * @param indexTypeName
622
     *            the type of the index to be created. That name is
623
     *            related to one of the registered index providers
624
     * @param featureType
625
     *            The FeatureType to which the indexed attribute belongs.
626
     *
627
     * @param attributeName
628
     *            The name of the attributed to be indexed
629
     *
630
     * @param indexName
631
     *            The index name
632
     *
633
     * @return the resulting {@link FeatureIndex}
634
     *
635
     *
636
     * @throws FeatureIndexException
637
     *             if there is an error creating the index
638
     */
639
    public FeatureIndex createIndex(String indexTypeName,
640
        FeatureType featureType, String attributeName, String indexName)
641
        throws DataException;
642

    
643
    /**
644
     * Creates an index which will be applied to the features of the given type,
645
     * by using the data of the given attribute. This method will return without
646
     * waiting for the index to be filled, as that will be performed in
647
     * background. An optional {@link Observer} parameter is provided to be
648
     * notified ( {@link FeatureStoreNotification#INDEX_FILLING_SUCCESS} )
649
     * when the index has finished filling with data and is available to be
650
     * used.
651
     *
652
     * @param featureType
653
     *            The FeatureType to which the indexed attribute belongs.
654
     *
655
     * @param attributeName
656
     *            The name of the attributed to be indexed
657
     *
658
     * @param indexName
659
     *            The index name
660
     *
661
     * @param observer
662
     *            to notify to when the created index has finished filling
663
     *            with data and is available to be used. The observer will
664
     *            receive then a
665
     *            {@link FeatureStoreNotification#INDEX_FILLING_SUCCESS}
666
     *            notification, with the index object if it has finished
667
     *            successfully, or a
668
     *            {@link FeatureStoreNotification#INDEX_FILLING_ERROR}
669
     *            notification with the exception object if there has been
670
     *            any error in the process. Optional.
671
     *
672
     * @return the resulting {@link FeatureIndex}
673
     *
674
     * @see FeatureStoreNotification#INDEX_FILLING_STARTED
675
     * @see FeatureStoreNotification#INDEX_FILLING_SUCCESS
676
     * @see FeatureStoreNotification#INDEX_FILLING_CANCELLED
677
     * @see FeatureStoreNotification#INDEX_FILLING_ERROR
678
     *
679
     * @throws FeatureIndexException
680
     *             if there is an error creating the index
681
     */
682
    public FeatureIndex createIndex(FeatureType featureType,
683
        String attributeName, String indexName, Observer observer)
684
        throws DataException;
685

    
686
    /**
687
     * Creates an index which will be applied to the features of the given type,
688
     * by using the data of the given attribute. This method will return without
689
     * waiting for the index to be filled, as that will be performed in
690
     * background. An optional {@link Observer} parameter is provided to be
691
     * notified ( {@link FeatureStoreNotification#INDEX_FILLING_SUCCESS} )
692
     * when the index has finished filling with data and is available to be
693
     * used.
694
     *
695
     * @param indexTypeName
696
     *            the type of the index to be created. That name is
697
     *            related to one of the registered index providers
698
     * @param featureType
699
     *            The FeatureType to which the indexed attribute belongs.
700
     *
701
     * @param attributeName
702
     *            The name of the attributed to be indexed
703
     *
704
     * @param indexName
705
     *            The index name
706
     *
707
     * @param observer
708
     *            to notify to when the created index has finished filling
709
     *            with data and is available to be used. The observer will
710
     *            receive then a
711
     *            {@link FeatureStoreNotification#INDEX_FILLING_SUCCESS}
712
     *            notification, with the index object if it has finished
713
     *            successfully, or a
714
     *            {@link FeatureStoreNotification#INDEX_FILLING_ERROR}
715
     *            notification with the exception object if there has been
716
     *            any error in the process. Optional.
717
     *
718
     * @return the resulting {@link FeatureIndex}
719
     *
720
     * @see FeatureStoreNotification#INDEX_FILLING_STARTED
721
     * @see FeatureStoreNotification#INDEX_FILLING_SUCCESS
722
     * @see FeatureStoreNotification#INDEX_FILLING_CANCELLED
723
     * @see FeatureStoreNotification#INDEX_FILLING_ERROR
724
     *
725
     * @throws FeatureIndexException
726
     *             if there is an error creating the index
727
     */
728
    public FeatureIndex createIndex(String indexTypeName,
729
        FeatureType featureType, String attributeName, String indexName,
730
        Observer observer) throws DataException;
731

    
732
    /**
733
     * Returns a FeatureIndexes structure containing all available indexes in
734
     * the store.
735
     *
736
     * @return
737
     */
738
    public FeatureIndexes getIndexes();
739

    
740
    /*
741
     * =============================================================
742
     *
743
     * Selection related services
744
     */
745

    
746
    /**
747
     * Sets the selection to the passed {@link FeatureSet}
748
     *
749
     * @param selection
750
     *            A {@link FeatureSet} with the requested selection
751
     */
752
    public void setSelection(FeatureSet selection) throws DataException;
753

    
754
    /**
755
     * Creates a {@link FeatureSelection}
756
     *
757
     * @return
758
     *         a {@link FeatureSelection}
759
     *
760
     * @throws DataException
761
     */
762
    public FeatureSelection createFeatureSelection() throws DataException;
763

    
764
    /**
765
     * Returns the current {@link FeatureSelection}.
766
     * Create a empty selection if not exits.
767
     * 
768
     * Manage of the selection can be slow on some data sources. 
769
     * Use with care.
770
     * In data sources that do not support position access to records, 
771
     * it may be slow to retrieve items from the selection. In some data 
772
     * sources it may be necessary to access to this to retrieve each 
773
     * item in the selection.
774
     *
775
     * @return
776
     *         current {@link FeatureSelection}.
777
     *
778
     * @throws DataException
779
     */
780
    public FeatureSelection getFeatureSelection() throws DataException;
781

    
782
    /*
783
     * =============================================================
784
     *
785
     * Lock related services
786
     */
787

    
788
    /**
789
     * Indicates whether this store supports locks.
790
     *
791
     * @return
792
     *         true if this store supports locks, false if not.
793
     */
794
    public boolean isLocksSupported();
795

    
796
    /**
797
     * Returns the set of locked features
798
     *
799
     * @return
800
     *         set of locked features
801
     *
802
     * @throws DataException
803
     */
804
    public FeatureLocks getLocks() throws DataException;
805

    
806
    /*
807
     * =============================================================
808
     * Transforms related services
809
     * =============================================================
810
     */
811

    
812
    /**
813
     * Returns this store transforms
814
     *
815
     * @return
816
     *         this store transforms
817
     */
818
    public FeatureStoreTransforms getTransforms();
819

    
820
    /**
821
     * Returns a new {@link FeatureQuery} associated to this store.
822
     *
823
     * @return
824
     *         a new {@link FeatureQuery} associated to this store.
825
     */
826
    public FeatureQuery createFeatureQuery();
827

    
828
    /**
829
     * Returns featue count of this store.
830
     *
831
     * @return
832
     * @throws DataException
833
     */
834
    public long getFeatureCount() throws DataException;
835

    
836
//    /**
837
//     * Creates a vectorial cache that is used to save and retrieve data.
838
//     *
839
//     * @param name
840
//     *            the cache name.
841
//     * @param parameters
842
//     *            parameters to create the stores used to save data.
843
//     * @throws DataException
844
//     */
845
//    public void createCache(String name, DynObject parameters)
846
//        throws DataException;
847
//
848
//    /**
849
//     * @return the vectorial cache
850
//     */
851
//    public FeatureCache getCache();
852

    
853
    /**
854
     * Return if the provider knows the real envelope of a layer. If not,
855
     * the {@link FeatureStoreProvider#getEnvelope()} method doesn't return
856
     * the full envelope.
857
     *
858
     * @return
859
     *         <true> if it knows the real envelope.
860
     */
861
    public boolean isKnownEnvelope();
862

    
863
    /**
864
     * Return if the maximum number of features provided by the
865
     * provider are limited.
866
     *
867
     * @return
868
     *         <true> if there is a limit of features.
869
     */
870
    public boolean hasRetrievedFeaturesLimit();
871

    
872
    /**
873
     * If the {@link FeatureStoreProvider#hasRetrievedFeaturesLimit()} returns
874
     * true,
875
     * it returns the limit of features retrieved from the provider.
876
     *
877
     * @return
878
     *         The limit of the retrieved features.
879
     */
880
    public int getRetrievedFeaturesLimit();
881

    
882
    /**
883
     * Return the associated feature to the dynobject.
884
     * If the dynobject isn't associated to a feature of this store, return null.
885
     *
886
     * @param dynobject
887
     * @return
888
     */
889
    public Feature getFeature(DynObject dynobject);
890

    
891
    public Iterator iterator();
892

    
893
    public ExpressionBuilder createExpressionBuilder();
894

    
895
    /**
896
     * 
897
     * @return 
898
     * @deprecated use createExpressionBuilder
899
     */
900
    public ExpressionBuilder createExpression();
901

    
902
    public void createCache(String name, DynObject parameters)
903
        throws DataException;
904

    
905
    public FeatureCache getCache();
906

    
907
    public boolean isBroken();
908

    
909
        public Throwable getBreakingsCause();
910

    
911
    /**
912
     * @param index
913
     * @return
914
     */
915
    SpatialIndex wrapSpatialIndex(SpatialIndex index);
916
    
917
    public FeatureReference getFeatureReference(String code);
918
}