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

History | View | Annotate | Download (30 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
import org.gvsig.expressionevaluator.ExpressionBuilder;
32

    
33
import org.gvsig.fmap.dal.DataServerExplorer;
34
import org.gvsig.fmap.dal.DataStore;
35
import org.gvsig.fmap.dal.DataStoreParameters;
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 first() throws DataException;
301

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

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

    
306
    public Feature findFirst(String filter, String sortBy, boolean asc) throws DataException;
307

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

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

    
312
    public Feature findFirst(Expression filter, String sortBy, boolean asc) throws DataException;
313

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

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

    
346
    /*
347
     * =============================================================
348
     *
349
     * Editing related services
350
     */
351

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

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

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

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

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

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

    
401

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
591
    /*
592
     * =============================================================
593
     *
594
     * Index related services
595
     */
596

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

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

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

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

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

    
742
    /*
743
     * =============================================================
744
     *
745
     * Selection related services
746
     */
747

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

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

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

    
784
    /*
785
     * =============================================================
786
     *
787
     * Lock related services
788
     */
789

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

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

    
808
    /*
809
     * =============================================================
810
     * Transforms related services
811
     * =============================================================
812
     */
813

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

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

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

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

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

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

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

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

    
893
    public Iterator iterator();
894

    
895
    public ExpressionBuilder createExpressionBuilder();
896

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

    
904
    public void createCache(String name, DynObject parameters)
905
        throws DataException;
906

    
907
    public FeatureCache getCache();
908

    
909
    public boolean isBroken();
910

    
911
        public Throwable getBreakingsCause();
912

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

    
921
    /**
922
     * Devuelbe el numero de operaciones pendientes de guardar en una sesion
923
     * de edicion. Es un valor orientativo.
924
     * Las operaciones pendientes son la suma de operaciones de borrado, insercion
925
     * o modificacion de las features en una sesion de edicion.
926
     * 
927
     * Retorna 0 si no esta en edicion.
928
     * 
929
     * @return numero de operaciones pendientes. 
930
     */
931
    public long getPendingChangesCount();
932
}