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 / FeatureQuery.java @ 46875

History | View | Annotate | Download (11 KB)

1 40559 jjdelcerro
/**
2
 * gvSIG. Desktop Geographic Information System.
3 40435 jjdelcerro
 *
4 40559 jjdelcerro
 * Copyright (C) 2007-2013 gvSIG Association.
5 40435 jjdelcerro
 *
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 40559 jjdelcerro
 * as published by the Free Software Foundation; either version 3
9 40435 jjdelcerro
 * 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 40559 jjdelcerro
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23 40435 jjdelcerro
 */
24
/*
25
 * AUTHORS (In addition to CIT):
26
 * 2008 {DiSiD Technologies}  {Create Parameter object to define FeatureCollections queries}
27
 */
28
package org.gvsig.fmap.dal.feature;
29
30 44712 jjdelcerro
import java.util.List;
31
import java.util.Map;
32 44023 jjdelcerro
import org.gvsig.expressionevaluator.Expression;
33 46010 jjdelcerro
import org.gvsig.expressionevaluator.MutableSymbolTable;
34
import org.gvsig.expressionevaluator.SymbolTable;
35 40435 jjdelcerro
import org.gvsig.fmap.dal.DataQuery;
36
import org.gvsig.tools.evaluator.Evaluator;
37
import org.gvsig.tools.lang.Cloneable;
38
39
/**
40
 * Defines the properties of a collection of Features, as a result of a query
41
 * through a FeatureStore.
42
 * <p>
43
 * A FeatureQuery is always defined by a FeatureType, or by the list of
44
 * attribute names of the FeatureStore to return.
45
 * </p>
46
 * <p>
47
 * The filter allows to select Features whose properties have values with the
48
 * characteristics defined by the filter.
49
 * </p>
50
 * <p>
51
 * The order is used to set the order of the result FeatureCollection, based on
52
 * the values of the properties of the Features.
53
 * </p>
54
 * <p>
55
 * The scale parameter can be used by the FeatureStore as a hint about the
56
 * quality or resolution of the data needed to view or operate with the data
57
 * returned. As an example, the FeatureStore may use the scale to return only a
58
 * representative subset of the data, or maybe to return Features with less
59
 * detail, like a point or a line instead of a polygon.
60
 * </p>
61
 * <p>
62
 * If an implementation of FeatureStore is able to get other parameters to
63
 * customize the behavior of the getDataCollection methods, there is an option
64
 * to set more parameters through the setAttribute method.
65
 * </p>
66 42975 jjdelcerro
 *
67 40435 jjdelcerro
 * @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team
68
 */
69
public interface FeatureQuery extends DataQuery, Cloneable {
70
71 46456 jjdelcerro
    public static final int NO_LIMIT = -1;
72
73 44712 jjdelcerro
  /**
74
   * Returns the names of the attributes to load from each {@link Feature}.
75
   *
76
   * @return the attribute names to load
77
   */
78
  String[] getAttributeNames();
79 40435 jjdelcerro
80 44712 jjdelcerro
  /**
81
   * Sets the names of the attributes to load from each {@link Feature}.
82
   *
83
   * @param attributeNames the attribute names to load
84
   */
85
  void setAttributeNames(String[] attributeNames);
86 42975 jjdelcerro
87 44712 jjdelcerro
  void retrievesAllAttributes();
88 40435 jjdelcerro
89 44712 jjdelcerro
  /**
90
   * Adds the name of an attribute that has to be used to load each
91
   * {@link Feature}.
92
   *
93
   * @param attributeName the attribute name to load
94
   */
95
  void addAttributeName(String attributeName);
96 42975 jjdelcerro
97 44712 jjdelcerro
  public void addPrimaryKeyAttributeNames(FeatureStore store);
98 41212 jjdelcerro
99 44712 jjdelcerro
  public void addEssentialAttributeNames(FeatureStore store);
100 43358 jjdelcerro
101 44712 jjdelcerro
  /**
102
   * Return true if has set attribute names
103
   *
104
   * @return true if has attribute names, otherwise false
105
   */
106
  boolean hasAttributeNames();
107 43358 jjdelcerro
108 44712 jjdelcerro
  /**
109
   * Remove all the attribute names specifieds.
110
   */
111
  void clearAttributeNames();
112 41212 jjdelcerro
113 44712 jjdelcerro
  /**
114
   * Returns the names of the attributes that are constants in each
115
   * {@link Feature}. These attributes will not be charged.
116
   *
117
   * @return the attribute names that are constant
118
   */
119
  String[] getConstantsAttributeNames();
120 42975 jjdelcerro
121 44712 jjdelcerro
  /**
122
   * Set of attribute names to be treated as constants for each {@link Feature}.
123
   *
124
   * @param attributeNames the attribute names to be constants
125
   */
126
  void setConstantsAttributeNames(String[] attributeNames);
127 41212 jjdelcerro
128 44712 jjdelcerro
  /**
129
   * Add an attribute name that will be treated as constant for each
130
   * {@link Feature}.
131
   *
132
   * @param attributeName the attribute name to be treated as constant
133
   */
134
  void addConstantAttributeName(String attributeName);
135 42975 jjdelcerro
136 44712 jjdelcerro
  /**
137
   * Return true if has set constants attribute names
138
   *
139
   * @return true if has constants attribute names, otherwise false
140
   */
141
  boolean hasConstantsAttributeNames();
142 42975 jjdelcerro
143 44712 jjdelcerro
  /**
144
   * Remove all the names specified as constants attributes.
145
   */
146
  void clearConstantsAttributeNames();
147 40435 jjdelcerro
148 44712 jjdelcerro
  /**
149
   * Sets the {@link FeatureType} of the {@link Feature}s to load. It may be
150
   * used as an alternative way to set a subset of the list of attribute names
151
   * to load, by creating a sub-FeatureType.
152
   *
153
   * @param featureType the feature type of the data to load
154
   */
155
  void setFeatureType(FeatureType featureType);
156 40435 jjdelcerro
157 44712 jjdelcerro
  /**
158
   * Returns the {@link FeatureType} id of the {@link Feature}s to load.
159
   *
160
   * @return the {@link FeatureType} id of the {@link Feature}s to load
161
   */
162
  String getFeatureTypeId();
163 40435 jjdelcerro
164 44712 jjdelcerro
  /**
165
   * Sets the {@link FeatureType} id of the {@link Feature}s to load. This way
166
   * all {@link Feature} attributes will be loaded.
167
   *
168
   * @param featureTypeId the {@link FeatureType} id of the {@link Feature}s to
169
   * load
170
   */
171
  void setFeatureTypeId(String featureTypeId);
172 40435 jjdelcerro
173 44712 jjdelcerro
  /**
174
   * Returns the filter to apply to the {@link Feature}s to load.
175
   *
176
   * @return the filter
177
   */
178
  Evaluator getFilter();
179
180
  /**
181
   * Return the Expression associated to the filter.
182
   * If the current filter is not an Expression, return null.
183
   *
184
   * @return the expression of the filter.
185
   */
186
  Expression getExpressionFilter();
187 42975 jjdelcerro
188 44712 jjdelcerro
  /**
189
   * Sets the filter to apply to the {@link Feature}s to load.
190
   *
191
   * @param filter the filter to apply to the {@link Feature}s to load
192
   */
193
  void setFilter(Evaluator filter);
194 44023 jjdelcerro
195 44712 jjdelcerro
  void setFilter(Expression filter);
196 42975 jjdelcerro
197 44712 jjdelcerro
  void setFilter(String filter);
198 40435 jjdelcerro
199 44712 jjdelcerro
  /**
200
   * Adds a filter to apply to the {@link Feature}s to load. A query can have
201
   * more that one filter and all of them are applied when the query is applied.
202
   * If filter is null do nothing.
203
   *
204
   * @param filter a filter to apply to the {@link Feature}s to load
205
   */
206
  void addFilter(Evaluator filter);
207 44023 jjdelcerro
208 44712 jjdelcerro
  void addFilter(Expression filter);
209 42975 jjdelcerro
210 44712 jjdelcerro
  void addFilter(String filter);
211 40435 jjdelcerro
212 44712 jjdelcerro
  void clearFilter();
213 40435 jjdelcerro
214 44712 jjdelcerro
  /**
215
   * Returns if a filter has been defined for the query.
216
   *
217
   * @return if a filter has been defined for the query
218
   */
219
  boolean hasFilter();
220 40435 jjdelcerro
221 44712 jjdelcerro
  /**
222
   * Returns the order of the {@link Feature}s to load.
223
   *
224
   * @return the order of the {@link Feature}s to load
225
   */
226
  FeatureQueryOrder getOrder();
227 40435 jjdelcerro
228 44712 jjdelcerro
  /**
229
   * Sets the order of the {@link Feature}s to load.
230
   *
231
   * @param order the order of the {@link Feature}s to load
232
   */
233
  void setOrder(FeatureQueryOrder order);
234 40435 jjdelcerro
235 44712 jjdelcerro
  /**
236
   * Returns if an order has been set for the elements returned by the query.
237
   *
238
   * @return if an order has been set for the elements returned by the query
239
   */
240
  boolean hasOrder();
241 40435 jjdelcerro
242 44712 jjdelcerro
  /**
243
   * @return @deprecated to be removed in gvSIG 2.0
244
   * @see #clone()
245
   */
246
  FeatureQuery getCopy();
247 40435 jjdelcerro
248 44712 jjdelcerro
  /**
249
   * Returns the maximum number of elements to return with this query.
250
   * <p>
251
   * <strong>NOTE:</strong> this value may be ignored by the underlying data
252
   * source, or only used as a hint, so don't rely on it being used, as you may
253
   * actually get more values than the limit.
254
   * </p>
255
   *
256
   * @return the maximum number of elements to return with this query
257
   */
258
  long getLimit();
259 40435 jjdelcerro
260 44712 jjdelcerro
  /**
261
   * Sets the maximum number of elements to return with this query.
262
   * <p>
263
   * <strong>NOTE:</strong> this value may be ignored by the underlying data
264
   * source, or only used as a hint, so don't rely on it being used, as you may
265
   * actually get more values than the limit.
266
   * </p>
267
   *
268
   * @param limit the maximum number of elements to return with this query
269
   */
270
  void setLimit(long limit);
271
272 46456 jjdelcerro
  public void clearLimit();
273
274 44712 jjdelcerro
  /**
275
   * Returns the load page size, as the number of elements to be retrieved in
276
   * block by the data source. This value is only used as a hint to the
277
   * underlying data source, as a way to tell how many Features may be read in a
278
   * block.
279
   *
280
   * @return the load page size
281
   */
282
  long getPageSize();
283
284
  /**
285
   * Sets the load page size, as the number of elements to be retrieved in block
286
   * by the data source. This value is only used as a hint to the underlying
287
   * data source, as a way to tell how many Features may be read in a block.
288
   *
289
   * @param pageSize the load page size
290
   */
291
  void setPageSize(long pageSize);
292 46163 jjdelcerro
293
  /**
294
   * Returns true if a subquery should be used. It will only take effect
295
   * when the sql perameter of the connection has a value.
296
   * @return
297
   */
298
  public boolean isUseSubquery();
299
300
  /**
301
   * Indicates whether to use a subquery or not in case the connection has
302
   * an sql indicated. This flag will have no effect if the "sql" parameter
303
   * in the connection has not been specified.
304
   * By default it will be true and whenever an sql has been indicated in the
305
   * connection, a subquery will be used to access the data. If false is assigned,
306
   * the sql should return, in the same order, the rows required by the
307
   * FeatureType of the store.
308
   *
309
   * @param useSubquery
310
   */
311
  public void setUseSubquery(boolean useSubquery);
312 44712 jjdelcerro
313
  /**
314
   * Return the names of attributes for group the features.
315
   *
316
   * @return the list of names to group features.
317
   */
318
  public List<String> getGroupByColumns();
319
320 46251 jjdelcerro
  public void removeGroupByColumn(String colname);
321
322 44727 jjdelcerro
  public boolean isAGroupByColumn(String name);
323
324 44712 jjdelcerro
  public boolean hasGroupByColumns();
325
326
  /**
327
   * Return the aggregate functions useds for every attribute of the feature.
328
   * The map is indexed by the name of the attribute and contains the aggregate
329
   * functions used by each attribute.
330
   *
331
   * @return a Map with the aggregate function by attribute
332
   */
333
  public Map<String,String> getAggregateFunctions();
334 45425 jjdelcerro
335 46250 jjdelcerro
  public void removeAggregateFunction(String colname);
336
337 46539 fdiaz
  public String getAggregateFunction(String name);
338
339 45425 jjdelcerro
  public void addAggregate(String funcName, String columnName);
340 44712 jjdelcerro
341 45162 omartinez
  @Deprecated
342 44727 jjdelcerro
  public String getAggregate(String name);
343
344 45162 omartinez
  public String getAggregate(String tableName, String name);
345 46505 fdiaz
346
  public boolean isAggregate(String name);
347 45162 omartinez
348 44712 jjdelcerro
  public boolean hasAggregateFunctions();
349
350
  public void copyFrom(FeatureQuery query);
351 44754 omartinez
352 46501 jjdelcerro
  /**
353
  @Deprecated use getExtraColumns
354
  */
355 44829 omartinez
  public FeatureExtraColumns getExtraColumn();
356 44712 jjdelcerro
357 46501 jjdelcerro
  /**
358
   * Extra local columns to the query. It will never be null.
359
   *
360
   * @return
361
   */
362
  public FeatureExtraColumns getExtraColumns();
363
364 46010 jjdelcerro
  public MutableSymbolTable getSymbolTable();
365
366
  public void setSymbolTable(MutableSymbolTable symbolTable);
367
368
  /**
369
   * Set a variable in the symbol table associated to this searchPanel.
370
   *
371
   * @param name
372
   * @param value
373
   */
374
  public void setVar(String name, Object value);
375
376 46277 jjdelcerro
  public boolean hasLimit();
377 44712 jjdelcerro
}