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

History | View | Annotate | Download (51.5 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.dal.feature;
25

    
26
import java.util.Iterator;
27
import java.util.List;
28
import javax.json.JsonObject;
29
import org.apache.commons.lang3.StringUtils;
30
import org.cresques.cts.IProjection;
31
import org.gvsig.expressionevaluator.Expression;
32
import org.gvsig.expressionevaluator.ExpressionBuilder;
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
import org.gvsig.tools.util.GetItemWithSizeIsEmptyAndIterator64;
49
import org.gvsig.tools.util.PropertiesSupport;
50
import org.gvsig.tools.util.Size64;
51
import org.gvsig.tools.util.UnmodifiableBasicList64;
52

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

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

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

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

    
114
    /** Indicates that this store is in append mode */
115
    final static int MODE_APPEND = 2;
116
    
117
    final static int MODE_PASS_THROUGH = 3;
118

    
119
    /*
120
     * =============================================================
121
     *
122
     * information related services
123
     */
124

    
125
    /**
126
     * Indicates whether this store allows writing.
127
     *
128
     * @return
129
     *         true if this store can be written, false if not.
130
     */
131
    public boolean allowWrite();
132

    
133
    /**
134
     * Returns this store's default {@link FeatureType}.
135
     *
136
     * @return
137
     *         this store's default {@link FeatureType}.
138
     *
139
     * @throws DataException
140
     */
141
    public FeatureType getDefaultFeatureType() throws DataException;
142
    
143
    public FeatureType getDefaultFeatureTypeQuietly();
144

    
145
    /**
146
     * Returns this store's featureType {@link FeatureType} matches with
147
     * featureTypeId.
148
     *
149
     * @param featureTypeId
150
     *
151
     * @return this store's default {@link FeatureType}.
152
     *
153
     * @throws DataException
154
     */
155
    public FeatureType getFeatureType(String featureTypeId)
156
        throws DataException;
157

    
158
    /**
159
     * Returns this store's {@link FeatureType}(s).
160
     *
161
     * @return a list with this store's {@link FeatureType}(s).
162
     *
163
     * @throws DataException
164
     */
165
    public List getFeatureTypes() throws DataException;
166

    
167
    /**
168
     * Returns this store's parameters.
169
     *
170
     * @return
171
     *         {@link DataStoreParameters} containing this store's parameters
172
     */
173
    public DataStoreParameters getParameters();
174

    
175
    /**
176
     * @param gvSIGgeometryType
177
     * @return 
178
     * @throws DataException
179
     * @deprecated Mirar de cambiarlo a metadatos
180
     */
181
    public boolean canWriteGeometry(int gvSIGgeometryType) throws DataException;
182

    
183
    /**
184
     * Returns this store's total envelope (extent).
185
     *
186
     * @return this store's total envelope (extent) or <code>null</code> if
187
     *         store not have geometry information
188
     * @throws org.gvsig.fmap.dal.exception.DataException
189
     */
190
    public Envelope getEnvelope() throws DataException;
191

    
192
    /**
193
     *
194
     * @deprecated use getDefaultFeatureType().getDefaultSRS()
195
     * @return
196
     * @throws DataException
197
     */
198
    public IProjection getSRSDefaultGeometry() throws DataException;
199

    
200
    /**
201
     * Exports this store to another store.
202
     *
203
     * @param explorer
204
     *            {@link DataServerExplorer} target
205
     * @param provider
206
     * @param params
207
     *            New parameters of this store that will be used on the target
208
     *            explorer
209
     *
210
     * @throws DataException
211
     *
212
     * @Deprecated this method is unstable
213
     */
214
    public void export(DataServerExplorer explorer, String provider,
215
        NewFeatureStoreParameters params, String name) throws DataException;
216

    
217
    public void copyTo(FeatureStore target);
218

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

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

    
315
    
316
    
317
    /**
318
     * Returns all available features in the store.
319
     *
320
     * It is a utility method that calls {@link #getFeatureSet(FeatureQuery)}
321
     * 
322
     * @return the {@link FeatureSet} 
323
     * @throws ReadException if there is any error while reading the features
324
     * @see {@link #accept(org.gvsig.tools.visitor.Visitor)}, {@link #getFeatureSet(FeatureQuery)}
325
     */
326
    FeatureSet getFeatureSet() throws DataException;
327

    
328
    /**
329
     * Return a subset of features.
330
     * 
331
     * It is a utility method that calls {@link #getFeatureSet(FeatureQuery)}
332
     * 
333
     * @param filter an {@link String} expression used to filter the features in the store.
334
     * @return the {@link FeatureSet} 
335
     * @throws ReadException if there is any error while reading the features
336
     * @see {@link #createFeatureQuery(Expression,String,boolean)}, {@link #getFeatureSet(FeatureQuery)}
337
     */
338
    FeatureSet getFeatureSet(String filter) throws DataException;
339

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

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

    
369
    /**
370
     * Return a subset of features.
371
     * 
372
     * It is a utility method that calls {@link #getFeatureSet(FeatureQuery)}
373
     * 
374
     * @param filter an {@link Expression} used to filter the features in the store.
375
     * @return the {@link FeatureSet} 
376
     * @throws DataException 
377
     * @see {@link #createFeatureQuery(Expression,String,boolean)}, {@link #getFeatureSet(FeatureQuery)}
378
     */
379
    FeatureSet getFeatureSet(Expression filter) throws DataException;
380

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

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

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

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

    
447
    /**
448
     * Loads all available feature in the store. The loading of Features is
449
     * performed by calling the Observer, once each loaded Feature.
450
     *
451
     * @param observer to be notified of each loaded Feature
452
     * @throws DataException if there is any error while loading the features
453
     */
454
    void getFeatureSet(Observer observer) throws DataException;
455

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

    
477
    /**
478
     * Return a paginated list of Features.
479
     * 
480
     * It is a utility method that calls {@link #getFeatures(FeatureQuery, int)}
481
     * using the default page size.
482
     * 
483
     * @param query to filter and sort the returned feature list
484
     * @return the {@link List}/{@link UnmodifiableBasicList64} of features
485
     * @see {@link #getFeatures(FeatureQuery, int)}
486
     */
487
    public List<Feature> getFeatures(FeatureQuery query);
488

    
489
    /**
490
     * Return a paginated list with al Features in the store.
491
     * 
492
     * It is a utility method that calls {@link #getFeatures(FeatureQuery, int)}
493
     * using the default page size.
494
     * 
495
     * @return the {@link List}/{@link UnmodifiableBasicList64} of features
496
     * @see {@link #getFeatures(FeatureQuery, int)}
497
     */
498
    public List<Feature> getFeatures();
499

    
500
    /**
501
     * Return a paginated list of Features
502
     * 
503
     * It is a utility method that calls {@link #getFeatures(FeatureQuery, int)}
504
     * 
505
     * @param filter used to filter the features in the store.
506
     * @return the List of Features
507
     * @see {@link #getFeatures(FeatureQuery, int)}, {@link #createFeatureQuery(String,String,boolean)}
508
     */
509
    public List<Feature> getFeatures(String filter);
510

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

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

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

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

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

    
577
    public GetItemWithSizeIsEmptyAndIterator64<Feature> getFeatures64();
578

    
579
    public GetItemWithSizeIsEmptyAndIterator64<Feature> getFeatures64(String filter);
580
    
581
    public GetItemWithSizeIsEmptyAndIterator64<Feature> getFeatures64(String filter, String sortBy, boolean asc);
582
    
583
    public GetItemWithSizeIsEmptyAndIterator64<Feature> getFeatures64(FeatureQuery query, int pageSize);
584
    
585
    /**
586
     * Return the first {@link Feature} of the store.
587
     * 
588
     * @return the first {@link Feature} or null if the store is empty.
589
     * @throws DataException 
590
     */
591
    public Feature first() throws DataException;
592

    
593
    /**
594
     * Returns the first {@link Feature} that meets the criteria indicated.
595
     * 
596
     * It is a utility method that calls {@link #findFirst(FeatureQuery)}.
597
     * 
598
     * @param filter {@link String} expression used to filter the features.
599
     * @return the first {@link Feature} or null if the filter don't return any feature.
600
     * @throws DataException 
601
     * @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(String,String,boolean)}
602
     */
603
    public Feature findFirst(String filter) throws DataException;
604

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

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

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

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

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

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

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

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

    
712
    /**
713
     * Returns the feature given its reference.
714
     *
715
     * @param reference a unique FeatureReference
716
     * @return 
717
     * @returnThe Feature
718
     * @throws DataException
719
     *
720
     */
721
    public Feature getFeatureByReference(FeatureReference reference) throws DataException;
722

    
723
    /**
724
     * Returns the feature given its reference and feature type.
725
     *
726
     * @param reference
727
     *            a unique FeatureReference
728
     *
729
     * @param featureType
730
     *            FeatureType to which the requested Feature belongs
731
     *
732
     * @return
733
     *         The Feature
734
     *
735
     * @throws DataException
736
     *
737
     */
738
    public Feature getFeatureByReference(FeatureReference reference,
739
        FeatureType featureType) throws DataException;
740

    
741
    /*
742
     * =============================================================
743
     *
744
     * Editing related services
745
     */
746

    
747
    /**
748
     * Enters editing state.
749
     * @throws org.gvsig.fmap.dal.exception.DataException
750
     */
751
    public void edit() throws DataException;
752

    
753
    /**
754
     * Enters editing state specifying the editing mode.
755
     *
756
     * @param mode
757
     *
758
     * @throws DataException
759
     */
760
    public void edit(int mode) throws DataException;
761
    
762
    public int getMode();
763

    
764
    /**
765
     * Cancels all editing since the last edit().
766
     *
767
     * @throws DataException
768
     */
769
    public void cancelEditing() throws DataException;
770

    
771
    public boolean cancelEditingQuietly();
772

    
773
    public static boolean cancelEditingQuietly(FeatureStore store) {
774
        if( store==null ) {
775
            return true;
776
        }
777
        return store.cancelEditingQuietly();
778
    }
779
    
780
    /**
781
     * Exits editing state.
782
     *
783
     * @throws DataException
784
     */
785
    public void finishEditing() throws DataException;
786

    
787
    public boolean finishEditingQuietly();
788
    
789
    public static boolean finishEditingQuietly(FeatureStore store) {
790
        if( store==null ) {
791
            return true;
792
        }
793
        return store.finishEditingQuietly();
794
    }
795

    
796
    /**
797
     * Save changes in the provider without leaving the edit mode.
798
     * Do not call observers to communicate a change of ediding mode.
799
     * The operation's history is eliminated to prevent inconsistencies
800
     * in the data.
801
     *
802
     * @throws DataException
803
     */
804
    public void commitChanges() throws DataException ;
805

    
806
    /**
807
     *
808
     * Returns true if you can call CommitChanges method.
809
     * If not in editing or changes have been made in the structure
810
     * return false.
811
     *
812
     * @return true if can call commitChanges
813
     * @throws DataException
814
     */
815
    public boolean canCommitChanges() throws DataException;
816

    
817

    
818
    /**
819
     * Indicates whether this store is in editing state.
820
     *
821
     * @return
822
     *         true if this store is in editing state, false if not.
823
     */
824
    public boolean isEditing();
825

    
826
    /**
827
     * Indicates whether this store is in appending state. In this state the new
828
     * features are automatically inserted at the end of the {@link FeatureSet}.
829
     *
830
     * @return true if this store is in appending state.
831
     */
832
    public boolean isAppending();
833

    
834
    /**
835
     * Updates a {@link FeatureType} in the store with the changes in the
836
     * {@link EditableFeatureType}.<br>
837
     *
838
     * Any {@link FeatureSet} from this store that are used will be invalidated.
839
     *
840
     * @param featureType
841
     *            an {@link EditableFeatureType} with the changes.
842
     *
843
     * @throws DataException
844
     */
845
    public void update(EditableFeatureType featureType) throws DataException;
846

    
847
    /**
848
     * Updates a {@link Feature} in the store with the changes in the
849
     * {@link EditableFeature}.<br>
850
     *
851
     * Any {@link FeatureSet} from this store that was still in use will be
852
     * invalidated. You can override this using
853
     * {@link FeatureSet#update(EditableFeature)}.
854
     *
855
     * @param feature
856
     *            the feature to be updated
857
     *
858
     * @throws DataException
859
     */
860
    public void update(EditableFeature feature) throws DataException;
861

    
862
    /**
863
     * Updates Features in the store with the values of the parameters.
864
     * Examples:
865
     *      update("field1",value1,"field2",value2);
866
     *      update("field1",value1,"field2",value2,filter);
867
     * 
868
     * filter can be a {@link Expression} or a String
869
     * 
870
     * @param parameters
871
     * @throws DataException 
872
     */
873
    public void update(Object... parameters) throws DataException;
874

    
875
    /**
876
     * Deletes a {@link Feature} from the store.<br>
877
     *
878
     * Any {@link FeatureSet} from this store that was still in use will be
879
     * invalidated. You can override this using {@link Iterator#remove()} from
880
     * {@link FeatureSet}.
881
     *
882
     * @param feature
883
     *            The feature to be deleted.
884
     *
885
     * @throws DataException
886
     */
887
    public void delete(Feature feature) throws DataException;
888
    
889
    public void delete(String filter);
890
    
891
    public void delete(Expression filter);
892

    
893
    /**
894
     * Inserts a {@link Feature} in the store.<br>
895
     *
896
     * Any {@link FeatureSet} from this store that was still in use will be
897
     * invalidated. You can override this using
898
     * {@link FeatureSet#insert(EditableFeature)}.
899
     *
900
     * @param feature
901
     *            The feature to be inserted
902
     *
903
     * @throws DataException
904
     */
905
    public void insert(EditableFeature feature) throws DataException;
906

    
907
    /**
908
     * Inserts a set of {@link Feature} in the store.
909
     * 
910
     * The attributes of the feature are copied from the features of the set 
911
     * by name, forcing the conversion of types if necessary.
912
     *
913
     * Any {@link FeatureSet} from this store that was still in use will be
914
     * invalidated.
915
     *
916
     * @param set, set with the source features.
917
     * @throws DataException
918
     */
919
    public void insert(FeatureSet set) throws DataException;
920
    
921
    /**
922
     * Creates a new feature using the default feature type and returns it as an
923
     * {@link EditableFeature}
924
     *
925
     * @return a new feature in editable state
926
     *
927
     * @throws DataException
928
     */
929
    public EditableFeature createNewFeature() throws DataException;
930

    
931
    /**
932
     * Creates a new feature of the given {@link FeatureType} and uses the given
933
     * {@link Feature} as default values to initialize it.
934
     *
935
     * @param type
936
     *            the new feature's feature type
937
     *
938
     * @param defaultValues
939
     *            a feature whose values are used as default values for the new
940
     *            feature.
941
     *
942
     * @return the new feature.
943
     *
944
     * @throws DataException
945
     */
946
    public EditableFeature createNewFeature(FeatureType type,
947
        Feature defaultValues) throws DataException;
948

    
949
    /**
950
     * Creates a new feature of the given {@link FeatureType}. The flag
951
     * defaultValues is used to indicate whether the new feature should be
952
     * initialized with default values or not.
953
     *
954
     * @param type
955
     *            the new feature's feature type
956
     *
957
     * @param defaultValues
958
     *            if true the new feature is initialized with each attribute's
959
     *            default value.
960
     *
961
     * @return
962
     *         the new feature
963
     *
964
     * @throws DataException
965
     */
966
    public EditableFeature createNewFeature(FeatureType type,
967
        boolean defaultValues) throws DataException;
968

    
969
    /**
970
     * Creates a new feature of default {@link FeatureType}. The flag
971
     * defaultValues is used to indicate whether the new feature should be
972
     * initialized with default values or not.
973
     *
974
     * @param defaultValues
975
     *            if true the new feature is initialized with each attribute's
976
     *            default value.
977
     *
978
     * @return
979
     *         the new feature
980
     *
981
     * @throws DataException
982
     */
983
    public EditableFeature createNewFeature(boolean defaultValues)
984
        throws DataException;
985

    
986
    /**
987
     * Creates a new feature of default {@link FeatureType}.
988
     * The new feature should be initialized with the values of the feature
989
     * passed as parameter.
990
     * Values are inicialiced by name from the feature specified. Error in
991
     * value assignement are ignoreds.
992
     *
993
     * @param defaultValues the values to initialize the new feature.
994
     * @return the new feature
995
     * @throws DataException
996
     */
997
    public EditableFeature createNewFeature(Feature defaultValues)
998
        throws DataException;
999

    
1000
    public EditableFeature createNewFeature(JsonObject defaultValues)
1001
        throws DataException;
1002

    
1003
    /**
1004
     * Indicates whether this store supports append mode.
1005
     *
1006
     * @return
1007
     *         true if this store supports append mode.
1008
     */
1009
    public boolean isAppendModeSupported();
1010

    
1011
    /**
1012
     * Initiates an editing group. This is typically used to group series of
1013
     * store editing operations.
1014
     *
1015
     * @param description
1016
     *            Description of the editing group.
1017
     *
1018
     * @throws NeedEditingModeException
1019
     */
1020
    public void beginEditingGroup(String description)
1021
        throws NeedEditingModeException;
1022

    
1023
    /**
1024
     * Finishes an editing group.
1025
     *
1026
     * @throws NeedEditingModeException
1027
     */
1028
    public void endEditingGroup() throws NeedEditingModeException;
1029

    
1030
    /*
1031
     * =============================================================
1032
     *
1033
     * Index related services
1034
     */
1035

    
1036
    /**
1037
     * Creates an index which will be applied to the features of the given type,
1038
     * by using the data of the given attribute.
1039
     *
1040
     * @param featureType
1041
     *            The FeatureType to which the indexed attribute belongs.
1042
     *
1043
     * @param attributeName
1044
     *            The name of the attributed to be indexed
1045
     *
1046
     * @param indexName
1047
     *            The index name
1048
     *
1049
     * @return the resulting {@link FeatureIndex}
1050
     *
1051
     *
1052
     * @throws FeatureIndexException
1053
     *             if there is an error creating the index
1054
     */
1055
    public FeatureIndex createIndex(FeatureType featureType,
1056
        String attributeName, String indexName) throws DataException;
1057

    
1058
    /**
1059
     * Creates an index which will be applied to the features of the given type,
1060
     * by using the data of the given attribute.
1061
     *
1062
     * @param indexTypeName
1063
     *            the type of the index to be created. That name is
1064
     *            related to one of the registered index providers
1065
     * @param featureType
1066
     *            The FeatureType to which the indexed attribute belongs.
1067
     *
1068
     * @param attributeName
1069
     *            The name of the attributed to be indexed
1070
     *
1071
     * @param indexName
1072
     *            The index name
1073
     *
1074
     * @return the resulting {@link FeatureIndex}
1075
     *
1076
     *
1077
     * @throws FeatureIndexException
1078
     *             if there is an error creating the index
1079
     */
1080
    public FeatureIndex createIndex(String indexTypeName,
1081
        FeatureType featureType, String attributeName, String indexName)
1082
        throws DataException;
1083

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

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

    
1173
    /**
1174
     * Returns a FeatureIndexes structure containing all available indexes in
1175
     * the store.
1176
     *
1177
     * @return
1178
     */
1179
    public FeatureIndexes getIndexes();
1180

    
1181
    /*
1182
     * =============================================================
1183
     *
1184
     * Selection related services
1185
     */
1186

    
1187
    /**
1188
     * Sets the selection to the passed {@link FeatureSet}
1189
     *
1190
     * @param selection
1191
     *            A {@link FeatureSet} with the requested selection
1192
     * @throws org.gvsig.fmap.dal.exception.DataException
1193
     */
1194
    public void setSelection(FeatureSet selection) throws DataException;
1195

    
1196
    /**
1197
     * Creates a {@link FeatureSelection}
1198
     *
1199
     * @return
1200
     *         a {@link FeatureSelection}
1201
     *
1202
     * @throws DataException
1203
     */
1204
    public FeatureSelection createFeatureSelection() throws DataException;
1205
    
1206
    public FeatureSelection createLargeFeatureSelection() throws DataException;
1207
            
1208
    /**
1209
     * Creates a {@link FeatureSelection}
1210
     *
1211
     * @return
1212
     *         a {@link FeatureSelection}
1213
     *
1214
     * @throws DataException
1215
     */
1216
    public FeatureSelection createMemoryFeatureSelection() throws DataException;
1217

    
1218

    
1219
    /**
1220
     * Returns the current {@link FeatureSelection}.
1221
     * Create a empty selection if not exits.
1222
     * 
1223
     * Manage of the selection can be slow on some data sources. 
1224
     * Use with care.
1225
     * In data sources that do not support position access to records, 
1226
     * it may be slow to retrieve items from the selection. In some data 
1227
     * sources it may be necessary to access to this to retrieve each 
1228
     * item in the selection.
1229
     *
1230
     * @return
1231
     *         current {@link FeatureSelection}.
1232
     *
1233
     * @throws DataException
1234
     */
1235
    public FeatureSelection getFeatureSelection() throws DataException;
1236

    
1237
    public FeatureSelection getFeatureSelectionQuietly();
1238

    
1239
    /*
1240
     * =============================================================
1241
     *
1242
     * Lock related services
1243
     */
1244

    
1245
    /**
1246
     * Indicates whether this store supports locks.
1247
     *
1248
     * @return
1249
     *         true if this store supports locks, false if not.
1250
     */
1251
    public boolean isLocksSupported();
1252

    
1253
    /**
1254
     * Returns the set of locked features
1255
     *
1256
     * @return
1257
     *         set of locked features
1258
     *
1259
     * @throws DataException
1260
     */
1261
    public FeatureLocks getLocks() throws DataException;
1262

    
1263
    /*
1264
     * =============================================================
1265
     * Transforms related services
1266
     * =============================================================
1267
     */
1268

    
1269
    /**
1270
     * Returns this store transforms
1271
     *
1272
     * @return
1273
     *         this store transforms
1274
     */
1275
    public FeatureStoreTransforms getTransforms();
1276

    
1277
    /**
1278
     * Returns a new {@link FeatureQuery} associated to this store.
1279
     *
1280
     * @return
1281
     *         a new {@link FeatureQuery} associated to this store.
1282
     */
1283
    public FeatureQuery createFeatureQuery();
1284

    
1285
    /**
1286
     * Returns featue count of this store.
1287
     *
1288
     * @return
1289
     * @throws DataException
1290
     */
1291
    public long getFeatureCount() throws DataException;
1292

    
1293
//    /**
1294
//     * Creates a vectorial cache that is used to save and retrieve data.
1295
//     *
1296
//     * @param name
1297
//     *            the cache name.
1298
//     * @param parameters
1299
//     *            parameters to create the stores used to save data.
1300
//     * @throws DataException
1301
//     */
1302
//    public void createCache(String name, DynObject parameters)
1303
//        throws DataException;
1304
//
1305
//    /**
1306
//     * @return the vectorial cache
1307
//     */
1308
//    public FeatureCache getCache();
1309

    
1310
    /**
1311
     * Return if the provider knows the real envelope of a layer. If not,
1312
     * the {@link FeatureStoreProvider#getEnvelope()} method doesn't return
1313
     * the full envelope.
1314
     *
1315
     * @return true if it knows the real envelope.
1316
     */
1317
    public boolean isKnownEnvelope();
1318

    
1319
    /**
1320
     * Return if the maximum number of features provided by the
1321
     * provider are limited.
1322
     *
1323
     * @return true if there is a limit of features.
1324
     */
1325
    public boolean hasRetrievedFeaturesLimit();
1326

    
1327
    /**
1328
     * If the {@link FeatureStoreProvider#hasRetrievedFeaturesLimit()} returns
1329
     * true,
1330
     * it returns the limit of features retrieved from the provider.
1331
     *
1332
     * @return
1333
     *         The limit of the retrieved features.
1334
     */
1335
    public int getRetrievedFeaturesLimit();
1336

    
1337
    /**
1338
     * Return the associated feature to the dynobject.
1339
     * If the dynobject isn't associated to a feature of this store, return null.
1340
     *
1341
     * @param dynobject
1342
     * @return
1343
     */
1344
    public Feature getFeature(DynObject dynobject);
1345

    
1346

    
1347
    public ExpressionBuilder createExpressionBuilder();
1348

    
1349
    /**
1350
     * 
1351
     * @return 
1352
     * @deprecated use createExpressionBuilder
1353
     */
1354
    public ExpressionBuilder createExpression();
1355

    
1356
    public void createCache(String name, DynObject parameters)
1357
        throws DataException;
1358

    
1359
    @Override
1360
    public FeatureCache getCache();
1361

    
1362
    public boolean isBroken();
1363

    
1364
    public Throwable getBreakingsCause();
1365

    
1366
    /**
1367
     * Indicates if the storage is temporary.
1368
     * There is no guarantee that a temporary store can be recovered from 
1369
     * its parameters. In general these will not be persistent.
1370
     * 
1371
     * @return true if the store is temporary, otherwise false.
1372
     */
1373
    public boolean isTemporary();
1374
    
1375
    public void setTemporary(Boolean temporary);
1376

    
1377
    /**
1378
     * @param index
1379
     * @return
1380
     */
1381
    public SpatialIndex wrapSpatialIndex(SpatialIndex index);
1382
    
1383
    public FeatureReference getFeatureReference(String code);
1384

    
1385
    /**
1386
     * Devuelbe el numero de operaciones pendientes de guardar en una sesion
1387
     * de edicion. Es un valor orientativo.
1388
     * Las operaciones pendientes son la suma de operaciones de borrado, insercion
1389
     * o modificacion de las features en una sesion de edicion.
1390
     * 
1391
     * Retorna 0 si no esta en edicion.
1392
     * 
1393
     * @return numero de operaciones pendientes. 
1394
     */
1395
    public long getPendingChangesCount();
1396
    
1397
    public Feature getSampleFeature();
1398
    
1399
    /**
1400
     * Return true when the default feature type of the store 
1401
     * support references.
1402
     * 
1403
     * @return true when support references.
1404
     */
1405
    public boolean supportReferences();
1406
    
1407
    public Feature getOriginalFeature(FeatureReference id);
1408

    
1409
    public Feature getOriginalFeature(Feature feature);
1410
    
1411
    public boolean isFeatureModified(FeatureReference id);
1412

    
1413
    public boolean isFeatureModified(Feature feature);
1414
    
1415
    public String getEditingSession();
1416

    
1417
    public List<FeatureReference> getEditedFeatures();
1418
    
1419
    public List<FeatureReference> getEditedFeaturesNotValidated();
1420

    
1421
    public boolean isFeatureSelectionEmpty();
1422
    
1423
    public boolean isFeatureSelectionAvailable();
1424
    
1425
    public Iterator<Feature> getFeaturesIterator(Iterator<FeatureReference> references);
1426
    
1427
    public Iterable<Feature> getFeaturesIterable(Iterator<FeatureReference> references);
1428
    
1429
    public boolean canBeEdited();
1430

    
1431
    
1432
}