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