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

History | View | Annotate | Download (10.9 KB)

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
/*
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
import java.util.List;
31
import java.util.Map;
32
import org.gvsig.expressionevaluator.Expression;
33
import org.gvsig.expressionevaluator.MutableSymbolTable;
34
import org.gvsig.expressionevaluator.SymbolTable;
35
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
 *
67
 * @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team
68
 */
69
public interface FeatureQuery extends DataQuery, Cloneable {
70

    
71
    public static final int NO_LIMIT = -1;
72
    
73
  /**
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

    
80
  /**
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

    
87
  void retrievesAllAttributes();
88

    
89
  /**
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

    
97
  public void addPrimaryKeyAttributeNames(FeatureStore store);
98

    
99
  public void addEssentialAttributeNames(FeatureStore store);
100

    
101
  /**
102
   * Return true if has set attribute names
103
   *
104
   * @return true if has attribute names, otherwise false
105
   */
106
  boolean hasAttributeNames();
107

    
108
  /**
109
   * Remove all the attribute names specifieds.
110
   */
111
  void clearAttributeNames();
112

    
113
  /**
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

    
121
  /**
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

    
128
  /**
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

    
136
  /**
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

    
143
  /**
144
   * Remove all the names specified as constants attributes.
145
   */
146
  void clearConstantsAttributeNames();
147

    
148
  /**
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

    
157
  /**
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

    
164
  /**
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

    
173
  /**
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

    
188
  /**
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

    
195
  void setFilter(Expression filter);
196

    
197
  void setFilter(String filter);
198

    
199
  /**
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

    
208
  void addFilter(Expression filter);
209

    
210
  void addFilter(String filter);
211

    
212
  void clearFilter();
213

    
214
  /**
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

    
221
  /**
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

    
228
  /**
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

    
235
  /**
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

    
242
  /**
243
   * @return @deprecated to be removed in gvSIG 2.0
244
   * @see #clone()
245
   */
246
  FeatureQuery getCopy();
247

    
248
  /**
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

    
260
  /**
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
  public void clearLimit();
273
  
274
  /**
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
  
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

    
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
  public void removeGroupByColumn(String colname);
321
  
322
  public boolean isAGroupByColumn(String name);
323
  
324
  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
  
335
  public void removeAggregateFunction(String colname);
336
  
337
  public void addAggregate(String funcName, String columnName);
338

    
339
  @Deprecated
340
  public String getAggregate(String name);
341
  
342
  public String getAggregate(String tableName, String name);
343

    
344
  public boolean isAggregate(String name);
345
  
346
  public boolean hasAggregateFunctions();
347

    
348
  public void copyFrom(FeatureQuery query);
349
      
350
  /**
351
  @Deprecated use getExtraColumns
352
  */
353
  public FeatureExtraColumns getExtraColumn();
354

    
355
  /** 
356
   * Extra local columns to the query. It will never be null.
357
   * 
358
   * @return 
359
   */
360
  public FeatureExtraColumns getExtraColumns();
361

    
362
  public MutableSymbolTable getSymbolTable();
363
  
364
  public void setSymbolTable(MutableSymbolTable symbolTable);
365
    
366
  /**
367
   * Set a variable in the symbol table associated to this searchPanel.
368
   * 
369
   * @param name
370
   * @param value 
371
   */
372
  public void setVar(String name, Object value);
373
  
374
  public boolean hasLimit();
375
}