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 40559 jjdelcerro
/**
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 40435 jjdelcerro
package org.gvsig.fmap.dal.feature;
25
26
import java.util.Iterator;
27
import java.util.List;
28 44655 jjdelcerro
import javax.json.JsonObject;
29 46855 jjdelcerro
import org.apache.commons.lang3.StringUtils;
30 40435 jjdelcerro
import org.cresques.cts.IProjection;
31 44023 jjdelcerro
import org.gvsig.expressionevaluator.Expression;
32 44042 jjdelcerro
import org.gvsig.expressionevaluator.ExpressionBuilder;
33 40435 jjdelcerro
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 43371 fdiaz
import org.gvsig.fmap.geom.SpatialIndex;
42 40435 jjdelcerro
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 45425 jjdelcerro
import org.gvsig.tools.util.GetItemWithSizeIsEmptyAndIterator64;
49
import org.gvsig.tools.util.PropertiesSupport;
50 45195 omartinez
import org.gvsig.tools.util.Size64;
51 44346 jjdelcerro
import org.gvsig.tools.util.UnmodifiableBasicList64;
52 40435 jjdelcerro
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 41818 fdiaz
 *
60 40435 jjdelcerro
 * <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 41818 fdiaz
 *
79 40435 jjdelcerro
 */
80 45425 jjdelcerro
public interface FeatureStore extends
81
        DataStore, UndoRedoStack, Cloneable, Iterable<Feature>,
82
        PropertiesSupport,
83
        Size64 {
84 40435 jjdelcerro
85 46855 jjdelcerro
    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 40435 jjdelcerro
    public static final String METADATA_DEFINITION_NAME = "FeatureStore";
105
106 45738 fdiaz
    final static int MODE_UNKNOWN = -1;
107 45739 jjdelcerro
108 40435 jjdelcerro
    /** 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 45425 jjdelcerro
117
    final static int MODE_PASS_THROUGH = 3;
118 40435 jjdelcerro
119
    /*
120
     * =============================================================
121 41818 fdiaz
     *
122 40435 jjdelcerro
     * information related services
123
     */
124
125
    /**
126
     * Indicates whether this store allows writing.
127 41818 fdiaz
     *
128 40435 jjdelcerro
     * @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 41818 fdiaz
     *
136 40435 jjdelcerro
     * @return
137
     *         this store's default {@link FeatureType}.
138 41818 fdiaz
     *
139 40435 jjdelcerro
     * @throws DataException
140
     */
141
    public FeatureType getDefaultFeatureType() throws DataException;
142 44884 jjdelcerro
143
    public FeatureType getDefaultFeatureTypeQuietly();
144 40435 jjdelcerro
145
    /**
146
     * Returns this store's featureType {@link FeatureType} matches with
147
     * featureTypeId.
148 41818 fdiaz
     *
149 40435 jjdelcerro
     * @param featureTypeId
150 41818 fdiaz
     *
151 40435 jjdelcerro
     * @return this store's default {@link FeatureType}.
152 41818 fdiaz
     *
153 40435 jjdelcerro
     * @throws DataException
154
     */
155
    public FeatureType getFeatureType(String featureTypeId)
156
        throws DataException;
157
158
    /**
159
     * Returns this store's {@link FeatureType}(s).
160 41818 fdiaz
     *
161 40435 jjdelcerro
     * @return a list with this store's {@link FeatureType}(s).
162 41818 fdiaz
     *
163 40435 jjdelcerro
     * @throws DataException
164
     */
165
    public List getFeatureTypes() throws DataException;
166
167
    /**
168
     * Returns this store's parameters.
169 41818 fdiaz
     *
170 40435 jjdelcerro
     * @return
171
     *         {@link DataStoreParameters} containing this store's parameters
172
     */
173
    public DataStoreParameters getParameters();
174
175
    /**
176 44884 jjdelcerro
     * @param gvSIGgeometryType
177
     * @return
178
     * @throws DataException
179 40435 jjdelcerro
     * @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 41818 fdiaz
     *
186 40435 jjdelcerro
     * @return this store's total envelope (extent) or <code>null</code> if
187
     *         store not have geometry information
188 44884 jjdelcerro
     * @throws org.gvsig.fmap.dal.exception.DataException
189 40435 jjdelcerro
     */
190
    public Envelope getEnvelope() throws DataException;
191
192
    /**
193 41818 fdiaz
     *
194 40435 jjdelcerro
     * @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 41818 fdiaz
     *
203 40435 jjdelcerro
     * @param explorer
204
     *            {@link DataServerExplorer} target
205 44884 jjdelcerro
     * @param provider
206 40435 jjdelcerro
     * @param params
207
     *            New parameters of this store that will be used on the target
208
     *            explorer
209 41818 fdiaz
     *
210 40435 jjdelcerro
     * @throws DataException
211 41818 fdiaz
     *
212 40435 jjdelcerro
     * @Deprecated this method is unstable
213
     */
214
    public void export(DataServerExplorer explorer, String provider,
215 45482 fdiaz
        NewFeatureStoreParameters params, String name) throws DataException;
216 40435 jjdelcerro
217 44318 jjdelcerro
    public void copyTo(FeatureStore target);
218
219 40435 jjdelcerro
    /*
220
     * =============================================================
221 41818 fdiaz
     *
222 40435 jjdelcerro
     * Query related services
223
     */
224 44346 jjdelcerro
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 45425 jjdelcerro
    public FeatureQuery createFeatureQuery(String filter);
247
    public FeatureQuery createFeatureQuery(Expression filter);
248 40435 jjdelcerro
249 44346 jjdelcerro
    /**
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 45308 fdiaz
    /**
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 40435 jjdelcerro
    /**
318
     * Returns all available features in the store.
319 41818 fdiaz
     *
320 44346 jjdelcerro
     * 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 40435 jjdelcerro
     */
326
    FeatureSet getFeatureSet() throws DataException;
327
328 44346 jjdelcerro
    /**
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 43533 jjdelcerro
    FeatureSet getFeatureSet(String filter) throws DataException;
339
340 44346 jjdelcerro
    /**
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 43533 jjdelcerro
    FeatureSet getFeatureSet(String filter, String sortBy) throws DataException;
354
355 44346 jjdelcerro
    /**
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 43533 jjdelcerro
    FeatureSet getFeatureSet(String filter, String sortBy, boolean asc) throws DataException;
368
369 44346 jjdelcerro
    /**
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 44023 jjdelcerro
    FeatureSet getFeatureSet(Expression filter) throws DataException;
380
381 44346 jjdelcerro
    /**
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 44023 jjdelcerro
    FeatureSet getFeatureSet(Expression filter, String sortBy) throws DataException;
395
396 44346 jjdelcerro
    /**
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 44023 jjdelcerro
    FeatureSet getFeatureSet(Expression filter, String sortBy, boolean asc) throws DataException;
409 44346 jjdelcerro
410 40435 jjdelcerro
    /**
411
     * Returns a subset of features taking into account the properties and
412 44346 jjdelcerro
     * restrictions of the {@link FeatureQuery}.
413
     *
414
     * If {@link FeatureQuery} is null, return al features in the store.
415
     *
416 40435 jjdelcerro
     * <p>
417
     * <em>
418 41818 fdiaz
     * <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 40435 jjdelcerro
     * get the features.
425
     * </em>
426
     * </p>
427 41818 fdiaz
     *
428 44346 jjdelcerro
     * @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 40435 jjdelcerro
     */
433
    FeatureSet getFeatureSet(FeatureQuery featureQuery) throws DataException;
434
435
    /**
436
     * Loads a subset of features taking into account the properties and
437 44346 jjdelcerro
     * restrictions of the FeatureQuery.
438
     * When feature loading is finished call the Observer passing the
439
     * {@link FeatureSet}  loaded.
440 41818 fdiaz
     *
441 44346 jjdelcerro
     * @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 40435 jjdelcerro
     */
445 44346 jjdelcerro
    void getFeatureSet(FeatureQuery featureQuery, Observer observer) throws DataException;
446 40435 jjdelcerro
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 41818 fdiaz
     *
451 44346 jjdelcerro
     * @param observer to be notified of each loaded Feature
452
     * @throws DataException if there is any error while loading the features
453 40435 jjdelcerro
     */
454
    void getFeatureSet(Observer observer) throws DataException;
455
456
    /**
457 42925 jjdelcerro
     * Return a paginated list of Features filtered by the query.
458 44346 jjdelcerro
     *
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 43371 fdiaz
     *
471 44346 jjdelcerro
     * @param query to filter and sort the returned feature list
472 42925 jjdelcerro
     * @param pageSize the page size of the list
473 44346 jjdelcerro
     * @return the {@link List}/{@link UnmodifiableBasicList64} of features
474 42925 jjdelcerro
     */
475
    public List<Feature> getFeatures(FeatureQuery query, int pageSize);
476 43371 fdiaz
477 44346 jjdelcerro
    /**
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 43550 jjdelcerro
    public List<Feature> getFeatures(FeatureQuery query);
488
489 44346 jjdelcerro
    /**
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 43020 jjdelcerro
    public List<Feature> getFeatures();
499 43371 fdiaz
500 44346 jjdelcerro
    /**
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 43628 jjdelcerro
    public List<Feature> getFeatures(String filter);
510
511 44346 jjdelcerro
    /**
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 43628 jjdelcerro
    public List<Feature> getFeatures(String filter, String sortBy);
523
524 44346 jjdelcerro
    /**
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 43628 jjdelcerro
    public List<Feature> getFeatures(String filter, String sortBy, boolean asc);
537
538 44346 jjdelcerro
    /**
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 44023 jjdelcerro
    public List<Feature> getFeatures(Expression filter);
549
550 44346 jjdelcerro
    /**
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 44023 jjdelcerro
    public List<Feature> getFeatures(Expression filter, String sortBy);
562
563 44346 jjdelcerro
    /**
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 44023 jjdelcerro
    public List<Feature> getFeatures(Expression filter, String sortBy, boolean asc);
576
577 45425 jjdelcerro
    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 44346 jjdelcerro
    /**
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 44100 jjdelcerro
    public Feature first() throws DataException;
592
593 44346 jjdelcerro
    /**
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 43628 jjdelcerro
    public Feature findFirst(String filter) throws DataException;
604
605 44346 jjdelcerro
    /**
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 43628 jjdelcerro
    public Feature findFirst(String filter, String sortBy) throws DataException;
617
618 44346 jjdelcerro
    /**
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 43628 jjdelcerro
    public Feature findFirst(String filter, String sortBy, boolean asc) throws DataException;
631
632 45308 fdiaz
633 44346 jjdelcerro
    /**
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 45308 fdiaz
     * @param sortBy Expression
640
     * @param asc use order ascending, true, or descending, false.
641 44346 jjdelcerro
     * @return the first {@link Feature} or null if the filter don't return any feature.
642
     * @throws DataException
643 45308 fdiaz
     * @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 44346 jjdelcerro
     * @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(Expession,String,boolean)}
656
     */
657 44023 jjdelcerro
    public Feature findFirst(Expression filter) throws DataException;
658
659 44346 jjdelcerro
    /**
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 44023 jjdelcerro
    public Feature findFirst(Expression filter, String sortBy) throws DataException;
671
672 44346 jjdelcerro
    /**
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 44023 jjdelcerro
    public Feature findFirst(Expression filter, String sortBy, boolean asc) throws DataException;
685
686 44346 jjdelcerro
    /**
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 45308 fdiaz
     * @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 44346 jjdelcerro
     * @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 44262 jjdelcerro
    public Feature findFirst(FeatureQuery query) throws DataException;
711 44346 jjdelcerro
712 42925 jjdelcerro
    /**
713 40435 jjdelcerro
     * Returns the feature given its reference.
714 41818 fdiaz
     *
715 44346 jjdelcerro
     * @param reference a unique FeatureReference
716
     * @return
717
     * @returnThe Feature
718 40435 jjdelcerro
     * @throws DataException
719 41818 fdiaz
     *
720 40435 jjdelcerro
     */
721 44346 jjdelcerro
    public Feature getFeatureByReference(FeatureReference reference) throws DataException;
722 40435 jjdelcerro
723
    /**
724
     * Returns the feature given its reference and feature type.
725 41818 fdiaz
     *
726 40435 jjdelcerro
     * @param reference
727
     *            a unique FeatureReference
728 41818 fdiaz
     *
729 40435 jjdelcerro
     * @param featureType
730
     *            FeatureType to which the requested Feature belongs
731 41818 fdiaz
     *
732 40435 jjdelcerro
     * @return
733
     *         The Feature
734 41818 fdiaz
     *
735 40435 jjdelcerro
     * @throws DataException
736 41818 fdiaz
     *
737 40435 jjdelcerro
     */
738
    public Feature getFeatureByReference(FeatureReference reference,
739
        FeatureType featureType) throws DataException;
740
741
    /*
742
     * =============================================================
743 41818 fdiaz
     *
744 40435 jjdelcerro
     * Editing related services
745
     */
746
747
    /**
748
     * Enters editing state.
749 44884 jjdelcerro
     * @throws org.gvsig.fmap.dal.exception.DataException
750 40435 jjdelcerro
     */
751
    public void edit() throws DataException;
752
753
    /**
754
     * Enters editing state specifying the editing mode.
755 41818 fdiaz
     *
756 40435 jjdelcerro
     * @param mode
757 41818 fdiaz
     *
758 40435 jjdelcerro
     * @throws DataException
759
     */
760
    public void edit(int mode) throws DataException;
761 45482 fdiaz
762
    public int getMode();
763 40435 jjdelcerro
764
    /**
765
     * Cancels all editing since the last edit().
766 41818 fdiaz
     *
767 40435 jjdelcerro
     * @throws DataException
768
     */
769
    public void cancelEditing() throws DataException;
770
771 45425 jjdelcerro
    public boolean cancelEditingQuietly();
772
773 45441 jjdelcerro
    public static boolean cancelEditingQuietly(FeatureStore store) {
774
        if( store==null ) {
775
            return true;
776
        }
777
        return store.cancelEditingQuietly();
778
    }
779
780 40435 jjdelcerro
    /**
781
     * Exits editing state.
782 41818 fdiaz
     *
783 40435 jjdelcerro
     * @throws DataException
784
     */
785
    public void finishEditing() throws DataException;
786
787 45425 jjdelcerro
    public boolean finishEditingQuietly();
788
789 45441 jjdelcerro
    public static boolean finishEditingQuietly(FeatureStore store) {
790
        if( store==null ) {
791
            return true;
792
        }
793
        return store.finishEditingQuietly();
794
    }
795
796 40435 jjdelcerro
    /**
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 41818 fdiaz
     *
812 40435 jjdelcerro
     * @return true if can call commitChanges
813 41818 fdiaz
     * @throws DataException
814 40435 jjdelcerro
     */
815
    public boolean canCommitChanges() throws DataException;
816
817 41818 fdiaz
818 40435 jjdelcerro
    /**
819
     * Indicates whether this store is in editing state.
820 41818 fdiaz
     *
821 40435 jjdelcerro
     * @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 41818 fdiaz
     *
830 40435 jjdelcerro
     * @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 41818 fdiaz
     *
838 40435 jjdelcerro
     * Any {@link FeatureSet} from this store that are used will be invalidated.
839 41818 fdiaz
     *
840 40435 jjdelcerro
     * @param featureType
841
     *            an {@link EditableFeatureType} with the changes.
842 41818 fdiaz
     *
843 40435 jjdelcerro
     * @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 41818 fdiaz
     *
851 40435 jjdelcerro
     * 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 41818 fdiaz
     *
855 40435 jjdelcerro
     * @param feature
856
     *            the feature to be updated
857 41818 fdiaz
     *
858 40435 jjdelcerro
     * @throws DataException
859
     */
860
    public void update(EditableFeature feature) throws DataException;
861
862 45776 fdiaz
    /**
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 45425 jjdelcerro
    public void update(Object... parameters) throws DataException;
874
875 40435 jjdelcerro
    /**
876
     * Deletes a {@link Feature} from the store.<br>
877 41818 fdiaz
     *
878 40435 jjdelcerro
     * 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 41818 fdiaz
     *
882 40435 jjdelcerro
     * @param feature
883
     *            The feature to be deleted.
884 41818 fdiaz
     *
885 40435 jjdelcerro
     * @throws DataException
886
     */
887
    public void delete(Feature feature) throws DataException;
888 45425 jjdelcerro
889
    public void delete(String filter);
890
891
    public void delete(Expression filter);
892 40435 jjdelcerro
893
    /**
894
     * Inserts a {@link Feature} in the store.<br>
895 41818 fdiaz
     *
896 40435 jjdelcerro
     * 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 41818 fdiaz
     *
900 40435 jjdelcerro
     * @param feature
901
     *            The feature to be inserted
902 41818 fdiaz
     *
903 40435 jjdelcerro
     * @throws DataException
904
     */
905
    public void insert(EditableFeature feature) throws DataException;
906
907
    /**
908 45071 jjdelcerro
     * 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 40435 jjdelcerro
     * Creates a new feature using the default feature type and returns it as an
923
     * {@link EditableFeature}
924 41818 fdiaz
     *
925 40435 jjdelcerro
     * @return a new feature in editable state
926 41818 fdiaz
     *
927 40435 jjdelcerro
     * @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 41818 fdiaz
     *
935 40435 jjdelcerro
     * @param type
936
     *            the new feature's feature type
937 41818 fdiaz
     *
938 40435 jjdelcerro
     * @param defaultValues
939
     *            a feature whose values are used as default values for the new
940
     *            feature.
941 41818 fdiaz
     *
942 40435 jjdelcerro
     * @return the new feature.
943 41818 fdiaz
     *
944 40435 jjdelcerro
     * @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 41818 fdiaz
     *
954 40435 jjdelcerro
     * @param type
955
     *            the new feature's feature type
956 41818 fdiaz
     *
957 40435 jjdelcerro
     * @param defaultValues
958
     *            if true the new feature is initialized with each attribute's
959
     *            default value.
960 41818 fdiaz
     *
961 40435 jjdelcerro
     * @return
962
     *         the new feature
963 41818 fdiaz
     *
964 40435 jjdelcerro
     * @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 41818 fdiaz
     *
974 40435 jjdelcerro
     * @param defaultValues
975
     *            if true the new feature is initialized with each attribute's
976
     *            default value.
977 41818 fdiaz
     *
978 40435 jjdelcerro
     * @return
979
     *         the new feature
980 41818 fdiaz
     *
981 40435 jjdelcerro
     * @throws DataException
982
     */
983
    public EditableFeature createNewFeature(boolean defaultValues)
984
        throws DataException;
985
986
    /**
987 43371 fdiaz
     * Creates a new feature of default {@link FeatureType}.
988
     * The new feature should be initialized with the values of the feature
989 42293 jjdelcerro
     * passed as parameter.
990
     * Values are inicialiced by name from the feature specified. Error in
991
     * value assignement are ignoreds.
992 43371 fdiaz
     *
993 42293 jjdelcerro
     * @param defaultValues the values to initialize the new feature.
994
     * @return the new feature
995 43371 fdiaz
     * @throws DataException
996 42293 jjdelcerro
     */
997
    public EditableFeature createNewFeature(Feature defaultValues)
998
        throws DataException;
999
1000 44655 jjdelcerro
    public EditableFeature createNewFeature(JsonObject defaultValues)
1001
        throws DataException;
1002
1003 42293 jjdelcerro
    /**
1004 40435 jjdelcerro
     * Indicates whether this store supports append mode.
1005 41818 fdiaz
     *
1006 40435 jjdelcerro
     * @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 41818 fdiaz
     *
1015 40435 jjdelcerro
     * @param description
1016
     *            Description of the editing group.
1017 41818 fdiaz
     *
1018 40435 jjdelcerro
     * @throws NeedEditingModeException
1019
     */
1020
    public void beginEditingGroup(String description)
1021
        throws NeedEditingModeException;
1022
1023
    /**
1024
     * Finishes an editing group.
1025 41818 fdiaz
     *
1026 40435 jjdelcerro
     * @throws NeedEditingModeException
1027
     */
1028
    public void endEditingGroup() throws NeedEditingModeException;
1029
1030
    /*
1031
     * =============================================================
1032 41818 fdiaz
     *
1033 40435 jjdelcerro
     * 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 41818 fdiaz
     *
1040 40435 jjdelcerro
     * @param featureType
1041
     *            The FeatureType to which the indexed attribute belongs.
1042 41818 fdiaz
     *
1043 40435 jjdelcerro
     * @param attributeName
1044
     *            The name of the attributed to be indexed
1045 41818 fdiaz
     *
1046 40435 jjdelcerro
     * @param indexName
1047
     *            The index name
1048 41818 fdiaz
     *
1049 40435 jjdelcerro
     * @return the resulting {@link FeatureIndex}
1050 41818 fdiaz
     *
1051
     *
1052 40435 jjdelcerro
     * @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 41818 fdiaz
     *
1062 40435 jjdelcerro
     * @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 41818 fdiaz
     *
1068 40435 jjdelcerro
     * @param attributeName
1069
     *            The name of the attributed to be indexed
1070 41818 fdiaz
     *
1071 40435 jjdelcerro
     * @param indexName
1072
     *            The index name
1073 41818 fdiaz
     *
1074 40435 jjdelcerro
     * @return the resulting {@link FeatureIndex}
1075 41818 fdiaz
     *
1076
     *
1077 40435 jjdelcerro
     * @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 41818 fdiaz
     *
1093 40435 jjdelcerro
     * @param featureType
1094
     *            The FeatureType to which the indexed attribute belongs.
1095 41818 fdiaz
     *
1096 40435 jjdelcerro
     * @param attributeName
1097
     *            The name of the attributed to be indexed
1098 41818 fdiaz
     *
1099 40435 jjdelcerro
     * @param indexName
1100
     *            The index name
1101 41818 fdiaz
     *
1102 40435 jjdelcerro
     * @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 41818 fdiaz
     *
1113 40435 jjdelcerro
     * @return the resulting {@link FeatureIndex}
1114 41818 fdiaz
     *
1115 40435 jjdelcerro
     * @see FeatureStoreNotification#INDEX_FILLING_STARTED
1116
     * @see FeatureStoreNotification#INDEX_FILLING_SUCCESS
1117
     * @see FeatureStoreNotification#INDEX_FILLING_CANCELLED
1118
     * @see FeatureStoreNotification#INDEX_FILLING_ERROR
1119 41818 fdiaz
     *
1120 40435 jjdelcerro
     * @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 41818 fdiaz
     *
1136 40435 jjdelcerro
     * @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 41818 fdiaz
     *
1142 40435 jjdelcerro
     * @param attributeName
1143
     *            The name of the attributed to be indexed
1144 41818 fdiaz
     *
1145 40435 jjdelcerro
     * @param indexName
1146
     *            The index name
1147 41818 fdiaz
     *
1148 40435 jjdelcerro
     * @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 41818 fdiaz
     *
1159 40435 jjdelcerro
     * @return the resulting {@link FeatureIndex}
1160 41818 fdiaz
     *
1161 40435 jjdelcerro
     * @see FeatureStoreNotification#INDEX_FILLING_STARTED
1162
     * @see FeatureStoreNotification#INDEX_FILLING_SUCCESS
1163
     * @see FeatureStoreNotification#INDEX_FILLING_CANCELLED
1164
     * @see FeatureStoreNotification#INDEX_FILLING_ERROR
1165 41818 fdiaz
     *
1166 40435 jjdelcerro
     * @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 41818 fdiaz
     *
1177 40435 jjdelcerro
     * @return
1178
     */
1179
    public FeatureIndexes getIndexes();
1180
1181
    /*
1182
     * =============================================================
1183 41818 fdiaz
     *
1184 40435 jjdelcerro
     * Selection related services
1185
     */
1186
1187
    /**
1188
     * Sets the selection to the passed {@link FeatureSet}
1189 41818 fdiaz
     *
1190 40435 jjdelcerro
     * @param selection
1191
     *            A {@link FeatureSet} with the requested selection
1192 44884 jjdelcerro
     * @throws org.gvsig.fmap.dal.exception.DataException
1193 40435 jjdelcerro
     */
1194
    public void setSelection(FeatureSet selection) throws DataException;
1195
1196
    /**
1197
     * Creates a {@link FeatureSelection}
1198 41818 fdiaz
     *
1199 40435 jjdelcerro
     * @return
1200
     *         a {@link FeatureSelection}
1201 41818 fdiaz
     *
1202 40435 jjdelcerro
     * @throws DataException
1203
     */
1204
    public FeatureSelection createFeatureSelection() throws DataException;
1205 45426 fdiaz
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 40435 jjdelcerro
1218 45426 fdiaz
1219 40435 jjdelcerro
    /**
1220
     * Returns the current {@link FeatureSelection}.
1221
     * Create a empty selection if not exits.
1222 43358 jjdelcerro
     *
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 41818 fdiaz
     *
1230 40435 jjdelcerro
     * @return
1231
     *         current {@link FeatureSelection}.
1232 41818 fdiaz
     *
1233 40435 jjdelcerro
     * @throws DataException
1234
     */
1235
    public FeatureSelection getFeatureSelection() throws DataException;
1236
1237 46672 fdiaz
    public FeatureSelection getFeatureSelectionQuietly();
1238
1239 40435 jjdelcerro
    /*
1240
     * =============================================================
1241 41818 fdiaz
     *
1242 40435 jjdelcerro
     * Lock related services
1243
     */
1244
1245
    /**
1246
     * Indicates whether this store supports locks.
1247 41818 fdiaz
     *
1248 40435 jjdelcerro
     * @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 41818 fdiaz
     *
1256 40435 jjdelcerro
     * @return
1257
     *         set of locked features
1258 41818 fdiaz
     *
1259 40435 jjdelcerro
     * @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 41818 fdiaz
     *
1272 40435 jjdelcerro
     * @return
1273
     *         this store transforms
1274
     */
1275
    public FeatureStoreTransforms getTransforms();
1276
1277
    /**
1278
     * Returns a new {@link FeatureQuery} associated to this store.
1279 41818 fdiaz
     *
1280 40435 jjdelcerro
     * @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 41818 fdiaz
     *
1288 40435 jjdelcerro
     * @return
1289
     * @throws DataException
1290
     */
1291
    public long getFeatureCount() throws DataException;
1292
1293 43020 jjdelcerro
//    /**
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 40435 jjdelcerro
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 41818 fdiaz
     *
1315 44884 jjdelcerro
     * @return true if it knows the real envelope.
1316 40435 jjdelcerro
     */
1317
    public boolean isKnownEnvelope();
1318
1319
    /**
1320
     * Return if the maximum number of features provided by the
1321
     * provider are limited.
1322 41818 fdiaz
     *
1323 44884 jjdelcerro
     * @return true if there is a limit of features.
1324 40435 jjdelcerro
     */
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 41818 fdiaz
     *
1332 40435 jjdelcerro
     * @return
1333
     *         The limit of the retrieved features.
1334
     */
1335
    public int getRetrievedFeaturesLimit();
1336 41818 fdiaz
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 43371 fdiaz
1346
1347 43521 jjdelcerro
    public ExpressionBuilder createExpressionBuilder();
1348 43371 fdiaz
1349 43521 jjdelcerro
    /**
1350
     *
1351
     * @return
1352
     * @deprecated use createExpressionBuilder
1353
     */
1354
    public ExpressionBuilder createExpression();
1355
1356 43056 jjdelcerro
    public void createCache(String name, DynObject parameters)
1357
        throws DataException;
1358
1359 44443 jjdelcerro
    @Override
1360 43371 fdiaz
    public FeatureCache getCache();
1361
1362 43215 jjdelcerro
    public boolean isBroken();
1363 43371 fdiaz
1364 44443 jjdelcerro
    public Throwable getBreakingsCause();
1365 43371 fdiaz
1366
    /**
1367 44443 jjdelcerro
     * 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 46301 fdiaz
    public void setTemporary(Boolean temporary);
1376
1377 44443 jjdelcerro
    /**
1378 43371 fdiaz
     * @param index
1379
     * @return
1380
     */
1381 44111 jjdelcerro
    public SpatialIndex wrapSpatialIndex(SpatialIndex index);
1382 43824 jjdelcerro
1383
    public FeatureReference getFeatureReference(String code);
1384 44111 jjdelcerro
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 44253 jjdelcerro
1397 44283 jjdelcerro
    public Feature getSampleFeature();
1398 44435 jjdelcerro
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 45521 fdiaz
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 45738 fdiaz
1415
    public String getEditingSession();
1416 45788 jjdelcerro
1417
    public List<FeatureReference> getEditedFeatures();
1418
1419
    public List<FeatureReference> getEditedFeaturesNotValidated();
1420 46277 jjdelcerro
1421
    public boolean isFeatureSelectionEmpty();
1422 45788 jjdelcerro
1423 46277 jjdelcerro
    public boolean isFeatureSelectionAvailable();
1424 46309 jjdelcerro
1425
    public Iterator<Feature> getFeaturesIterator(Iterator<FeatureReference> references);
1426
1427
    public Iterable<Feature> getFeaturesIterable(Iterator<FeatureReference> references);
1428
1429 46875 fdiaz
    public boolean canBeEdited();
1430
1431
1432 40435 jjdelcerro
}