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

History | View | Annotate | Download (50.8 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 40435 jjdelcerro
import org.cresques.cts.IProjection;
30 44023 jjdelcerro
import org.gvsig.expressionevaluator.Expression;
31 44042 jjdelcerro
import org.gvsig.expressionevaluator.ExpressionBuilder;
32 40435 jjdelcerro
import org.gvsig.fmap.dal.DataServerExplorer;
33
import org.gvsig.fmap.dal.DataStore;
34
import org.gvsig.fmap.dal.DataStoreParameters;
35
import org.gvsig.fmap.dal.exception.DataException;
36
import org.gvsig.fmap.dal.exception.ReadException;
37
import org.gvsig.fmap.dal.feature.exception.FeatureIndexException;
38
import org.gvsig.fmap.dal.feature.exception.NeedEditingModeException;
39
import org.gvsig.fmap.geom.Geometry;
40 43371 fdiaz
import org.gvsig.fmap.geom.SpatialIndex;
41 40435 jjdelcerro
import org.gvsig.fmap.geom.primitive.Envelope;
42
import org.gvsig.tools.dispose.DisposableIterator;
43
import org.gvsig.tools.dynobject.DynObject;
44
import org.gvsig.tools.lang.Cloneable;
45
import org.gvsig.tools.observer.Observer;
46
import org.gvsig.tools.undo.UndoRedoStack;
47 45425 jjdelcerro
import org.gvsig.tools.util.GetItemWithSizeIsEmptyAndIterator64;
48
import org.gvsig.tools.util.PropertiesSupport;
49 45195 omartinez
import org.gvsig.tools.util.Size64;
50 44346 jjdelcerro
import org.gvsig.tools.util.UnmodifiableBasicList64;
51 40435 jjdelcerro
52
/**
53
 * <p>
54
 * A FeatureStore is a type of store whose data consists on sets of
55
 * {@link Feature}(s). {@link Feature}(s) from the same FeatureStore can be of
56
 * different {@link FeatureType}(s) (as in GML format for instance).
57
 * </p>
58 41818 fdiaz
 *
59 40435 jjdelcerro
 * <p>
60
 * FeatureStore allows:
61
 * </p>
62
 * <ul>
63
 * <li>Obtaining the default {@link FeatureType}. A FeatureStore always has one
64
 * and only one default FeatureType.
65
 * <li>Obtaining the list of {@link FeatureType}(s) defined in the FeatureStore.
66
 * <li>Obtaining, filtering and sorting subsets of data ({@link FeatureSet})
67
 * through {@link FeatureQuery}, as well as background loading.
68
 * <li>Obtaining the total {@link Envelope} (AKA bounding box or extent) of the
69
 * store.
70
 * <li>Support for editing {@link FeatureType}(s).
71
 * <li>Obtaining information about contained {@link Geometry} types.
72
 * <li>Exporting to another store.
73
 * <li>Indexing.
74
 * <li>Selection.
75
 * <li>Locks management.
76
 * </ul>
77 41818 fdiaz
 *
78 40435 jjdelcerro
 */
79 45425 jjdelcerro
public interface FeatureStore extends
80
        DataStore, UndoRedoStack, Cloneable, Iterable<Feature>,
81
        PropertiesSupport,
82
        Size64 {
83 40435 jjdelcerro
84
    public static final String METADATA_DEFINITION_NAME = "FeatureStore";
85
86 45738 fdiaz
    final static int MODE_UNKNOWN = -1;
87 45739 jjdelcerro
88 40435 jjdelcerro
    /** Indicates that this store is in query mode */
89
    final static int MODE_QUERY = 0;
90
91
    /** Indicates that this store is in full edit mode */
92
    final static int MODE_FULLEDIT = 1;
93
94
    /** Indicates that this store is in append mode */
95
    final static int MODE_APPEND = 2;
96 45425 jjdelcerro
97
    final static int MODE_PASS_THROUGH = 3;
98 40435 jjdelcerro
99
    /*
100
     * =============================================================
101 41818 fdiaz
     *
102 40435 jjdelcerro
     * information related services
103
     */
104
105
    /**
106
     * Indicates whether this store allows writing.
107 41818 fdiaz
     *
108 40435 jjdelcerro
     * @return
109
     *         true if this store can be written, false if not.
110
     */
111
    public boolean allowWrite();
112
113
    /**
114
     * Returns this store's default {@link FeatureType}.
115 41818 fdiaz
     *
116 40435 jjdelcerro
     * @return
117
     *         this store's default {@link FeatureType}.
118 41818 fdiaz
     *
119 40435 jjdelcerro
     * @throws DataException
120
     */
121
    public FeatureType getDefaultFeatureType() throws DataException;
122 44884 jjdelcerro
123
    public FeatureType getDefaultFeatureTypeQuietly();
124 40435 jjdelcerro
125
    /**
126
     * Returns this store's featureType {@link FeatureType} matches with
127
     * featureTypeId.
128 41818 fdiaz
     *
129 40435 jjdelcerro
     * @param featureTypeId
130 41818 fdiaz
     *
131 40435 jjdelcerro
     * @return this store's default {@link FeatureType}.
132 41818 fdiaz
     *
133 40435 jjdelcerro
     * @throws DataException
134
     */
135
    public FeatureType getFeatureType(String featureTypeId)
136
        throws DataException;
137
138
    /**
139
     * Returns this store's {@link FeatureType}(s).
140 41818 fdiaz
     *
141 40435 jjdelcerro
     * @return a list with this store's {@link FeatureType}(s).
142 41818 fdiaz
     *
143 40435 jjdelcerro
     * @throws DataException
144
     */
145
    public List getFeatureTypes() throws DataException;
146
147
    /**
148
     * Returns this store's parameters.
149 41818 fdiaz
     *
150 40435 jjdelcerro
     * @return
151
     *         {@link DataStoreParameters} containing this store's parameters
152
     */
153
    public DataStoreParameters getParameters();
154
155
    /**
156 44884 jjdelcerro
     * @param gvSIGgeometryType
157
     * @return
158
     * @throws DataException
159 40435 jjdelcerro
     * @deprecated Mirar de cambiarlo a metadatos
160
     */
161
    public boolean canWriteGeometry(int gvSIGgeometryType) throws DataException;
162
163
    /**
164
     * Returns this store's total envelope (extent).
165 41818 fdiaz
     *
166 40435 jjdelcerro
     * @return this store's total envelope (extent) or <code>null</code> if
167
     *         store not have geometry information
168 44884 jjdelcerro
     * @throws org.gvsig.fmap.dal.exception.DataException
169 40435 jjdelcerro
     */
170
    public Envelope getEnvelope() throws DataException;
171
172
    /**
173 41818 fdiaz
     *
174 40435 jjdelcerro
     * @deprecated use getDefaultFeatureType().getDefaultSRS()
175
     * @return
176
     * @throws DataException
177
     */
178
    public IProjection getSRSDefaultGeometry() throws DataException;
179
180
    /**
181
     * Exports this store to another store.
182 41818 fdiaz
     *
183 40435 jjdelcerro
     * @param explorer
184
     *            {@link DataServerExplorer} target
185 44884 jjdelcerro
     * @param provider
186 40435 jjdelcerro
     * @param params
187
     *            New parameters of this store that will be used on the target
188
     *            explorer
189 41818 fdiaz
     *
190 40435 jjdelcerro
     * @throws DataException
191 41818 fdiaz
     *
192 40435 jjdelcerro
     * @Deprecated this method is unstable
193
     */
194
    public void export(DataServerExplorer explorer, String provider,
195 45482 fdiaz
        NewFeatureStoreParameters params, String name) throws DataException;
196 40435 jjdelcerro
197 44318 jjdelcerro
    public void copyTo(FeatureStore target);
198
199 40435 jjdelcerro
    /*
200
     * =============================================================
201 41818 fdiaz
     *
202 40435 jjdelcerro
     * Query related services
203
     */
204 44346 jjdelcerro
205
    /**
206
     * Create a {@link FeatureQuery} with the restrictions indicateds.
207
     *
208
     * "filter" will be null or a valid filter expression for the store.
209
     *
210
     * "sortBy" can be null to use the store's default order.
211
     *
212
     * The parameter sortBy can be an attribute name or a comma separated list.
213
     * Each attribute name can be preceded or followed by "+" or "-" to indicate
214
     * the order to use to sort by that attribute.
215
     *
216
     * If no "+" or "-" is indicated, the "asc" parameter will be used to
217
     * determine if the order is ascending, "true" or decent, "false".
218
     *
219
     * @param filter an {@link String} expression used to filter the features in the store.
220
     * @param sortBy Attribute names separated by commas used to sort the list to return.
221
     * @param asc use order ascending, true, or descending, false.
222
     * @return a {@link FeatureQuery} with the restrictions.
223
     * @see {@link FeatureQuery}
224
     */
225
    public FeatureQuery createFeatureQuery(String filter, String sortBy, boolean asc);
226 45425 jjdelcerro
    public FeatureQuery createFeatureQuery(String filter);
227
    public FeatureQuery createFeatureQuery(Expression filter);
228 40435 jjdelcerro
229 44346 jjdelcerro
    /**
230
     * Create a {@link FeatureQuery} with the restrictions indicateds.
231
     *
232
     * "filter" will be null or {@link Expression} valid for the store.
233
     *
234
     * "sortBy" can be null to use the store's default order.
235
     *
236
     * The parameter sortBy can be an attribute name or a comma separated list.
237
     * Each attribute name can be preceded or followed by "+" or "-" to indicate
238
     * the order to use to sort by that attribute.
239
     *
240
     * If no "+" or "-" is indicated, the "asc" parameter will be used to
241
     * determine if the order is ascending, "true" or decent, "false".
242
     *
243
     * @param filter an {@link String} expression used to filter the features in the store.
244
     * @param sortBy Attribute names separated by commas used to sort the list to return.
245
     * @param asc use order ascending, true, or descending, false.
246
     * @return a {@link FeatureQuery} with the restrictions.
247
     * @see {@link FeatureQuery}
248
     */
249
    public FeatureQuery createFeatureQuery(Expression filter, String sortBy, boolean asc);
250
251 45308 fdiaz
    /**
252
     * Create a {@link FeatureQuery} with the restrictions indicateds.
253
     *
254
     * "filter" will be null or {@link Expression} valid for the store.
255
     *
256
     * "sortBy" can be null to use the store's default order.
257
     *
258
     * The parameter sortBy can be an attribute name or a comma separated list.
259
     * Each attribute name can be preceded or followed by "+" or "-" to indicate
260
     * the order to use to sort by that attribute.
261
     *
262
     * If no "+" or "-" is indicated, the "asc" parameter will be used to
263
     * determine if the order is ascending, "true" or decent, "false".
264
     *
265
     * @param filter an {@link String} expression used to filter the features in the store.
266
     * @param sortBy expression used to order the features in the store.
267
     * @param asc use order ascending, true, or descending, false.
268
     * @return a {@link FeatureQuery} with the restrictions.
269
     * @see {@link FeatureQuery}
270
     */
271
    public FeatureQuery createFeatureQuery(Expression filter, Expression sortBy, boolean asc);
272
273
    /**
274
     * Create a {@link FeatureQuery} with the restrictions indicateds.
275
     *
276
     * "filter" will be null or {@link Expression} valid for the store.
277
     *
278
     * "sortBy" can be null to use the store's default order.
279
     *
280
     * The parameter sortBy can be an attribute name or a comma separated list.
281
     * Each attribute name can be preceded or followed by "+" or "-" to indicate
282
     * the order to use to sort by that attribute.
283
     *
284
     * If no "+" or "-" is indicated, the "asc" parameter will be used to
285
     * determine if the order is ascending, "true" or decent, "false".
286
     *
287
     * @param filter an {@link String} expression used to filter the features in the store.
288
     * @param sortBy expression used to order the features in the store.
289
     * @param asc use order ascending, true, or descending, false.
290
     * @return a {@link FeatureQuery} with the restrictions.
291
     * @see {@link FeatureQuery}
292
     */
293
    public FeatureQuery createFeatureQuery(String filter, Expression sortBy, boolean asc);
294
295
296
297 40435 jjdelcerro
    /**
298
     * Returns all available features in the store.
299 41818 fdiaz
     *
300 44346 jjdelcerro
     * It is a utility method that calls {@link #getFeatureSet(FeatureQuery)}
301
     *
302
     * @return the {@link FeatureSet}
303
     * @throws ReadException if there is any error while reading the features
304
     * @see {@link #accept(org.gvsig.tools.visitor.Visitor)}, {@link #getFeatureSet(FeatureQuery)}
305 40435 jjdelcerro
     */
306
    FeatureSet getFeatureSet() throws DataException;
307
308 44346 jjdelcerro
    /**
309
     * Return a subset of features.
310
     *
311
     * It is a utility method that calls {@link #getFeatureSet(FeatureQuery)}
312
     *
313
     * @param filter an {@link String} expression used to filter the features in the store.
314
     * @return the {@link FeatureSet}
315
     * @throws ReadException if there is any error while reading the features
316
     * @see {@link #createFeatureQuery(Expression,String,boolean)}, {@link #getFeatureSet(FeatureQuery)}
317
     */
318 43533 jjdelcerro
    FeatureSet getFeatureSet(String filter) throws DataException;
319
320 44346 jjdelcerro
    /**
321
     * Return a subset of features.
322
     *
323
     * It is a utility method that calls {@link #getFeatureSet(FeatureQuery)}
324
     *
325
     * The sort order used is ascending.
326
     *
327
     * @param filter an {@link String} expression used to filter the features in the store.
328
     * @param sortBy Attribute names separated by commas used to sort the list to return.
329
     * @return the {@link FeatureSet}
330
     * @throws ReadException if there is any error while reading the features
331
     * @see {@link #createFeatureQuery(Expression,String,boolean)}, {@link #getFeatureSet(FeatureQuery)}
332
     */
333 43533 jjdelcerro
    FeatureSet getFeatureSet(String filter, String sortBy) throws DataException;
334
335 44346 jjdelcerro
    /**
336
     * Return a subset of features.
337
     *
338
     * It is a utility method that calls {@link #getFeatureSet(FeatureQuery)}
339
     *
340
     * @param filter an {@link String} expression used to filter the features in the store.
341
     * @param sortBy Attribute names separated by commas used to sort the list to return.
342
     * @param asc use order ascending, true, or descending, false.
343
     * @return the {@link FeatureSet}
344
     * @throws ReadException if there is any error while reading the features
345
     * @see {@link #createFeatureQuery(Expression,String,boolean)}, {@link #getFeatureSet(FeatureQuery)}
346
     */
347 43533 jjdelcerro
    FeatureSet getFeatureSet(String filter, String sortBy, boolean asc) throws DataException;
348
349 44346 jjdelcerro
    /**
350
     * Return a subset of features.
351
     *
352
     * It is a utility method that calls {@link #getFeatureSet(FeatureQuery)}
353
     *
354
     * @param filter an {@link Expression} used to filter the features in the store.
355
     * @return the {@link FeatureSet}
356
     * @throws DataException
357
     * @see {@link #createFeatureQuery(Expression,String,boolean)}, {@link #getFeatureSet(FeatureQuery)}
358
     */
359 44023 jjdelcerro
    FeatureSet getFeatureSet(Expression filter) throws DataException;
360
361 44346 jjdelcerro
    /**
362
     * Return a subset of features.
363
     *
364
     * It is a utility method that calls {@link #getFeatureSet(FeatureQuery)}
365
     *
366
     * The sort order used is ascending.
367
     *
368
     * @param filter an {@link Expression} used to filter the features in the store.
369
     * @param sortBy Attribute names separated by commas used to sort the list to return.
370
     * @return the {@link FeatureSet}
371
     * @throws ReadException if there is any error while reading the features
372
     * @see {@link #createFeatureQuery(Expression,String,boolean)}, {@link #getFeatureSet(FeatureQuery)}
373
     */
374 44023 jjdelcerro
    FeatureSet getFeatureSet(Expression filter, String sortBy) throws DataException;
375
376 44346 jjdelcerro
    /**
377
     * Return a subset of features.
378
     *
379
     * It is a utility method that calls {@link #getFeatureSet(FeatureQuery)}
380
     *
381
     * @param filter an {@link Expression} used to filter the features in the store.
382
     * @param sortBy Attribute names separated by commas used to sort the list to return.
383
     * @param asc use order ascending, true, or descending, false.
384
     * @return the {@link FeatureSet}
385
     * @throws DataException
386
     * @see {@link #createFeatureQuery(Expression,String,boolean)}, {@link #getFeatureSet(FeatureQuery)}
387
     */
388 44023 jjdelcerro
    FeatureSet getFeatureSet(Expression filter, String sortBy, boolean asc) throws DataException;
389 44346 jjdelcerro
390 40435 jjdelcerro
    /**
391
     * Returns a subset of features taking into account the properties and
392 44346 jjdelcerro
     * restrictions of the {@link FeatureQuery}.
393
     *
394
     * If {@link FeatureQuery} is null, return al features in the store.
395
     *
396 40435 jjdelcerro
     * <p>
397
     * <em>
398 41818 fdiaz
     * <strong>NOTE:</strong> if you use this method to get a
399
     * {@link FeatureSet}, you  must get sure it is disposed
400
     * (@see {@link DisposableIterator#dispose()}) in any case, even if an
401
     * error occurs while getting the data. It is recommended to use the
402
     * <code>accept</code> methods instead, which handle everything for you.
403
     * Take into account the accept methods may use a fast iterator to
404 40435 jjdelcerro
     * get the features.
405
     * </em>
406
     * </p>
407 41818 fdiaz
     *
408 44346 jjdelcerro
     * @param featureQuery defines the characteristics of the features to return.
409
     * @return the {@link FeatureSet}
410
     * @throws ReadException if there is any error while reading the features.
411
     * @see #accept(org.gvsig.tools.visitor.Visitor, org.gvsig.fmap.dal.DataQuery)
412 40435 jjdelcerro
     */
413
    FeatureSet getFeatureSet(FeatureQuery featureQuery) throws DataException;
414
415
    /**
416
     * Loads a subset of features taking into account the properties and
417 44346 jjdelcerro
     * restrictions of the FeatureQuery.
418
     * When feature loading is finished call the Observer passing the
419
     * {@link FeatureSet}  loaded.
420 41818 fdiaz
     *
421 44346 jjdelcerro
     * @param featureQuery defines the characteristics of the features to return.
422
     * @param observer to be notified when loading is finished.
423
     * @throws DataException if there is any error while loading the features
424 40435 jjdelcerro
     */
425 44346 jjdelcerro
    void getFeatureSet(FeatureQuery featureQuery, Observer observer) throws DataException;
426 40435 jjdelcerro
427
    /**
428
     * Loads all available feature in the store. The loading of Features is
429
     * performed by calling the Observer, once each loaded Feature.
430 41818 fdiaz
     *
431 44346 jjdelcerro
     * @param observer to be notified of each loaded Feature
432
     * @throws DataException if there is any error while loading the features
433 40435 jjdelcerro
     */
434
    void getFeatureSet(Observer observer) throws DataException;
435
436
    /**
437 42925 jjdelcerro
     * Return a paginated list of Features filtered by the query.
438 44346 jjdelcerro
     *
439
     * If the query  is null, return all features in the store sorteds
440
     * by default order.
441
     *
442
     * The return value implements {@link List} and {@link UnmodifiableBasicList64}
443
     * to support large list of features.
444
     *
445
     * The returned list of Features is paginated, and the page size
446
     * used is "pageSize".
447
     *
448
     * If the page size is less than or equal to 0, the default page size of
449
     * 100 will be used.
450 43371 fdiaz
     *
451 44346 jjdelcerro
     * @param query to filter and sort the returned feature list
452 42925 jjdelcerro
     * @param pageSize the page size of the list
453 44346 jjdelcerro
     * @return the {@link List}/{@link UnmodifiableBasicList64} of features
454 42925 jjdelcerro
     */
455
    public List<Feature> getFeatures(FeatureQuery query, int pageSize);
456 43371 fdiaz
457 44346 jjdelcerro
    /**
458
     * Return a paginated list of Features.
459
     *
460
     * It is a utility method that calls {@link #getFeatures(FeatureQuery, int)}
461
     * using the default page size.
462
     *
463
     * @param query to filter and sort the returned feature list
464
     * @return the {@link List}/{@link UnmodifiableBasicList64} of features
465
     * @see {@link #getFeatures(FeatureQuery, int)}
466
     */
467 43550 jjdelcerro
    public List<Feature> getFeatures(FeatureQuery query);
468
469 44346 jjdelcerro
    /**
470
     * Return a paginated list with al Features in the store.
471
     *
472
     * It is a utility method that calls {@link #getFeatures(FeatureQuery, int)}
473
     * using the default page size.
474
     *
475
     * @return the {@link List}/{@link UnmodifiableBasicList64} of features
476
     * @see {@link #getFeatures(FeatureQuery, int)}
477
     */
478 43020 jjdelcerro
    public List<Feature> getFeatures();
479 43371 fdiaz
480 44346 jjdelcerro
    /**
481
     * Return a paginated list of Features
482
     *
483
     * It is a utility method that calls {@link #getFeatures(FeatureQuery, int)}
484
     *
485
     * @param filter used to filter the features in the store.
486
     * @return the List of Features
487
     * @see {@link #getFeatures(FeatureQuery, int)}, {@link #createFeatureQuery(String,String,boolean)}
488
     */
489 43628 jjdelcerro
    public List<Feature> getFeatures(String filter);
490
491 44346 jjdelcerro
    /**
492
     * Return a paginated list of Features.
493
     *
494
     * It is a utility method that calls {@link #getFeatures(FeatureQuery, int)}
495
     * using the default page size.
496
     *
497
     * @param filter used to filter the features in the store.
498
     * @param sortBy Attribute names separated by commas used to sort the list to return.
499
     * @return the {@link List}/{@link UnmodifiableBasicList64} of features
500
     * @see {@link #getFeatures(FeatureQuery, int)}, {@link #createFeatureQuery(String,String,boolean)}
501
     */
502 43628 jjdelcerro
    public List<Feature> getFeatures(String filter, String sortBy);
503
504 44346 jjdelcerro
    /**
505
     * Return a paginated list of Features.
506
     *
507
     * It is a utility method that calls {@link #getFeatures(FeatureQuery, int)}
508
     * using the default page size.
509
     *
510
     * @param filter an {@link String} expression used to filter the features in the store.
511
     * @param sortBy Attribute names separated by commas used to sort the list to return.
512
     * @param asc use order ascending, true, or descending, false.
513
     * @return the {@link List}/{@link UnmodifiableBasicList64} of features
514
     * @see {@link #getFeatures(FeatureQuery, int)}, {@link #createFeatureQuery(String,String,boolean)}
515
     */
516 43628 jjdelcerro
    public List<Feature> getFeatures(String filter, String sortBy, boolean asc);
517
518 44346 jjdelcerro
    /**
519
     * Return a paginated list of Features
520
     *
521
     * It is a utility method that calls {@link #getFeatures(FeatureQuery, int)}
522
     * using the default page size.
523
     *
524
     * @param filter an {@link Expression} used to filter the features in the store.
525
     * @return the List of Features
526
     * @see {@link #getFeatures(FeatureQuery, int)}, {@link #createFeatureQuery(Expression,String,boolean)}
527
     */
528 44023 jjdelcerro
    public List<Feature> getFeatures(Expression filter);
529
530 44346 jjdelcerro
    /**
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 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
     * @return the {@link List}/{@link UnmodifiableBasicList64} of features
539
     * @see {@link #getFeatures(FeatureQuery, int)}, {@link #createFeatureQuery(Expression,String,boolean)}
540
     */
541 44023 jjdelcerro
    public List<Feature> getFeatures(Expression filter, String sortBy);
542
543 44346 jjdelcerro
    /**
544
     * Return a paginated list of Features
545
     *
546
     * It is a utility method that calls {@link #getFeatures(FeatureQuery, int)}
547
     * using the default page size.
548
     *
549
     * @param filter an {@link Expression} used to filter the features in the store.
550
     * @param sortBy Attribute names separated by commas used to sort the list to return.
551
     * @param asc use order ascending, true, or descending, false.
552
     * @return the {@link List}/{@link UnmodifiableBasicList64} of features
553
     * @see {@link #getFeatures(FeatureQuery, int)}, {@link #createFeatureQuery(Expression,String,boolean)}
554
     */
555 44023 jjdelcerro
    public List<Feature> getFeatures(Expression filter, String sortBy, boolean asc);
556
557 45425 jjdelcerro
    public GetItemWithSizeIsEmptyAndIterator64<Feature> getFeatures64();
558
559
    public GetItemWithSizeIsEmptyAndIterator64<Feature> getFeatures64(String filter);
560
561
    public GetItemWithSizeIsEmptyAndIterator64<Feature> getFeatures64(String filter, String sortBy, boolean asc);
562
563
    public GetItemWithSizeIsEmptyAndIterator64<Feature> getFeatures64(FeatureQuery query, int pageSize);
564
565 44346 jjdelcerro
    /**
566
     * Return the first {@link Feature} of the store.
567
     *
568
     * @return the first {@link Feature} or null if the store is empty.
569
     * @throws DataException
570
     */
571 44100 jjdelcerro
    public Feature first() throws DataException;
572
573 44346 jjdelcerro
    /**
574
     * Returns the first {@link Feature} that meets the criteria indicated.
575
     *
576
     * It is a utility method that calls {@link #findFirst(FeatureQuery)}.
577
     *
578
     * @param filter {@link String} expression used to filter the features.
579
     * @return the first {@link Feature} or null if the filter don't return any feature.
580
     * @throws DataException
581
     * @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(String,String,boolean)}
582
     */
583 43628 jjdelcerro
    public Feature findFirst(String filter) throws DataException;
584
585 44346 jjdelcerro
    /**
586
     * Returns the first {@link Feature} that meets the criteria indicated.
587
     *
588
     * It is a utility method that calls {@link #findFirst(FeatureQuery)}.
589
     *
590
     * @param filter {@link String} expression used to filter the features.
591
     * @param sortBy Attribute names separated by commas used to sort the list to return.
592
     * @return the first {@link Feature} or null if the filter don't return any feature.
593
     * @throws DataException
594
     * @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(String,String,boolean)}
595
     */
596 43628 jjdelcerro
    public Feature findFirst(String filter, String sortBy) throws DataException;
597
598 44346 jjdelcerro
    /**
599
     * Returns the first {@link Feature} that meets the criteria indicated.
600
     *
601
     * It is a utility method that calls {@link #findFirst(FeatureQuery)}.
602
     *
603
     * @param filter {@link String} expression used to filter the features.
604
     * @param sortBy Attribute names separated by commas used to sort the list to return.
605
     * @param asc use order ascending, true, or descending, false.
606
     * @return the first {@link Feature} or null if the filter don't return any feature.
607
     * @throws DataException
608
     * @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(String,String,boolean)}
609
     */
610 43628 jjdelcerro
    public Feature findFirst(String filter, String sortBy, boolean asc) throws DataException;
611
612 45308 fdiaz
613 44346 jjdelcerro
    /**
614
     * Returns the first {@link Feature} that meets the criteria indicated.
615
     *
616
     * It is a utility method that calls {@link #findFirst(FeatureQuery)}.
617
     *
618
     * @param filter {@link String} expression used to filter the features.
619 45308 fdiaz
     * @param sortBy Expression
620
     * @param asc use order ascending, true, or descending, false.
621 44346 jjdelcerro
     * @return the first {@link Feature} or null if the filter don't return any feature.
622
     * @throws DataException
623 45308 fdiaz
     * @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(String,String,boolean)}
624
     */
625
    public Feature findFirst(String filter, Expression sortBy, boolean asc) throws DataException;
626
627
    /**
628
     * Returns the first {@link Feature} that meets the criteria indicated.
629
     *
630
     * It is a utility method that calls {@link #findFirst(FeatureQuery)}.
631
     *
632
     * @param filter {@link String} expression used to filter the features.
633
     * @return the first {@link Feature} or null if the filter don't return any feature.
634
     * @throws DataException
635 44346 jjdelcerro
     * @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(Expession,String,boolean)}
636
     */
637 44023 jjdelcerro
    public Feature findFirst(Expression filter) throws DataException;
638
639 44346 jjdelcerro
    /**
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 Attribute names separated by commas used to sort the list to return.
646
     * @return the first {@link Feature} or null if the filter don't return any feature.
647
     * @throws DataException
648
     * @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(Expession,String,boolean)}
649
     */
650 44023 jjdelcerro
    public Feature findFirst(Expression filter, String sortBy) throws DataException;
651
652 44346 jjdelcerro
    /**
653
     * Returns the first {@link Feature} that meets the criteria indicated.
654
     *
655
     * It is a utility method that calls {@link #findFirst(FeatureQuery)}.
656
     *
657
     * @param filter {@link String} expression used to filter the features.
658
     * @param sortBy Attribute names separated by commas used to sort the list to return.
659
     * @param asc use order ascending, true, or descending, false.
660
     * @return the first {@link Feature} or null if the filter don't return any feature.
661
     * @throws DataException
662
     * @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(Expession,String,boolean)}
663
     */
664 44023 jjdelcerro
    public Feature findFirst(Expression filter, String sortBy, boolean asc) throws DataException;
665
666 44346 jjdelcerro
    /**
667
     * Returns the first {@link Feature} that meets the criteria indicated.
668
     *
669
     * It is a utility method that calls {@link #findFirst(FeatureQuery)}.
670
     *
671 45308 fdiaz
     * @param filter {@link String} expression used to filter the features.
672
     * @param sortBy expression used to sort features
673
     * @param asc use order ascending, true, or descending, false.
674
     * @return the first {@link Feature} or null if the filter don't return any feature.
675
     * @throws DataException
676
     * @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(Expession,String,boolean)}
677
     */
678
    public Feature findFirst(Expression filter, Expression sortBy, boolean asc) throws DataException;
679
680
    /**
681
     * Returns the first {@link Feature} that meets the criteria indicated.
682
     *
683
     * It is a utility method that calls {@link #findFirst(FeatureQuery)}.
684
     *
685 44346 jjdelcerro
     * @param query to filter and sort the returned feature list
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 44262 jjdelcerro
    public Feature findFirst(FeatureQuery query) throws DataException;
691 44346 jjdelcerro
692 42925 jjdelcerro
    /**
693 40435 jjdelcerro
     * Returns the feature given its reference.
694 41818 fdiaz
     *
695 44346 jjdelcerro
     * @param reference a unique FeatureReference
696
     * @return
697
     * @returnThe Feature
698 40435 jjdelcerro
     * @throws DataException
699 41818 fdiaz
     *
700 40435 jjdelcerro
     */
701 44346 jjdelcerro
    public Feature getFeatureByReference(FeatureReference reference) throws DataException;
702 40435 jjdelcerro
703
    /**
704
     * Returns the feature given its reference and feature type.
705 41818 fdiaz
     *
706 40435 jjdelcerro
     * @param reference
707
     *            a unique FeatureReference
708 41818 fdiaz
     *
709 40435 jjdelcerro
     * @param featureType
710
     *            FeatureType to which the requested Feature belongs
711 41818 fdiaz
     *
712 40435 jjdelcerro
     * @return
713
     *         The Feature
714 41818 fdiaz
     *
715 40435 jjdelcerro
     * @throws DataException
716 41818 fdiaz
     *
717 40435 jjdelcerro
     */
718
    public Feature getFeatureByReference(FeatureReference reference,
719
        FeatureType featureType) throws DataException;
720
721
    /*
722
     * =============================================================
723 41818 fdiaz
     *
724 40435 jjdelcerro
     * Editing related services
725
     */
726
727
    /**
728
     * Enters editing state.
729 44884 jjdelcerro
     * @throws org.gvsig.fmap.dal.exception.DataException
730 40435 jjdelcerro
     */
731
    public void edit() throws DataException;
732
733
    /**
734
     * Enters editing state specifying the editing mode.
735 41818 fdiaz
     *
736 40435 jjdelcerro
     * @param mode
737 41818 fdiaz
     *
738 40435 jjdelcerro
     * @throws DataException
739
     */
740
    public void edit(int mode) throws DataException;
741 45482 fdiaz
742
    public int getMode();
743 40435 jjdelcerro
744
    /**
745
     * Cancels all editing since the last edit().
746 41818 fdiaz
     *
747 40435 jjdelcerro
     * @throws DataException
748
     */
749
    public void cancelEditing() throws DataException;
750
751 45425 jjdelcerro
    public boolean cancelEditingQuietly();
752
753 45441 jjdelcerro
    public static boolean cancelEditingQuietly(FeatureStore store) {
754
        if( store==null ) {
755
            return true;
756
        }
757
        return store.cancelEditingQuietly();
758
    }
759
760 40435 jjdelcerro
    /**
761
     * Exits editing state.
762 41818 fdiaz
     *
763 40435 jjdelcerro
     * @throws DataException
764
     */
765
    public void finishEditing() throws DataException;
766
767 45425 jjdelcerro
    public boolean finishEditingQuietly();
768
769 45441 jjdelcerro
    public static boolean finishEditingQuietly(FeatureStore store) {
770
        if( store==null ) {
771
            return true;
772
        }
773
        return store.finishEditingQuietly();
774
    }
775
776 40435 jjdelcerro
    /**
777
     * Save changes in the provider without leaving the edit mode.
778
     * Do not call observers to communicate a change of ediding mode.
779
     * The operation's history is eliminated to prevent inconsistencies
780
     * in the data.
781
     *
782
     * @throws DataException
783
     */
784
    public void commitChanges() throws DataException ;
785
786
    /**
787
     *
788
     * Returns true if you can call CommitChanges method.
789
     * If not in editing or changes have been made in the structure
790
     * return false.
791 41818 fdiaz
     *
792 40435 jjdelcerro
     * @return true if can call commitChanges
793 41818 fdiaz
     * @throws DataException
794 40435 jjdelcerro
     */
795
    public boolean canCommitChanges() throws DataException;
796
797 41818 fdiaz
798 40435 jjdelcerro
    /**
799
     * Indicates whether this store is in editing state.
800 41818 fdiaz
     *
801 40435 jjdelcerro
     * @return
802
     *         true if this store is in editing state, false if not.
803
     */
804
    public boolean isEditing();
805
806
    /**
807
     * Indicates whether this store is in appending state. In this state the new
808
     * features are automatically inserted at the end of the {@link FeatureSet}.
809 41818 fdiaz
     *
810 40435 jjdelcerro
     * @return true if this store is in appending state.
811
     */
812
    public boolean isAppending();
813
814
    /**
815
     * Updates a {@link FeatureType} in the store with the changes in the
816
     * {@link EditableFeatureType}.<br>
817 41818 fdiaz
     *
818 40435 jjdelcerro
     * Any {@link FeatureSet} from this store that are used will be invalidated.
819 41818 fdiaz
     *
820 40435 jjdelcerro
     * @param featureType
821
     *            an {@link EditableFeatureType} with the changes.
822 41818 fdiaz
     *
823 40435 jjdelcerro
     * @throws DataException
824
     */
825
    public void update(EditableFeatureType featureType) throws DataException;
826
827
    /**
828
     * Updates a {@link Feature} in the store with the changes in the
829
     * {@link EditableFeature}.<br>
830 41818 fdiaz
     *
831 40435 jjdelcerro
     * Any {@link FeatureSet} from this store that was still in use will be
832
     * invalidated. You can override this using
833
     * {@link FeatureSet#update(EditableFeature)}.
834 41818 fdiaz
     *
835 40435 jjdelcerro
     * @param feature
836
     *            the feature to be updated
837 41818 fdiaz
     *
838 40435 jjdelcerro
     * @throws DataException
839
     */
840
    public void update(EditableFeature feature) throws DataException;
841
842 45776 fdiaz
    /**
843
     * Updates Features in the store with the values of the parameters.
844
     * Examples:
845
     *      update("field1",value1,"field2",value2);
846
     *      update("field1",value1,"field2",value2,filter);
847
     *
848
     * filter can be a {@link Expression} or a String
849
     *
850
     * @param parameters
851
     * @throws DataException
852
     */
853 45425 jjdelcerro
    public void update(Object... parameters) throws DataException;
854
855 40435 jjdelcerro
    /**
856
     * Deletes a {@link Feature} from the store.<br>
857 41818 fdiaz
     *
858 40435 jjdelcerro
     * Any {@link FeatureSet} from this store that was still in use will be
859
     * invalidated. You can override this using {@link Iterator#remove()} from
860
     * {@link FeatureSet}.
861 41818 fdiaz
     *
862 40435 jjdelcerro
     * @param feature
863
     *            The feature to be deleted.
864 41818 fdiaz
     *
865 40435 jjdelcerro
     * @throws DataException
866
     */
867
    public void delete(Feature feature) throws DataException;
868 45425 jjdelcerro
869
    public void delete(String filter);
870
871
    public void delete(Expression filter);
872 40435 jjdelcerro
873
    /**
874
     * Inserts a {@link Feature} in the store.<br>
875 41818 fdiaz
     *
876 40435 jjdelcerro
     * Any {@link FeatureSet} from this store that was still in use will be
877
     * invalidated. You can override this using
878
     * {@link FeatureSet#insert(EditableFeature)}.
879 41818 fdiaz
     *
880 40435 jjdelcerro
     * @param feature
881
     *            The feature to be inserted
882 41818 fdiaz
     *
883 40435 jjdelcerro
     * @throws DataException
884
     */
885
    public void insert(EditableFeature feature) throws DataException;
886
887
    /**
888 45071 jjdelcerro
     * Inserts a set of {@link Feature} in the store.
889
     *
890
     * The attributes of the feature are copied from the features of the set
891
     * by name, forcing the conversion of types if necessary.
892
     *
893
     * Any {@link FeatureSet} from this store that was still in use will be
894
     * invalidated.
895
     *
896
     * @param set, set with the source features.
897
     * @throws DataException
898
     */
899
    public void insert(FeatureSet set) throws DataException;
900
901
    /**
902 40435 jjdelcerro
     * Creates a new feature using the default feature type and returns it as an
903
     * {@link EditableFeature}
904 41818 fdiaz
     *
905 40435 jjdelcerro
     * @return a new feature in editable state
906 41818 fdiaz
     *
907 40435 jjdelcerro
     * @throws DataException
908
     */
909
    public EditableFeature createNewFeature() throws DataException;
910
911
    /**
912
     * Creates a new feature of the given {@link FeatureType} and uses the given
913
     * {@link Feature} as default values to initialize it.
914 41818 fdiaz
     *
915 40435 jjdelcerro
     * @param type
916
     *            the new feature's feature type
917 41818 fdiaz
     *
918 40435 jjdelcerro
     * @param defaultValues
919
     *            a feature whose values are used as default values for the new
920
     *            feature.
921 41818 fdiaz
     *
922 40435 jjdelcerro
     * @return the new feature.
923 41818 fdiaz
     *
924 40435 jjdelcerro
     * @throws DataException
925
     */
926
    public EditableFeature createNewFeature(FeatureType type,
927
        Feature defaultValues) throws DataException;
928
929
    /**
930
     * Creates a new feature of the given {@link FeatureType}. The flag
931
     * defaultValues is used to indicate whether the new feature should be
932
     * initialized with default values or not.
933 41818 fdiaz
     *
934 40435 jjdelcerro
     * @param type
935
     *            the new feature's feature type
936 41818 fdiaz
     *
937 40435 jjdelcerro
     * @param defaultValues
938
     *            if true the new feature is initialized with each attribute's
939
     *            default value.
940 41818 fdiaz
     *
941 40435 jjdelcerro
     * @return
942
     *         the new feature
943 41818 fdiaz
     *
944 40435 jjdelcerro
     * @throws DataException
945
     */
946
    public EditableFeature createNewFeature(FeatureType type,
947
        boolean defaultValues) throws DataException;
948
949
    /**
950
     * Creates a new feature of default {@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 defaultValues
955
     *            if true the new feature is initialized with each attribute's
956
     *            default value.
957 41818 fdiaz
     *
958 40435 jjdelcerro
     * @return
959
     *         the new feature
960 41818 fdiaz
     *
961 40435 jjdelcerro
     * @throws DataException
962
     */
963
    public EditableFeature createNewFeature(boolean defaultValues)
964
        throws DataException;
965
966
    /**
967 43371 fdiaz
     * Creates a new feature of default {@link FeatureType}.
968
     * The new feature should be initialized with the values of the feature
969 42293 jjdelcerro
     * passed as parameter.
970
     * Values are inicialiced by name from the feature specified. Error in
971
     * value assignement are ignoreds.
972 43371 fdiaz
     *
973 42293 jjdelcerro
     * @param defaultValues the values to initialize the new feature.
974
     * @return the new feature
975 43371 fdiaz
     * @throws DataException
976 42293 jjdelcerro
     */
977
    public EditableFeature createNewFeature(Feature defaultValues)
978
        throws DataException;
979
980 44655 jjdelcerro
    public EditableFeature createNewFeature(JsonObject defaultValues)
981
        throws DataException;
982
983 42293 jjdelcerro
    /**
984 40435 jjdelcerro
     * Indicates whether this store supports append mode.
985 41818 fdiaz
     *
986 40435 jjdelcerro
     * @return
987
     *         true if this store supports append mode.
988
     */
989
    public boolean isAppendModeSupported();
990
991
    /**
992
     * Initiates an editing group. This is typically used to group series of
993
     * store editing operations.
994 41818 fdiaz
     *
995 40435 jjdelcerro
     * @param description
996
     *            Description of the editing group.
997 41818 fdiaz
     *
998 40435 jjdelcerro
     * @throws NeedEditingModeException
999
     */
1000
    public void beginEditingGroup(String description)
1001
        throws NeedEditingModeException;
1002
1003
    /**
1004
     * Finishes an editing group.
1005 41818 fdiaz
     *
1006 40435 jjdelcerro
     * @throws NeedEditingModeException
1007
     */
1008
    public void endEditingGroup() throws NeedEditingModeException;
1009
1010
    /*
1011
     * =============================================================
1012 41818 fdiaz
     *
1013 40435 jjdelcerro
     * Index related services
1014
     */
1015
1016
    /**
1017
     * Creates an index which will be applied to the features of the given type,
1018
     * by using the data of the given attribute.
1019 41818 fdiaz
     *
1020 40435 jjdelcerro
     * @param featureType
1021
     *            The FeatureType to which the indexed attribute belongs.
1022 41818 fdiaz
     *
1023 40435 jjdelcerro
     * @param attributeName
1024
     *            The name of the attributed to be indexed
1025 41818 fdiaz
     *
1026 40435 jjdelcerro
     * @param indexName
1027
     *            The index name
1028 41818 fdiaz
     *
1029 40435 jjdelcerro
     * @return the resulting {@link FeatureIndex}
1030 41818 fdiaz
     *
1031
     *
1032 40435 jjdelcerro
     * @throws FeatureIndexException
1033
     *             if there is an error creating the index
1034
     */
1035
    public FeatureIndex createIndex(FeatureType featureType,
1036
        String attributeName, String indexName) throws DataException;
1037
1038
    /**
1039
     * Creates an index which will be applied to the features of the given type,
1040
     * by using the data of the given attribute.
1041 41818 fdiaz
     *
1042 40435 jjdelcerro
     * @param indexTypeName
1043
     *            the type of the index to be created. That name is
1044
     *            related to one of the registered index providers
1045
     * @param featureType
1046
     *            The FeatureType to which the indexed attribute belongs.
1047 41818 fdiaz
     *
1048 40435 jjdelcerro
     * @param attributeName
1049
     *            The name of the attributed to be indexed
1050 41818 fdiaz
     *
1051 40435 jjdelcerro
     * @param indexName
1052
     *            The index name
1053 41818 fdiaz
     *
1054 40435 jjdelcerro
     * @return the resulting {@link FeatureIndex}
1055 41818 fdiaz
     *
1056
     *
1057 40435 jjdelcerro
     * @throws FeatureIndexException
1058
     *             if there is an error creating the index
1059
     */
1060
    public FeatureIndex createIndex(String indexTypeName,
1061
        FeatureType featureType, String attributeName, String indexName)
1062
        throws DataException;
1063
1064
    /**
1065
     * Creates an index which will be applied to the features of the given type,
1066
     * by using the data of the given attribute. This method will return without
1067
     * waiting for the index to be filled, as that will be performed in
1068
     * background. An optional {@link Observer} parameter is provided to be
1069
     * notified ( {@link FeatureStoreNotification#INDEX_FILLING_SUCCESS} )
1070
     * when the index has finished filling with data and is available to be
1071
     * used.
1072 41818 fdiaz
     *
1073 40435 jjdelcerro
     * @param featureType
1074
     *            The FeatureType to which the indexed attribute belongs.
1075 41818 fdiaz
     *
1076 40435 jjdelcerro
     * @param attributeName
1077
     *            The name of the attributed to be indexed
1078 41818 fdiaz
     *
1079 40435 jjdelcerro
     * @param indexName
1080
     *            The index name
1081 41818 fdiaz
     *
1082 40435 jjdelcerro
     * @param observer
1083
     *            to notify to when the created index has finished filling
1084
     *            with data and is available to be used. The observer will
1085
     *            receive then a
1086
     *            {@link FeatureStoreNotification#INDEX_FILLING_SUCCESS}
1087
     *            notification, with the index object if it has finished
1088
     *            successfully, or a
1089
     *            {@link FeatureStoreNotification#INDEX_FILLING_ERROR}
1090
     *            notification with the exception object if there has been
1091
     *            any error in the process. Optional.
1092 41818 fdiaz
     *
1093 40435 jjdelcerro
     * @return the resulting {@link FeatureIndex}
1094 41818 fdiaz
     *
1095 40435 jjdelcerro
     * @see FeatureStoreNotification#INDEX_FILLING_STARTED
1096
     * @see FeatureStoreNotification#INDEX_FILLING_SUCCESS
1097
     * @see FeatureStoreNotification#INDEX_FILLING_CANCELLED
1098
     * @see FeatureStoreNotification#INDEX_FILLING_ERROR
1099 41818 fdiaz
     *
1100 40435 jjdelcerro
     * @throws FeatureIndexException
1101
     *             if there is an error creating the index
1102
     */
1103
    public FeatureIndex createIndex(FeatureType featureType,
1104
        String attributeName, String indexName, Observer observer)
1105
        throws DataException;
1106
1107
    /**
1108
     * Creates an index which will be applied to the features of the given type,
1109
     * by using the data of the given attribute. This method will return without
1110
     * waiting for the index to be filled, as that will be performed in
1111
     * background. An optional {@link Observer} parameter is provided to be
1112
     * notified ( {@link FeatureStoreNotification#INDEX_FILLING_SUCCESS} )
1113
     * when the index has finished filling with data and is available to be
1114
     * used.
1115 41818 fdiaz
     *
1116 40435 jjdelcerro
     * @param indexTypeName
1117
     *            the type of the index to be created. That name is
1118
     *            related to one of the registered index providers
1119
     * @param featureType
1120
     *            The FeatureType to which the indexed attribute belongs.
1121 41818 fdiaz
     *
1122 40435 jjdelcerro
     * @param attributeName
1123
     *            The name of the attributed to be indexed
1124 41818 fdiaz
     *
1125 40435 jjdelcerro
     * @param indexName
1126
     *            The index name
1127 41818 fdiaz
     *
1128 40435 jjdelcerro
     * @param observer
1129
     *            to notify to when the created index has finished filling
1130
     *            with data and is available to be used. The observer will
1131
     *            receive then a
1132
     *            {@link FeatureStoreNotification#INDEX_FILLING_SUCCESS}
1133
     *            notification, with the index object if it has finished
1134
     *            successfully, or a
1135
     *            {@link FeatureStoreNotification#INDEX_FILLING_ERROR}
1136
     *            notification with the exception object if there has been
1137
     *            any error in the process. Optional.
1138 41818 fdiaz
     *
1139 40435 jjdelcerro
     * @return the resulting {@link FeatureIndex}
1140 41818 fdiaz
     *
1141 40435 jjdelcerro
     * @see FeatureStoreNotification#INDEX_FILLING_STARTED
1142
     * @see FeatureStoreNotification#INDEX_FILLING_SUCCESS
1143
     * @see FeatureStoreNotification#INDEX_FILLING_CANCELLED
1144
     * @see FeatureStoreNotification#INDEX_FILLING_ERROR
1145 41818 fdiaz
     *
1146 40435 jjdelcerro
     * @throws FeatureIndexException
1147
     *             if there is an error creating the index
1148
     */
1149
    public FeatureIndex createIndex(String indexTypeName,
1150
        FeatureType featureType, String attributeName, String indexName,
1151
        Observer observer) throws DataException;
1152
1153
    /**
1154
     * Returns a FeatureIndexes structure containing all available indexes in
1155
     * the store.
1156 41818 fdiaz
     *
1157 40435 jjdelcerro
     * @return
1158
     */
1159
    public FeatureIndexes getIndexes();
1160
1161
    /*
1162
     * =============================================================
1163 41818 fdiaz
     *
1164 40435 jjdelcerro
     * Selection related services
1165
     */
1166
1167
    /**
1168
     * Sets the selection to the passed {@link FeatureSet}
1169 41818 fdiaz
     *
1170 40435 jjdelcerro
     * @param selection
1171
     *            A {@link FeatureSet} with the requested selection
1172 44884 jjdelcerro
     * @throws org.gvsig.fmap.dal.exception.DataException
1173 40435 jjdelcerro
     */
1174
    public void setSelection(FeatureSet selection) throws DataException;
1175
1176
    /**
1177
     * Creates a {@link FeatureSelection}
1178 41818 fdiaz
     *
1179 40435 jjdelcerro
     * @return
1180
     *         a {@link FeatureSelection}
1181 41818 fdiaz
     *
1182 40435 jjdelcerro
     * @throws DataException
1183
     */
1184
    public FeatureSelection createFeatureSelection() throws DataException;
1185 45426 fdiaz
1186
    public FeatureSelection createLargeFeatureSelection() throws DataException;
1187
1188
    /**
1189
     * Creates a {@link FeatureSelection}
1190
     *
1191
     * @return
1192
     *         a {@link FeatureSelection}
1193
     *
1194
     * @throws DataException
1195
     */
1196
    public FeatureSelection createMemoryFeatureSelection() throws DataException;
1197 40435 jjdelcerro
1198 45426 fdiaz
1199 40435 jjdelcerro
    /**
1200
     * Returns the current {@link FeatureSelection}.
1201
     * Create a empty selection if not exits.
1202 43358 jjdelcerro
     *
1203
     * Manage of the selection can be slow on some data sources.
1204
     * Use with care.
1205
     * In data sources that do not support position access to records,
1206
     * it may be slow to retrieve items from the selection. In some data
1207
     * sources it may be necessary to access to this to retrieve each
1208
     * item in the selection.
1209 41818 fdiaz
     *
1210 40435 jjdelcerro
     * @return
1211
     *         current {@link FeatureSelection}.
1212 41818 fdiaz
     *
1213 40435 jjdelcerro
     * @throws DataException
1214
     */
1215
    public FeatureSelection getFeatureSelection() throws DataException;
1216
1217 46672 fdiaz
    public FeatureSelection getFeatureSelectionQuietly();
1218
1219 40435 jjdelcerro
    /*
1220
     * =============================================================
1221 41818 fdiaz
     *
1222 40435 jjdelcerro
     * Lock related services
1223
     */
1224
1225
    /**
1226
     * Indicates whether this store supports locks.
1227 41818 fdiaz
     *
1228 40435 jjdelcerro
     * @return
1229
     *         true if this store supports locks, false if not.
1230
     */
1231
    public boolean isLocksSupported();
1232
1233
    /**
1234
     * Returns the set of locked features
1235 41818 fdiaz
     *
1236 40435 jjdelcerro
     * @return
1237
     *         set of locked features
1238 41818 fdiaz
     *
1239 40435 jjdelcerro
     * @throws DataException
1240
     */
1241
    public FeatureLocks getLocks() throws DataException;
1242
1243
    /*
1244
     * =============================================================
1245
     * Transforms related services
1246
     * =============================================================
1247
     */
1248
1249
    /**
1250
     * Returns this store transforms
1251 41818 fdiaz
     *
1252 40435 jjdelcerro
     * @return
1253
     *         this store transforms
1254
     */
1255
    public FeatureStoreTransforms getTransforms();
1256
1257
    /**
1258
     * Returns a new {@link FeatureQuery} associated to this store.
1259 41818 fdiaz
     *
1260 40435 jjdelcerro
     * @return
1261
     *         a new {@link FeatureQuery} associated to this store.
1262
     */
1263
    public FeatureQuery createFeatureQuery();
1264
1265
    /**
1266
     * Returns featue count of this store.
1267 41818 fdiaz
     *
1268 40435 jjdelcerro
     * @return
1269
     * @throws DataException
1270
     */
1271
    public long getFeatureCount() throws DataException;
1272
1273 43020 jjdelcerro
//    /**
1274
//     * Creates a vectorial cache that is used to save and retrieve data.
1275
//     *
1276
//     * @param name
1277
//     *            the cache name.
1278
//     * @param parameters
1279
//     *            parameters to create the stores used to save data.
1280
//     * @throws DataException
1281
//     */
1282
//    public void createCache(String name, DynObject parameters)
1283
//        throws DataException;
1284
//
1285
//    /**
1286
//     * @return the vectorial cache
1287
//     */
1288
//    public FeatureCache getCache();
1289 40435 jjdelcerro
1290
    /**
1291
     * Return if the provider knows the real envelope of a layer. If not,
1292
     * the {@link FeatureStoreProvider#getEnvelope()} method doesn't return
1293
     * the full envelope.
1294 41818 fdiaz
     *
1295 44884 jjdelcerro
     * @return true if it knows the real envelope.
1296 40435 jjdelcerro
     */
1297
    public boolean isKnownEnvelope();
1298
1299
    /**
1300
     * Return if the maximum number of features provided by the
1301
     * provider are limited.
1302 41818 fdiaz
     *
1303 44884 jjdelcerro
     * @return true if there is a limit of features.
1304 40435 jjdelcerro
     */
1305
    public boolean hasRetrievedFeaturesLimit();
1306
1307
    /**
1308
     * If the {@link FeatureStoreProvider#hasRetrievedFeaturesLimit()} returns
1309
     * true,
1310
     * it returns the limit of features retrieved from the provider.
1311 41818 fdiaz
     *
1312 40435 jjdelcerro
     * @return
1313
     *         The limit of the retrieved features.
1314
     */
1315
    public int getRetrievedFeaturesLimit();
1316 41818 fdiaz
1317
    /**
1318
     * Return the associated feature to the dynobject.
1319
     * If the dynobject isn't associated to a feature of this store, return null.
1320
     *
1321
     * @param dynobject
1322
     * @return
1323
     */
1324
    public Feature getFeature(DynObject dynobject);
1325 43371 fdiaz
1326
1327 43521 jjdelcerro
    public ExpressionBuilder createExpressionBuilder();
1328 43371 fdiaz
1329 43521 jjdelcerro
    /**
1330
     *
1331
     * @return
1332
     * @deprecated use createExpressionBuilder
1333
     */
1334
    public ExpressionBuilder createExpression();
1335
1336 43056 jjdelcerro
    public void createCache(String name, DynObject parameters)
1337
        throws DataException;
1338
1339 44443 jjdelcerro
    @Override
1340 43371 fdiaz
    public FeatureCache getCache();
1341
1342 43215 jjdelcerro
    public boolean isBroken();
1343 43371 fdiaz
1344 44443 jjdelcerro
    public Throwable getBreakingsCause();
1345 43371 fdiaz
1346
    /**
1347 44443 jjdelcerro
     * Indicates if the storage is temporary.
1348
     * There is no guarantee that a temporary store can be recovered from
1349
     * its parameters. In general these will not be persistent.
1350
     *
1351
     * @return true if the store is temporary, otherwise false.
1352
     */
1353
    public boolean isTemporary();
1354
1355 46301 fdiaz
    public void setTemporary(Boolean temporary);
1356
1357 44443 jjdelcerro
    /**
1358 43371 fdiaz
     * @param index
1359
     * @return
1360
     */
1361 44111 jjdelcerro
    public SpatialIndex wrapSpatialIndex(SpatialIndex index);
1362 43824 jjdelcerro
1363
    public FeatureReference getFeatureReference(String code);
1364 44111 jjdelcerro
1365
    /**
1366
     * Devuelbe el numero de operaciones pendientes de guardar en una sesion
1367
     * de edicion. Es un valor orientativo.
1368
     * Las operaciones pendientes son la suma de operaciones de borrado, insercion
1369
     * o modificacion de las features en una sesion de edicion.
1370
     *
1371
     * Retorna 0 si no esta en edicion.
1372
     *
1373
     * @return numero de operaciones pendientes.
1374
     */
1375
    public long getPendingChangesCount();
1376 44253 jjdelcerro
1377 44283 jjdelcerro
    public Feature getSampleFeature();
1378 44435 jjdelcerro
1379
    /**
1380
     * Return true when the default feature type of the store
1381
     * support references.
1382
     *
1383
     * @return true when support references.
1384
     */
1385
    public boolean supportReferences();
1386 45521 fdiaz
1387
    public Feature getOriginalFeature(FeatureReference id);
1388
1389
    public Feature getOriginalFeature(Feature feature);
1390
1391
    public boolean isFeatureModified(FeatureReference id);
1392
1393
    public boolean isFeatureModified(Feature feature);
1394 45738 fdiaz
1395
    public String getEditingSession();
1396 45788 jjdelcerro
1397
    public List<FeatureReference> getEditedFeatures();
1398
1399
    public List<FeatureReference> getEditedFeaturesNotValidated();
1400 46277 jjdelcerro
1401
    public boolean isFeatureSelectionEmpty();
1402 45788 jjdelcerro
1403 46277 jjdelcerro
    public boolean isFeatureSelectionAvailable();
1404 46309 jjdelcerro
1405
    public Iterator<Feature> getFeaturesIterator(Iterator<FeatureReference> references);
1406
1407
    public Iterable<Feature> getFeaturesIterable(Iterator<FeatureReference> references);
1408
1409 40435 jjdelcerro
}