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

History | View | Annotate | Download (50.4 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
    final static int SUBMODE_NONE = 0;
120
    
121
    /** En este modo hace un merge contra la base de datos, si existe lo actualizada y si no lo inserta **/
122
    final static int SUBMODE_MERGE = 2; 
123

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

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

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

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

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

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

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

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

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

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

    
223
    public void copyTo(FeatureStore target);
224

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
583
    public GetItemWithSizeIsEmptyAndIterator64<Feature> getFeatures64();
584

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
781
    public boolean cancelEditingQuietly();
782

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

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

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

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

    
827

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1228

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

    
1247
    public FeatureSelection getFeatureSelectionQuietly();
1248

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

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

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

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

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

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

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

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

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

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

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

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

    
1356

    
1357
    public ExpressionBuilder createExpressionBuilder();
1358

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

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

    
1369
    @Override
1370
    public FeatureCache getCache();
1371

    
1372
    public boolean isBroken();
1373

    
1374
    public Throwable getBreakingsCause();
1375

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

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

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

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

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

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

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

    
1441
    public String getLabel();
1442

    
1443
}