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

History | View | Annotate | Download (52 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
import java.util.function.Predicate;
29
import javax.json.JsonObject;
30
import org.apache.commons.lang3.StringUtils;
31
import org.cresques.cts.IProjection;
32
import org.gvsig.expressionevaluator.Expression;
33
import org.gvsig.expressionevaluator.ExpressionBuilder;
34
import org.gvsig.fmap.dal.DataServerExplorer;
35
import org.gvsig.fmap.dal.DataStore;
36
import org.gvsig.fmap.dal.DataStoreParameters;
37
import org.gvsig.fmap.dal.exception.DataException;
38
import org.gvsig.fmap.dal.exception.ReadException;
39
import org.gvsig.fmap.dal.feature.exception.FeatureIndexException;
40
import org.gvsig.fmap.dal.feature.exception.NeedEditingModeException;
41
import org.gvsig.fmap.geom.Geometry;
42
import org.gvsig.fmap.geom.SpatialIndex;
43
import org.gvsig.fmap.geom.primitive.Envelope;
44
import org.gvsig.tools.dispose.DisposableIterator;
45
import org.gvsig.tools.dynobject.DynObject;
46
import org.gvsig.tools.lang.Cloneable;
47
import org.gvsig.tools.observer.Observer;
48
import org.gvsig.tools.undo.UndoRedoStack;
49
import org.gvsig.tools.util.GetItemWithSizeIsEmptyAndIterator64;
50
import org.gvsig.tools.util.PropertiesSupport;
51
import org.gvsig.tools.util.Size64;
52
import org.gvsig.tools.util.UnmodifiableBasicList64;
53

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

    
86
    public static String getLabel(FeatureStore store) {        
87
        if( store == null ) {
88
            return null;
89
        }
90
        String label = null;
91
        try {
92
            label = store.getName();
93
            FeatureType ft = store.getDefaultFeatureTypeQuietly();
94
            if( ft != null ) {
95
                if( StringUtils.isNotBlank(ft.getLabel()) ) {
96
                    label = ft.getLabel();
97
                }
98
            }
99
        } catch(Throwable t) {
100
            // Do nothing
101
        }
102
        return label;
103
    }
104
    
105
    public static final String METADATA_DEFINITION_NAME = "FeatureStore";
106

    
107
    final static int MODE_UNKNOWN = -1;
108
    
109
    /** Indicates that this store is in query mode */
110
    final static int MODE_QUERY = 0;
111

    
112
    /** Indicates that this store is in full edit mode */
113
    final static int MODE_FULLEDIT = 1;
114

    
115
    /** Indicates that this store is in append mode */
116
    final static int MODE_APPEND = 2;
117
    
118
    final static int MODE_PASS_THROUGH = 3;
119
    
120
    final static int SUBMODE_NONE = 0;
121
    
122
    /** En este modo hace un merge contra la base de datos, si existe lo actualizada y si no lo inserta **/
123
    final static int SUBMODE_MERGE = 2; 
124

    
125
    /*
126
     * =============================================================
127
     *
128
     * information related services
129
     */
130

    
131
    /**
132
     * Indicates whether this store allows writing.
133
     *
134
     * @return
135
     *         true if this store can be written, false if not.
136
     */
137
    public boolean allowWrite();
138

    
139
    /**
140
     * Returns this store's default {@link FeatureType}.
141
     *
142
     * @return
143
     *         this store's default {@link FeatureType}.
144
     *
145
     * @throws DataException
146
     */
147
    public FeatureType getDefaultFeatureType() throws DataException;
148
    
149
    public FeatureType getDefaultFeatureTypeQuietly();
150

    
151
    /**
152
     * Returns this store's featureType {@link FeatureType} matches with
153
     * featureTypeId.
154
     *
155
     * @param featureTypeId
156
     *
157
     * @return this store's default {@link FeatureType}.
158
     *
159
     * @throws DataException
160
     */
161
    public FeatureType getFeatureType(String featureTypeId)
162
        throws DataException;
163

    
164
    /**
165
     * Returns this store's {@link FeatureType}(s).
166
     *
167
     * @return a list with this store's {@link FeatureType}(s).
168
     *
169
     * @throws DataException
170
     */
171
    public List getFeatureTypes() throws DataException;
172

    
173
    /**
174
     * Returns this store's parameters.
175
     *
176
     * @return
177
     *         {@link DataStoreParameters} containing this store's parameters
178
     */
179
    @Override
180
    public DataStoreParameters getParameters();
181

    
182
    /**
183
     * @param gvSIGgeometryType
184
     * @return 
185
     * @throws DataException
186
     * @deprecated Mirar de cambiarlo a metadatos
187
     */
188
    public boolean canWriteGeometry(int gvSIGgeometryType) throws DataException;
189

    
190
    /**
191
     * Returns this store's total envelope (extent).
192
     *
193
     * @return this store's total envelope (extent) or <code>null</code> if
194
     *         store not have geometry information
195
     * @throws org.gvsig.fmap.dal.exception.DataException
196
     */
197
    public Envelope getEnvelope() throws DataException;
198

    
199
    /**
200
     *
201
     * @deprecated use getDefaultFeatureType().getDefaultSRS()
202
     * @return
203
     * @throws DataException
204
     */
205
    public IProjection getSRSDefaultGeometry() throws DataException;
206

    
207
    /**
208
     * Exports this store to another store.
209
     *
210
     * @param explorer
211
     *            {@link DataServerExplorer} target
212
     * @param provider
213
     * @param params
214
     *            New parameters of this store that will be used on the target
215
     *            explorer
216
     *
217
     * @throws DataException
218
     *
219
     * @Deprecated this method is unstable
220
     */
221
    public void export(DataServerExplorer explorer, String provider,
222
        NewFeatureStoreParameters params, String name) throws DataException;
223

    
224
    public void copyTo(FeatureStore target);
225

    
226
    /*
227
     * =============================================================
228
     *
229
     * Query related services
230
     */
231
    
232
    /** 
233
     * Create a {@link FeatureQuery} with the restrictions indicateds.
234
     * 
235
     * "filter" will be null or a valid filter expression for the store.
236
     * 
237
     * "sortBy" can be null to use the store's default order.
238
     * 
239
     * The parameter sortBy can be an attribute name or a comma separated list. 
240
     * Each attribute name can be preceded or followed by "+" or "-" to indicate 
241
     * the order to use to sort by that attribute. 
242
     * 
243
     * If no "+" or "-" is indicated, the "asc" parameter will be used to 
244
     * determine if the order is ascending, "true" or decent, "false".
245
     * 
246
     * @param filter an {@link String} expression used to filter the features in the store.
247
     * @param sortBy Attribute names separated by commas used to sort the list to return.
248
     * @param asc use order ascending, true, or descending, false.
249
     * @return a {@link FeatureQuery} with the restrictions.
250
     * @see {@link FeatureQuery}
251
     */
252
    public FeatureQuery createFeatureQuery(String filter, String sortBy, boolean asc);
253
    public FeatureQuery createFeatureQuery(String filter);
254
    public FeatureQuery createFeatureQuery(Expression filter);
255

    
256
    /** 
257
     * Create a {@link FeatureQuery} with the restrictions indicateds.
258
     * 
259
     * "filter" will be null or {@link Expression} valid for the store.
260
     * 
261
     * "sortBy" can be null to use the store's default order.
262
     * 
263
     * The parameter sortBy can be an attribute name or a comma separated list. 
264
     * Each attribute name can be preceded or followed by "+" or "-" to indicate 
265
     * the order to use to sort by that attribute. 
266
     * 
267
     * If no "+" or "-" is indicated, the "asc" parameter will be used to 
268
     * determine if the order is ascending, "true" or decent, "false".
269
     * 
270
     * @param filter an {@link String} expression used to filter the features in the store.
271
     * @param sortBy Attribute names separated by commas used to sort the list to return.
272
     * @param asc use order ascending, true, or descending, false.
273
     * @return a {@link FeatureQuery} with the restrictions.
274
     * @see {@link FeatureQuery}
275
     */
276
    public FeatureQuery createFeatureQuery(Expression filter, String sortBy, boolean asc);
277
        
278
    /** 
279
     * Create a {@link FeatureQuery} with the restrictions indicateds.
280
     * 
281
     * "filter" will be null or {@link Expression} valid for the store.
282
     * 
283
     * "sortBy" can be null to use the store's default order.
284
     * 
285
     * The parameter sortBy can be an attribute name or a comma separated list. 
286
     * Each attribute name can be preceded or followed by "+" or "-" to indicate 
287
     * the order to use to sort by that attribute. 
288
     * 
289
     * If no "+" or "-" is indicated, the "asc" parameter will be used to 
290
     * determine if the order is ascending, "true" or decent, "false".
291
     * 
292
     * @param filter an {@link String} expression used to filter the features in the store.
293
     * @param sortBy expression used to order the features in the store.
294
     * @param asc use order ascending, true, or descending, false.
295
     * @return a {@link FeatureQuery} with the restrictions.
296
     * @see {@link FeatureQuery}
297
     */
298
    public FeatureQuery createFeatureQuery(Expression filter, Expression sortBy, boolean asc);
299
    
300
    /** 
301
     * Create a {@link FeatureQuery} with the restrictions indicateds.
302
     * 
303
     * "filter" will be null or {@link Expression} valid for the store.
304
     * 
305
     * "sortBy" can be null to use the store's default order.
306
     * 
307
     * The parameter sortBy can be an attribute name or a comma separated list. 
308
     * Each attribute name can be preceded or followed by "+" or "-" to indicate 
309
     * the order to use to sort by that attribute. 
310
     * 
311
     * If no "+" or "-" is indicated, the "asc" parameter will be used to 
312
     * determine if the order is ascending, "true" or decent, "false".
313
     * 
314
     * @param filter an {@link String} expression used to filter the features in the store.
315
     * @param sortBy expression used to order the features in the store.
316
     * @param asc use order ascending, true, or descending, false.
317
     * @return a {@link FeatureQuery} with the restrictions.
318
     * @see {@link FeatureQuery}
319
     */
320
    public FeatureQuery createFeatureQuery(String filter, Expression sortBy, boolean asc);
321

    
322
    
323
    
324
    /**
325
     * Returns all available features in the store.
326
     *
327
     * It is a utility method that calls {@link #getFeatureSet(FeatureQuery)}
328
     * 
329
     * @return the {@link FeatureSet} 
330
     * @throws ReadException if there is any error while reading the features
331
     * @see {@link #accept(org.gvsig.tools.visitor.Visitor)}, {@link #getFeatureSet(FeatureQuery)}
332
     */
333
    FeatureSet getFeatureSet() throws DataException;
334

    
335
    /**
336
     * Return a subset of features.
337
     * 
338
     * It is a utility method that calls {@link #getFeatureSet(FeatureQuery)}
339
     * 
340
     * @param filter an {@link String} expression used to filter the features in the store.
341
     * @return the {@link FeatureSet} 
342
     * @throws ReadException if there is any error while reading the features
343
     * @see {@link #createFeatureQuery(Expression,String,boolean)}, {@link #getFeatureSet(FeatureQuery)}
344
     */
345
    FeatureSet getFeatureSet(String filter) throws DataException;
346

    
347
    /**
348
     * Return a subset of features.
349
     * 
350
     * It is a utility method that calls {@link #getFeatureSet(FeatureQuery)}
351
     * 
352
     * The sort order used is ascending.
353
     * 
354
     * @param filter an {@link String} expression used to filter the features in the store.
355
     * @param sortBy Attribute names separated by commas used to sort the list to return.
356
     * @return the {@link FeatureSet} 
357
     * @throws ReadException if there is any error while reading the features
358
     * @see {@link #createFeatureQuery(Expression,String,boolean)}, {@link #getFeatureSet(FeatureQuery)}
359
     */
360
    FeatureSet getFeatureSet(String filter, String sortBy) throws DataException;
361

    
362
    /**
363
     * Return a subset of features.
364
     * 
365
     * It is a utility method that calls {@link #getFeatureSet(FeatureQuery)}
366
     * 
367
     * @param filter an {@link String} expression used to filter the features in the store.
368
     * @param sortBy Attribute names separated by commas used to sort the list to return.
369
     * @param asc use order ascending, true, or descending, false.
370
     * @return the {@link FeatureSet} 
371
     * @throws ReadException if there is any error while reading the features
372
     * @see {@link #createFeatureQuery(Expression,String,boolean)}, {@link #getFeatureSet(FeatureQuery)}
373
     */
374
    FeatureSet getFeatureSet(String filter, String sortBy, boolean asc) throws DataException;
375

    
376
    /**
377
     * Return a subset of features.
378
     * 
379
     * It is a utility method that calls {@link #getFeatureSet(FeatureQuery)}
380
     * 
381
     * @param filter an {@link Expression} used to filter the features in the store.
382
     * @return the {@link FeatureSet} 
383
     * @throws DataException 
384
     * @see {@link #createFeatureQuery(Expression,String,boolean)}, {@link #getFeatureSet(FeatureQuery)}
385
     */
386
    FeatureSet getFeatureSet(Expression filter) throws DataException;
387

    
388
    /**
389
     * Return a subset of features.
390
     * 
391
     * It is a utility method that calls {@link #getFeatureSet(FeatureQuery)}
392
     * 
393
     * The sort order used is ascending.
394
     * 
395
     * @param filter an {@link Expression} used to filter the features in the store.
396
     * @param sortBy Attribute names separated by commas used to sort the list to return.
397
     * @return the {@link FeatureSet} 
398
     * @throws ReadException if there is any error while reading the features
399
     * @see {@link #createFeatureQuery(Expression,String,boolean)}, {@link #getFeatureSet(FeatureQuery)}
400
     */
401
    FeatureSet getFeatureSet(Expression filter, String sortBy) throws DataException;
402

    
403
    /**
404
     * Return a subset of features.
405
     * 
406
     * It is a utility method that calls {@link #getFeatureSet(FeatureQuery)}
407
     * 
408
     * @param filter an {@link Expression} used to filter the features in the store.
409
     * @param sortBy Attribute names separated by commas used to sort the list to return.
410
     * @param asc use order ascending, true, or descending, false.
411
     * @return the {@link FeatureSet} 
412
     * @throws DataException 
413
     * @see {@link #createFeatureQuery(Expression,String,boolean)}, {@link #getFeatureSet(FeatureQuery)}
414
     */
415
    FeatureSet getFeatureSet(Expression filter, String sortBy, boolean asc) throws DataException;
416

    
417
    /**
418
     * Returns a subset of features taking into account the properties and
419
     * restrictions of the {@link FeatureQuery}.
420
     * 
421
     * If {@link FeatureQuery} is null, return al features in the store.
422
     * 
423
     * <p>
424
     * <em>
425
     * <strong>NOTE:</strong> if you use this method to get a
426
     * {@link FeatureSet}, you  must get sure it is disposed
427
     * (@see {@link DisposableIterator#dispose()}) in any case, even if an
428
     * error occurs while getting the data. It is recommended to use the
429
     * <code>accept</code> methods instead, which handle everything for you.
430
     * Take into account the accept methods may use a fast iterator to
431
     * get the features.
432
     * </em>
433
     * </p>
434
     *
435
     * @param featureQuery defines the characteristics of the features to return.
436
     * @return the {@link FeatureSet} 
437
     * @throws ReadException if there is any error while reading the features.
438
     * @see #accept(org.gvsig.tools.visitor.Visitor, org.gvsig.fmap.dal.DataQuery)
439
     */
440
    FeatureSet getFeatureSet(FeatureQuery featureQuery) throws DataException;
441

    
442
    /**
443
     * Loads a subset of features taking into account the properties and
444
     * restrictions of the FeatureQuery. 
445
     * When feature loading is finished call the Observer passing the
446
     * {@link FeatureSet}  loaded.
447
     *
448
     * @param featureQuery defines the characteristics of the features to return.
449
     * @param observer to be notified when loading is finished.
450
     * @throws DataException if there is any error while loading the features
451
     */
452
    void getFeatureSet(FeatureQuery featureQuery, Observer observer) throws DataException;
453

    
454
    /**
455
     * Loads all available feature in the store. The loading of Features is
456
     * performed by calling the Observer, once each loaded Feature.
457
     *
458
     * @param observer to be notified of each loaded Feature
459
     * @throws DataException if there is any error while loading the features
460
     */
461
    void getFeatureSet(Observer observer) throws DataException;
462

    
463
    /**
464
     * Return a paginated list of Features filtered by the query.
465
     * 
466
     * If the query  is null, return all features in the store sorteds 
467
     * by default order.
468
     * 
469
     * The return value implements {@link List} and {@link UnmodifiableBasicList64} 
470
     * to support large list of features.
471
     * 
472
     * The returned list of Features is paginated, and the page size
473
     * used is "pageSize". 
474
     * 
475
     * If the page size is less than or equal to 0, the default page size of 
476
     * 100 will be used.
477
     *
478
     * @param query to filter and sort the returned feature list
479
     * @param pageSize the page size of the list
480
     * @return the {@link List}/{@link UnmodifiableBasicList64} of features
481
     */
482
    public List<Feature> getFeatures(FeatureQuery query, int pageSize);
483

    
484
    /**
485
     * Return a paginated list of Features.
486
     * 
487
     * It is a utility method that calls {@link #getFeatures(FeatureQuery, int)}
488
     * using the default page size.
489
     * 
490
     * @param query to filter and sort the returned feature list
491
     * @return the {@link List}/{@link UnmodifiableBasicList64} of features
492
     * @see {@link #getFeatures(FeatureQuery, int)}
493
     */
494
    public List<Feature> getFeatures(FeatureQuery query);
495

    
496
    /**
497
     * Return a paginated list with al Features in the store.
498
     * 
499
     * It is a utility method that calls {@link #getFeatures(FeatureQuery, int)}
500
     * using the default page size.
501
     * 
502
     * @return the {@link List}/{@link UnmodifiableBasicList64} of features
503
     * @see {@link #getFeatures(FeatureQuery, int)}
504
     */
505
    public List<Feature> getFeatures();
506

    
507
    /**
508
     * Return a paginated list of Features
509
     * 
510
     * It is a utility method that calls {@link #getFeatures(FeatureQuery, int)}
511
     * 
512
     * @param filter used to filter the features in the store.
513
     * @return the List of Features
514
     * @see {@link #getFeatures(FeatureQuery, int)}, {@link #createFeatureQuery(String,String,boolean)}
515
     */
516
    public List<Feature> getFeatures(String filter);
517

    
518
    /**
519
     * Return a paginated list of Features.
520
     * 
521
     * It is a utility method that calls {@link #getFeatures(FeatureQuery, int)}
522
     * using the default page size.
523
     * 
524
     * @param filter used to filter the features in the store.
525
     * @param sortBy Attribute names separated by commas used to sort the list to return.
526
     * @return the {@link List}/{@link UnmodifiableBasicList64} of features
527
     * @see {@link #getFeatures(FeatureQuery, int)}, {@link #createFeatureQuery(String,String,boolean)}
528
     */
529
    public List<Feature> getFeatures(String filter, String sortBy);
530

    
531
    /**
532
     * Return a paginated list of Features.
533
     *  
534
     * It is a utility method that calls {@link #getFeatures(FeatureQuery, int)}
535
     * using the default page size.
536
     * 
537
     * @param filter an {@link String} expression used to filter the features in the store.
538
     * @param sortBy Attribute names separated by commas used to sort the list to return.
539
     * @param asc use order ascending, true, or descending, false.
540
     * @return the {@link List}/{@link UnmodifiableBasicList64} of features
541
     * @see {@link #getFeatures(FeatureQuery, int)}, {@link #createFeatureQuery(String,String,boolean)}
542
     */
543
    public List<Feature> getFeatures(String filter, String sortBy, boolean asc);
544

    
545
    /**
546
     * Return a paginated list of Features
547
     * 
548
     * It is a utility method that calls {@link #getFeatures(FeatureQuery, int)}
549
     * using the default page size.
550
     * 
551
     * @param filter an {@link Expression} used to filter the features in the store.
552
     * @return the List of Features
553
     * @see {@link #getFeatures(FeatureQuery, int)}, {@link #createFeatureQuery(Expression,String,boolean)}
554
     */
555
    public List<Feature> getFeatures(Expression filter);
556

    
557
    /**
558
     * Return a paginated list of Features
559
     * 
560
     * It is a utility method that calls {@link #getFeatures(FeatureQuery, int)}
561
     * using the default page size.
562
     * 
563
     * @param filter an {@link Expression} used to filter the features in the store.
564
     * @param sortBy Attribute names separated by commas used to sort the list to return.
565
     * @return the {@link List}/{@link UnmodifiableBasicList64} of features
566
     * @see {@link #getFeatures(FeatureQuery, int)}, {@link #createFeatureQuery(Expression,String,boolean)}
567
     */
568
    public List<Feature> getFeatures(Expression filter, String sortBy);
569

    
570
    /**
571
     * Return a paginated list of Features
572
     * 
573
     * It is a utility method that calls {@link #getFeatures(FeatureQuery, int)}
574
     * using the default page size.
575
     * 
576
     * @param filter an {@link Expression} used to filter the features in the store.
577
     * @param sortBy Attribute names separated by commas used to sort the list to return.
578
     * @param asc use order ascending, true, or descending, false.
579
     * @return the {@link List}/{@link UnmodifiableBasicList64} of features
580
     * @see {@link #getFeatures(FeatureQuery, int)}, {@link #createFeatureQuery(Expression,String,boolean)}
581
     */
582
    public List<Feature> getFeatures(Expression filter, String sortBy, boolean asc);
583

    
584
    public GetItemWithSizeIsEmptyAndIterator64<Feature> getFeatures64();
585

    
586
    public GetItemWithSizeIsEmptyAndIterator64<Feature> getFeatures64(String filter);
587
    
588
    public GetItemWithSizeIsEmptyAndIterator64<Feature> getFeatures64(String filter, String sortBy, boolean asc);
589
    
590
    public GetItemWithSizeIsEmptyAndIterator64<Feature> getFeatures64(FeatureQuery query, int pageSize);
591
    
592
    /**
593
     * Return the first {@link Feature} of the store.
594
     * 
595
     * @return the first {@link Feature} or null if the store is empty.
596
     * @throws DataException 
597
     */
598
    public Feature first() throws DataException;
599

    
600
    /**
601
     * Returns the first {@link Feature} that meets the criteria indicated.
602
     * 
603
     * It is a utility method that calls {@link #findFirst(FeatureQuery)}.
604
     * 
605
     * @param filter {@link String} expression used to filter the features.
606
     * @return the first {@link Feature} or null if the filter don't return any feature.
607
     * @throws DataException 
608
     * @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(String,String,boolean)}
609
     */
610
    public Feature findFirst(String filter) throws DataException;
611

    
612
    /**
613
     * Returns the first {@link Feature} that meets the criteria indicated.
614
     * 
615
     * It is a utility method that calls {@link #findFirst(FeatureQuery)}.
616
     * 
617
     * @param filter {@link String} expression used to filter the features.
618
     * @param sortBy Attribute names separated by commas used to sort the list to return.
619
     * @return the first {@link Feature} or null if the filter don't return any feature.
620
     * @throws DataException 
621
     * @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(String,String,boolean)}
622
     */
623
    public Feature findFirst(String filter, String sortBy) throws DataException;
624

    
625
    /**
626
     * Returns the first {@link Feature} that meets the criteria indicated.
627
     * 
628
     * It is a utility method that calls {@link #findFirst(FeatureQuery)}.
629
     * 
630
     * @param filter {@link String} expression used to filter the features.
631
     * @param sortBy Attribute names separated by commas used to sort the list to return.
632
     * @param asc use order ascending, true, or descending, false.
633
     * @return the first {@link Feature} or null if the filter don't return any feature.
634
     * @throws DataException 
635
     * @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(String,String,boolean)}
636
     */
637
    public Feature findFirst(String filter, String sortBy, boolean asc) throws DataException;
638

    
639
    
640
    /**
641
     * Returns the first {@link Feature} that meets the criteria indicated.
642
     * 
643
     * It is a utility method that calls {@link #findFirst(FeatureQuery)}.
644
     * 
645
     * @param filter {@link String} expression used to filter the features.
646
     * @param sortBy Expression
647
     * @param asc use order ascending, true, or descending, false.
648
     * @return the first {@link Feature} or null if the filter don't return any feature.
649
     * @throws DataException 
650
     * @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(String,String,boolean)}
651
     */
652
    public Feature findFirst(String filter, Expression sortBy, boolean asc) throws DataException;
653

    
654
    /**
655
     * Returns the first {@link Feature} that meets the criteria indicated.
656
     * 
657
     * It is a utility method that calls {@link #findFirst(FeatureQuery)}.
658
     * 
659
     * @param filter {@link String} expression used to filter the features.
660
     * @return the first {@link Feature} or null if the filter don't return any feature.
661
     * @throws DataException 
662
     * @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(Expession,String,boolean)}
663
     */
664
    public Feature findFirst(Expression filter) throws DataException;
665

    
666
    /**
667
     * Returns the first {@link Feature} that meets the criteria indicated.
668
     * 
669
     * It is a utility method that calls {@link #findFirst(FeatureQuery)}.
670
     * 
671
     * @param filter {@link String} expression used to filter the features.
672
     * @param sortBy Attribute names separated by commas used to sort the list to return.
673
     * @return the first {@link Feature} or null if the filter don't return any feature.
674
     * @throws DataException 
675
     * @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(Expession,String,boolean)}
676
     */
677
    public Feature findFirst(Expression filter, String sortBy) throws DataException;
678

    
679
    /**
680
     * Returns the first {@link Feature} that meets the criteria indicated.
681
     * 
682
     * It is a utility method that calls {@link #findFirst(FeatureQuery)}.
683
     * 
684
     * @param filter {@link String} expression used to filter the features.
685
     * @param sortBy Attribute names separated by commas used to sort the list to return.
686
     * @param asc use order ascending, true, or descending, false.
687
     * @return the first {@link Feature} or null if the filter don't return any feature.
688
     * @throws DataException 
689
     * @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(Expession,String,boolean)}
690
     */
691
    public Feature findFirst(Expression filter, String sortBy, boolean asc) throws DataException;
692

    
693
    /**
694
     * Returns the first {@link Feature} that meets the criteria indicated.
695
     * 
696
     * It is a utility method that calls {@link #findFirst(FeatureQuery)}.
697
     * 
698
     * @param filter {@link String} expression used to filter the features.
699
     * @param sortBy expression used to sort features
700
     * @param asc use order ascending, true, or descending, false.
701
     * @return the first {@link Feature} or null if the filter don't return any feature.
702
     * @throws DataException 
703
     * @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(Expession,String,boolean)}
704
     */
705
    public Feature findFirst(Expression filter, Expression sortBy, boolean asc) throws DataException;
706

    
707
    /**
708
     * Returns the first {@link Feature} that meets the criteria indicated.
709
     * 
710
     * It is a utility method that calls {@link #findFirst(FeatureQuery)}.
711
     * 
712
     * @param query to filter and sort the returned feature list
713
     * @return the first {@link Feature} or null if the filter don't return any feature.
714
     * @throws DataException 
715
     * @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(Expession,String,boolean)}
716
     */
717
    public Feature findFirst(FeatureQuery query) throws DataException;
718

    
719
    /**
720
     * Returns the feature given its reference.
721
     *
722
     * @param reference a unique FeatureReference
723
     * @return 
724
     * @returnThe Feature
725
     * @throws DataException
726
     *
727
     */
728
    public Feature getFeatureByReference(FeatureReference reference) throws DataException;
729

    
730
    /**
731
     * Returns the feature given its reference and feature type.
732
     *
733
     * @param reference
734
     *            a unique FeatureReference
735
     *
736
     * @param featureType
737
     *            FeatureType to which the requested Feature belongs
738
     *
739
     * @return
740
     *         The Feature
741
     *
742
     * @throws DataException
743
     *
744
     */
745
    public Feature getFeatureByReference(FeatureReference reference,
746
        FeatureType featureType) throws DataException;
747

    
748
    /*
749
     * =============================================================
750
     *
751
     * Editing related services
752
     */
753

    
754
    /**
755
     * Enters editing state.
756
     * @throws org.gvsig.fmap.dal.exception.DataException
757
     */
758
    public void edit() throws DataException;
759

    
760
    /**
761
     * Enters editing state specifying the editing mode.
762
     *
763
     * @param mode
764
     *
765
     * @throws DataException
766
     */
767
    public void edit(int mode) throws DataException;
768
    
769
    public void edit(int mode, int submode) throws DataException;
770
    
771
    public int getSubmode();
772
    
773
    public int getMode();
774

    
775
    /**
776
     * Cancels all editing since the last edit().
777
     *
778
     * @throws DataException
779
     */
780
    public void cancelEditing() throws DataException;
781

    
782
    public boolean cancelEditingQuietly();
783

    
784
    public static boolean cancelEditingQuietly(FeatureStore store) {
785
        if( store==null ) {
786
            return true;
787
        }
788
        return store.cancelEditingQuietly();
789
    }
790
    
791
    /**
792
     * Exits editing state.
793
     *
794
     * @throws DataException
795
     */
796
    public void finishEditing() throws DataException;
797

    
798
    public boolean finishEditingQuietly();
799
    
800
    public static boolean finishEditingQuietly(FeatureStore store) {
801
        if( store==null ) {
802
            return true;
803
        }
804
        return store.finishEditingQuietly();
805
    }
806

    
807
    /**
808
     * Save changes in the provider without leaving the edit mode.
809
     * Do not call observers to communicate a change of ediding mode.
810
     * The operation's history is eliminated to prevent inconsistencies
811
     * in the data.
812
     *
813
     * @throws DataException
814
     */
815
    public void commitChanges() throws DataException ;
816

    
817
    /**
818
     *
819
     * Returns true if you can call CommitChanges method.
820
     * If not in editing or changes have been made in the structure
821
     * return false.
822
     *
823
     * @return true if can call commitChanges
824
     * @throws DataException
825
     */
826
    public boolean canCommitChanges() throws DataException;
827

    
828

    
829
    /**
830
     * Indicates whether this store is in editing state.
831
     *
832
     * @return
833
     *         true if this store is in editing state, false if not.
834
     */
835
    public boolean isEditing();
836

    
837
    /**
838
     * Indicates whether this store is in appending state. In this state the new
839
     * features are automatically inserted at the end of the {@link FeatureSet}.
840
     *
841
     * @return true if this store is in appending state.
842
     */
843
    public boolean isAppending();
844

    
845
    /**
846
     * Updates a {@link FeatureType} in the store with the changes in the
847
     * {@link EditableFeatureType}.<br>
848
     *
849
     * Any {@link FeatureSet} from this store that are used will be invalidated.
850
     *
851
     * @param featureType
852
     *            an {@link EditableFeatureType} with the changes.
853
     *
854
     * @throws DataException
855
     */
856
    public void update(EditableFeatureType featureType) throws DataException;
857

    
858
    /**
859
     * Updates a {@link Feature} in the store with the changes in the
860
     * {@link EditableFeature}.<br>
861
     *
862
     * Any {@link FeatureSet} from this store that was still in use will be
863
     * invalidated. You can override this using
864
     * {@link FeatureSet#update(EditableFeature)}.
865
     *
866
     * @param feature
867
     *            the feature to be updated
868
     *
869
     * @throws DataException
870
     */
871
    public void update(EditableFeature feature) throws DataException;
872

    
873
    /**
874
     * Updates Features in the store with the values of the parameters.
875
     * Examples:
876
     *      update("field1",value1,"field2",value2);
877
     *      update("field1",value1,"field2",value2,filter);
878
     * 
879
     * filter can be a {@link Expression} or a String
880
     * 
881
     * @param parameters
882
     * @throws DataException 
883
     */
884
    public void update(Object... parameters) throws DataException;
885

    
886
    /**
887
     * Deletes a {@link Feature} from the store.<br>
888
     *
889
     * Any {@link FeatureSet} from this store that was still in use will be
890
     * invalidated. You can override this using {@link Iterator#remove()} from
891
     * {@link FeatureSet}.
892
     *
893
     * @param feature
894
     *            The feature to be deleted.
895
     *
896
     * @throws DataException
897
     */
898
    public void delete(Feature feature) throws DataException;
899
    
900
    public void delete(String filter);
901
    
902
    public void delete(Expression filter);
903

    
904
    /**
905
     * Inserts a {@link Feature} in the store.<br>
906
     *
907
     * Any {@link FeatureSet} from this store that was still in use will be
908
     * invalidated. You can override this using
909
     * {@link FeatureSet#insert(EditableFeature)}.
910
     *
911
     * @param feature
912
     *            The feature to be inserted
913
     *
914
     * @throws DataException
915
     */
916
    public void insert(EditableFeature feature) throws DataException;
917

    
918
    /**
919
     * Inserts a set of {@link Feature} in the store.
920
     * 
921
     * The attributes of the feature are copied from the features of the set 
922
     * by name, forcing the conversion of types if necessary.
923
     *
924
     * Any {@link FeatureSet} from this store that was still in use will be
925
     * invalidated.
926
     *
927
     * @param set, set with the source features.
928
     * @throws DataException
929
     */
930
    public void insert(FeatureSet set) throws DataException;
931
    
932
    /**
933
     * Creates a new feature using the default feature type and returns it as an
934
     * {@link EditableFeature}
935
     *
936
     * @return a new feature in editable state
937
     *
938
     * @throws DataException
939
     */
940
    public EditableFeature createNewFeature() throws DataException;
941

    
942
    /**
943
     * Creates a new feature of the given {@link FeatureType} and uses the given
944
     * {@link Feature} as default values to initialize it.
945
     *
946
     * @param type
947
     *            the new feature's feature type
948
     *
949
     * @param defaultValues
950
     *            a feature whose values are used as default values for the new
951
     *            feature.
952
     *
953
     * @return the new feature.
954
     *
955
     * @throws DataException
956
     */
957
    public EditableFeature createNewFeature(FeatureType type,
958
        Feature defaultValues) throws DataException;
959

    
960
    /**
961
     * Creates a new feature of the given {@link FeatureType}. The flag
962
     * defaultValues is used to indicate whether the new feature should be
963
     * initialized with default values or not.
964
     *
965
     * @param type
966
     *            the new feature's feature type
967
     *
968
     * @param defaultValues
969
     *            if true the new feature is initialized with each attribute's
970
     *            default value.
971
     *
972
     * @return
973
     *         the new feature
974
     *
975
     * @throws DataException
976
     */
977
    public EditableFeature createNewFeature(FeatureType type,
978
        boolean defaultValues) throws DataException;
979

    
980
    /**
981
     * Creates a new feature of default {@link FeatureType}. The flag
982
     * defaultValues is used to indicate whether the new feature should be
983
     * initialized with default values or not.
984
     *
985
     * @param defaultValues
986
     *            if true the new feature is initialized with each attribute's
987
     *            default value.
988
     *
989
     * @return
990
     *         the new feature
991
     *
992
     * @throws DataException
993
     */
994
    public EditableFeature createNewFeature(boolean defaultValues)
995
        throws DataException;
996

    
997
    /**
998
     * Creates a new feature of default {@link FeatureType}.
999
     * The new feature should be initialized with the values of the feature
1000
     * passed as parameter.
1001
     * Values are inicialiced by name from the feature specified. Error in
1002
     * value assignement are ignoreds.
1003
     *
1004
     * @param defaultValues the values to initialize the new feature.
1005
     * @return the new feature
1006
     * @throws DataException
1007
     */
1008
    public EditableFeature createNewFeature(Feature defaultValues)
1009
        throws DataException;
1010

    
1011
    public EditableFeature createNewFeature(JsonObject defaultValues)
1012
        throws DataException;
1013

    
1014
    /**
1015
     * Indicates whether this store supports append mode.
1016
     *
1017
     * @return
1018
     *         true if this store supports append mode.
1019
     */
1020
    public boolean isAppendModeSupported();
1021

    
1022
    /**
1023
     * Initiates an editing group. This is typically used to group series of
1024
     * store editing operations.
1025
     *
1026
     * @param description
1027
     *            Description of the editing group.
1028
     *
1029
     * @throws NeedEditingModeException
1030
     */
1031
    public void beginEditingGroup(String description)
1032
        throws NeedEditingModeException;
1033

    
1034
    /**
1035
     * Finishes an editing group.
1036
     *
1037
     * @throws NeedEditingModeException
1038
     */
1039
    public void endEditingGroup() throws NeedEditingModeException;
1040

    
1041
    /*
1042
     * =============================================================
1043
     *
1044
     * Index related services
1045
     */
1046

    
1047
    /**
1048
     * Creates an index which will be applied to the features of the given type,
1049
     * by using the data of the given attribute.
1050
     *
1051
     * @param featureType
1052
     *            The FeatureType to which the indexed attribute belongs.
1053
     *
1054
     * @param attributeName
1055
     *            The name of the attributed to be indexed
1056
     *
1057
     * @param indexName
1058
     *            The index name
1059
     *
1060
     * @return the resulting {@link FeatureIndex}
1061
     *
1062
     *
1063
     * @throws FeatureIndexException
1064
     *             if there is an error creating the index
1065
     */
1066
    public FeatureIndex createIndex(FeatureType featureType,
1067
        String attributeName, String indexName) throws DataException;
1068

    
1069
    /**
1070
     * Creates an index which will be applied to the features of the given type,
1071
     * by using the data of the given attribute.
1072
     *
1073
     * @param indexTypeName
1074
     *            the type of the index to be created. That name is
1075
     *            related to one of the registered index providers
1076
     * @param featureType
1077
     *            The FeatureType to which the indexed attribute belongs.
1078
     *
1079
     * @param attributeName
1080
     *            The name of the attributed to be indexed
1081
     *
1082
     * @param indexName
1083
     *            The index name
1084
     *
1085
     * @return the resulting {@link FeatureIndex}
1086
     *
1087
     *
1088
     * @throws FeatureIndexException
1089
     *             if there is an error creating the index
1090
     */
1091
    public FeatureIndex createIndex(String indexTypeName,
1092
        FeatureType featureType, String attributeName, String indexName)
1093
        throws DataException;
1094

    
1095
    /**
1096
     * Creates an index which will be applied to the features of the given type,
1097
     * by using the data of the given attribute. This method will return without
1098
     * waiting for the index to be filled, as that will be performed in
1099
     * background. An optional {@link Observer} parameter is provided to be
1100
     * notified ( {@link FeatureStoreNotification#INDEX_FILLING_SUCCESS} )
1101
     * when the index has finished filling with data and is available to be
1102
     * used.
1103
     *
1104
     * @param featureType
1105
     *            The FeatureType to which the indexed attribute belongs.
1106
     *
1107
     * @param attributeName
1108
     *            The name of the attributed to be indexed
1109
     *
1110
     * @param indexName
1111
     *            The index name
1112
     *
1113
     * @param observer
1114
     *            to notify to when the created index has finished filling
1115
     *            with data and is available to be used. The observer will
1116
     *            receive then a
1117
     *            {@link FeatureStoreNotification#INDEX_FILLING_SUCCESS}
1118
     *            notification, with the index object if it has finished
1119
     *            successfully, or a
1120
     *            {@link FeatureStoreNotification#INDEX_FILLING_ERROR}
1121
     *            notification with the exception object if there has been
1122
     *            any error in the process. Optional.
1123
     *
1124
     * @return the resulting {@link FeatureIndex}
1125
     *
1126
     * @see FeatureStoreNotification#INDEX_FILLING_STARTED
1127
     * @see FeatureStoreNotification#INDEX_FILLING_SUCCESS
1128
     * @see FeatureStoreNotification#INDEX_FILLING_CANCELLED
1129
     * @see FeatureStoreNotification#INDEX_FILLING_ERROR
1130
     *
1131
     * @throws FeatureIndexException
1132
     *             if there is an error creating the index
1133
     */
1134
    public FeatureIndex createIndex(FeatureType featureType,
1135
        String attributeName, String indexName, Observer observer)
1136
        throws DataException;
1137

    
1138
    /**
1139
     * Creates an index which will be applied to the features of the given type,
1140
     * by using the data of the given attribute. This method will return without
1141
     * waiting for the index to be filled, as that will be performed in
1142
     * background. An optional {@link Observer} parameter is provided to be
1143
     * notified ( {@link FeatureStoreNotification#INDEX_FILLING_SUCCESS} )
1144
     * when the index has finished filling with data and is available to be
1145
     * used.
1146
     *
1147
     * @param indexTypeName
1148
     *            the type of the index to be created. That name is
1149
     *            related to one of the registered index providers
1150
     * @param featureType
1151
     *            The FeatureType to which the indexed attribute belongs.
1152
     *
1153
     * @param attributeName
1154
     *            The name of the attributed to be indexed
1155
     *
1156
     * @param indexName
1157
     *            The index name
1158
     *
1159
     * @param observer
1160
     *            to notify to when the created index has finished filling
1161
     *            with data and is available to be used. The observer will
1162
     *            receive then a
1163
     *            {@link FeatureStoreNotification#INDEX_FILLING_SUCCESS}
1164
     *            notification, with the index object if it has finished
1165
     *            successfully, or a
1166
     *            {@link FeatureStoreNotification#INDEX_FILLING_ERROR}
1167
     *            notification with the exception object if there has been
1168
     *            any error in the process. Optional.
1169
     *
1170
     * @return the resulting {@link FeatureIndex}
1171
     *
1172
     * @see FeatureStoreNotification#INDEX_FILLING_STARTED
1173
     * @see FeatureStoreNotification#INDEX_FILLING_SUCCESS
1174
     * @see FeatureStoreNotification#INDEX_FILLING_CANCELLED
1175
     * @see FeatureStoreNotification#INDEX_FILLING_ERROR
1176
     *
1177
     * @throws FeatureIndexException
1178
     *             if there is an error creating the index
1179
     */
1180
    public FeatureIndex createIndex(String indexTypeName,
1181
        FeatureType featureType, String attributeName, String indexName,
1182
        Observer observer) throws DataException;
1183

    
1184
    /**
1185
     * Returns a FeatureIndexes structure containing all available indexes in
1186
     * the store.
1187
     *
1188
     * @return
1189
     */
1190
    public FeatureIndexes getIndexes();
1191

    
1192
    /*
1193
     * =============================================================
1194
     *
1195
     * Selection related services
1196
     */
1197

    
1198
    /**
1199
     * Sets the selection to the passed {@link FeatureSet}
1200
     *
1201
     * @param selection
1202
     *            A {@link FeatureSet} with the requested selection
1203
     * @throws org.gvsig.fmap.dal.exception.DataException
1204
     */
1205
    public void setSelection(FeatureSet selection) throws DataException;
1206

    
1207
    /**
1208
     * Creates a {@link FeatureSelection}
1209
     *
1210
     * @return
1211
     *         a {@link FeatureSelection}
1212
     *
1213
     * @throws DataException
1214
     */
1215
    public FeatureSelection createFeatureSelection() throws DataException;
1216
    
1217
    public FeatureSelection createLargeFeatureSelection() throws DataException;
1218
            
1219
    /**
1220
     * Creates a {@link FeatureSelection}
1221
     *
1222
     * @return
1223
     *         a {@link FeatureSelection}
1224
     *
1225
     * @throws DataException
1226
     */
1227
    public FeatureSelection createMemoryFeatureSelection() throws DataException;
1228

    
1229

    
1230
    /**
1231
     * Returns the current {@link FeatureSelection}.
1232
     * Create a empty selection if not exits.
1233
     * 
1234
     * Manage of the selection can be slow on some data sources. 
1235
     * Use with care.
1236
     * In data sources that do not support position access to records, 
1237
     * it may be slow to retrieve items from the selection. In some data 
1238
     * sources it may be necessary to access to this to retrieve each 
1239
     * item in the selection.
1240
     *
1241
     * @return
1242
     *         current {@link FeatureSelection}.
1243
     *
1244
     * @throws DataException
1245
     */
1246
    public FeatureSelection getFeatureSelection() throws DataException;
1247

    
1248
    public FeatureSelection getFeatureSelectionQuietly();
1249

    
1250
    /*
1251
     * =============================================================
1252
     *
1253
     * Lock related services
1254
     */
1255

    
1256
    /**
1257
     * Indicates whether this store supports locks.
1258
     *
1259
     * @return
1260
     *         true if this store supports locks, false if not.
1261
     */
1262
    public boolean isLocksSupported();
1263

    
1264
    /**
1265
     * Returns the set of locked features
1266
     *
1267
     * @return
1268
     *         set of locked features
1269
     *
1270
     * @throws DataException
1271
     */
1272
    public FeatureLocks getLocks() throws DataException;
1273

    
1274
    /*
1275
     * =============================================================
1276
     * Transforms related services
1277
     * =============================================================
1278
     */
1279

    
1280
    /**
1281
     * Returns this store transforms
1282
     *
1283
     * @return
1284
     *         this store transforms
1285
     */
1286
    public FeatureStoreTransforms getTransforms();
1287

    
1288
    /**
1289
     * Returns a new {@link FeatureQuery} associated to this store.
1290
     *
1291
     * @return
1292
     *         a new {@link FeatureQuery} associated to this store.
1293
     */
1294
    public FeatureQuery createFeatureQuery();
1295

    
1296
    /**
1297
     * Returns featue count of this store.
1298
     *
1299
     * @return
1300
     * @throws DataException
1301
     */
1302
    public long getFeatureCount() throws DataException;
1303

    
1304
//    /**
1305
//     * Creates a vectorial cache that is used to save and retrieve data.
1306
//     *
1307
//     * @param name
1308
//     *            the cache name.
1309
//     * @param parameters
1310
//     *            parameters to create the stores used to save data.
1311
//     * @throws DataException
1312
//     */
1313
//    public void createCache(String name, DynObject parameters)
1314
//        throws DataException;
1315
//
1316
//    /**
1317
//     * @return the vectorial cache
1318
//     */
1319
//    public FeatureCache getCache();
1320

    
1321
    /**
1322
     * Return if the provider knows the real envelope of a layer. If not,
1323
     * the {@link FeatureStoreProvider#getEnvelope()} method doesn't return
1324
     * the full envelope.
1325
     *
1326
     * @return true if it knows the real envelope.
1327
     */
1328
    public boolean isKnownEnvelope();
1329

    
1330
    /**
1331
     * Return if the maximum number of features provided by the
1332
     * provider are limited.
1333
     *
1334
     * @return true if there is a limit of features.
1335
     */
1336
    public boolean hasRetrievedFeaturesLimit();
1337

    
1338
    /**
1339
     * If the {@link FeatureStoreProvider#hasRetrievedFeaturesLimit()} returns
1340
     * true,
1341
     * it returns the limit of features retrieved from the provider.
1342
     *
1343
     * @return
1344
     *         The limit of the retrieved features.
1345
     */
1346
    public int getRetrievedFeaturesLimit();
1347

    
1348
    /**
1349
     * Return the associated feature to the dynobject.
1350
     * If the dynobject isn't associated to a feature of this store, return null.
1351
     *
1352
     * @param dynobject
1353
     * @return
1354
     */
1355
    public Feature getFeature(DynObject dynobject);
1356

    
1357

    
1358
    public ExpressionBuilder createExpressionBuilder();
1359

    
1360
    /**
1361
     * 
1362
     * @return 
1363
     * @deprecated use createExpressionBuilder
1364
     */
1365
    public ExpressionBuilder createExpression();
1366

    
1367
    public void createCache(String name, DynObject parameters)
1368
        throws DataException;
1369

    
1370
    @Override
1371
    public FeatureCache getCache();
1372

    
1373
    public boolean isBroken();
1374

    
1375
    public Throwable getBreakingsCause();
1376

    
1377
    /**
1378
     * Indicates if the storage is temporary.
1379
     * There is no guarantee that a temporary store can be recovered from 
1380
     * its parameters. In general these will not be persistent.
1381
     * 
1382
     * @return true if the store is temporary, otherwise false.
1383
     */
1384
    public boolean isTemporary();
1385
    
1386
    public void setTemporary(Boolean temporary);
1387

    
1388
    /**
1389
     * @param index
1390
     * @return
1391
     */
1392
    public SpatialIndex wrapSpatialIndex(SpatialIndex index);
1393
    
1394
    public FeatureReference getFeatureReference(String code);
1395

    
1396
    /**
1397
     * Devuelbe el numero de operaciones pendientes de guardar en una sesion
1398
     * de edicion. Es un valor orientativo.
1399
     * Las operaciones pendientes son la suma de operaciones de borrado, insercion
1400
     * o modificacion de las features en una sesion de edicion.
1401
     * 
1402
     * Retorna 0 si no esta en edicion.
1403
     * 
1404
     * @return numero de operaciones pendientes. 
1405
     */
1406
    public long getPendingChangesCount();
1407
    
1408
    public Feature getSampleFeature();
1409
    
1410
    /**
1411
     * Return true when the default feature type of the store 
1412
     * support references.
1413
     * 
1414
     * @return true when support references.
1415
     */
1416
    public boolean supportReferences();
1417
    
1418
    public Feature getOriginalFeature(FeatureReference id);
1419

    
1420
    public Feature getOriginalFeature(Feature feature);
1421
    
1422
    public boolean isFeatureModified(FeatureReference id);
1423

    
1424
    public boolean isFeatureModified(Feature feature);
1425
    
1426
    public String getEditingSession();
1427

    
1428
    public List<FeatureReference> getEditedFeatures();
1429
    
1430
    public List<FeatureReference> getEditedFeaturesNotValidated();
1431

    
1432
    public boolean isFeatureSelectionEmpty();
1433
    
1434
    public boolean isFeatureSelectionAvailable();
1435
    
1436
    public Iterator<Feature> getFeaturesIterator(Iterator<FeatureReference> references);
1437
    
1438
    public Iterable<Feature> getFeaturesIterable(Iterator<FeatureReference> references);
1439
    
1440
    public boolean canBeEdited();
1441

    
1442
    public String getLabel();
1443

    
1444
    public Predicate<FeatureStoreNotification> setNotificationsFilter(Predicate<FeatureStoreNotification> filter);
1445

    
1446
}