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

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