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 @ 46277
History | View | Annotate | Download (10.6 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 |
/**
|
72 |
* Returns the names of the attributes to load from each {@link Feature}.
|
73 |
*
|
74 |
* @return the attribute names to load
|
75 |
*/
|
76 |
String[] getAttributeNames(); |
77 |
|
78 |
/**
|
79 |
* Sets the names of the attributes to load from each {@link Feature}.
|
80 |
*
|
81 |
* @param attributeNames the attribute names to load
|
82 |
*/
|
83 |
void setAttributeNames(String[] attributeNames); |
84 |
|
85 |
void retrievesAllAttributes();
|
86 |
|
87 |
/**
|
88 |
* Adds the name of an attribute that has to be used to load each
|
89 |
* {@link Feature}.
|
90 |
*
|
91 |
* @param attributeName the attribute name to load
|
92 |
*/
|
93 |
void addAttributeName(String attributeName); |
94 |
|
95 |
public void addPrimaryKeyAttributeNames(FeatureStore store); |
96 |
|
97 |
public void addEssentialAttributeNames(FeatureStore store); |
98 |
|
99 |
/**
|
100 |
* Return true if has set attribute names
|
101 |
*
|
102 |
* @return true if has attribute names, otherwise false
|
103 |
*/
|
104 |
boolean hasAttributeNames();
|
105 |
|
106 |
/**
|
107 |
* Remove all the attribute names specifieds.
|
108 |
*/
|
109 |
void clearAttributeNames();
|
110 |
|
111 |
/**
|
112 |
* Returns the names of the attributes that are constants in each
|
113 |
* {@link Feature}. These attributes will not be charged.
|
114 |
*
|
115 |
* @return the attribute names that are constant
|
116 |
*/
|
117 |
String[] getConstantsAttributeNames(); |
118 |
|
119 |
/**
|
120 |
* Set of attribute names to be treated as constants for each {@link Feature}.
|
121 |
*
|
122 |
* @param attributeNames the attribute names to be constants
|
123 |
*/
|
124 |
void setConstantsAttributeNames(String[] attributeNames); |
125 |
|
126 |
/**
|
127 |
* Add an attribute name that will be treated as constant for each
|
128 |
* {@link Feature}.
|
129 |
*
|
130 |
* @param attributeName the attribute name to be treated as constant
|
131 |
*/
|
132 |
void addConstantAttributeName(String attributeName); |
133 |
|
134 |
/**
|
135 |
* Return true if has set constants attribute names
|
136 |
*
|
137 |
* @return true if has constants attribute names, otherwise false
|
138 |
*/
|
139 |
boolean hasConstantsAttributeNames();
|
140 |
|
141 |
/**
|
142 |
* Remove all the names specified as constants attributes.
|
143 |
*/
|
144 |
void clearConstantsAttributeNames();
|
145 |
|
146 |
/**
|
147 |
* Sets the {@link FeatureType} of the {@link Feature}s to load. It may be
|
148 |
* used as an alternative way to set a subset of the list of attribute names
|
149 |
* to load, by creating a sub-FeatureType.
|
150 |
*
|
151 |
* @param featureType the feature type of the data to load
|
152 |
*/
|
153 |
void setFeatureType(FeatureType featureType);
|
154 |
|
155 |
/**
|
156 |
* Returns the {@link FeatureType} id of the {@link Feature}s to load.
|
157 |
*
|
158 |
* @return the {@link FeatureType} id of the {@link Feature}s to load
|
159 |
*/
|
160 |
String getFeatureTypeId();
|
161 |
|
162 |
/**
|
163 |
* Sets the {@link FeatureType} id of the {@link Feature}s to load. This way
|
164 |
* all {@link Feature} attributes will be loaded.
|
165 |
*
|
166 |
* @param featureTypeId the {@link FeatureType} id of the {@link Feature}s to
|
167 |
* load
|
168 |
*/
|
169 |
void setFeatureTypeId(String featureTypeId); |
170 |
|
171 |
/**
|
172 |
* Returns the filter to apply to the {@link Feature}s to load.
|
173 |
*
|
174 |
* @return the filter
|
175 |
*/
|
176 |
Evaluator getFilter(); |
177 |
|
178 |
/**
|
179 |
* Return the Expression associated to the filter.
|
180 |
* If the current filter is not an Expression, return null.
|
181 |
*
|
182 |
* @return the expression of the filter.
|
183 |
*/
|
184 |
Expression getExpressionFilter();
|
185 |
|
186 |
/**
|
187 |
* Sets the filter to apply to the {@link Feature}s to load.
|
188 |
*
|
189 |
* @param filter the filter to apply to the {@link Feature}s to load
|
190 |
*/
|
191 |
void setFilter(Evaluator filter);
|
192 |
|
193 |
void setFilter(Expression filter); |
194 |
|
195 |
void setFilter(String filter); |
196 |
|
197 |
/**
|
198 |
* Adds a filter to apply to the {@link Feature}s to load. A query can have
|
199 |
* more that one filter and all of them are applied when the query is applied.
|
200 |
* If filter is null do nothing.
|
201 |
*
|
202 |
* @param filter a filter to apply to the {@link Feature}s to load
|
203 |
*/
|
204 |
void addFilter(Evaluator filter);
|
205 |
|
206 |
void addFilter(Expression filter); |
207 |
|
208 |
void addFilter(String filter); |
209 |
|
210 |
void clearFilter();
|
211 |
|
212 |
/**
|
213 |
* Returns if a filter has been defined for the query.
|
214 |
*
|
215 |
* @return if a filter has been defined for the query
|
216 |
*/
|
217 |
boolean hasFilter();
|
218 |
|
219 |
/**
|
220 |
* Returns the order of the {@link Feature}s to load.
|
221 |
*
|
222 |
* @return the order of the {@link Feature}s to load
|
223 |
*/
|
224 |
FeatureQueryOrder getOrder(); |
225 |
|
226 |
/**
|
227 |
* Sets the order of the {@link Feature}s to load.
|
228 |
*
|
229 |
* @param order the order of the {@link Feature}s to load
|
230 |
*/
|
231 |
void setOrder(FeatureQueryOrder order);
|
232 |
|
233 |
/**
|
234 |
* Returns if an order has been set for the elements returned by the query.
|
235 |
*
|
236 |
* @return if an order has been set for the elements returned by the query
|
237 |
*/
|
238 |
boolean hasOrder();
|
239 |
|
240 |
/**
|
241 |
* @return @deprecated to be removed in gvSIG 2.0
|
242 |
* @see #clone()
|
243 |
*/
|
244 |
FeatureQuery getCopy(); |
245 |
|
246 |
/**
|
247 |
* Returns the maximum number of elements to return with this query.
|
248 |
* <p>
|
249 |
* <strong>NOTE:</strong> this value may be ignored by the underlying data
|
250 |
* source, or only used as a hint, so don't rely on it being used, as you may
|
251 |
* actually get more values than the limit.
|
252 |
* </p>
|
253 |
*
|
254 |
* @return the maximum number of elements to return with this query
|
255 |
*/
|
256 |
long getLimit();
|
257 |
|
258 |
/**
|
259 |
* Sets the maximum number of elements to return with this query.
|
260 |
* <p>
|
261 |
* <strong>NOTE:</strong> this value may be ignored by the underlying data
|
262 |
* source, or only used as a hint, so don't rely on it being used, as you may
|
263 |
* actually get more values than the limit.
|
264 |
* </p>
|
265 |
*
|
266 |
* @param limit the maximum number of elements to return with this query
|
267 |
*/
|
268 |
void setLimit(long limit); |
269 |
|
270 |
/**
|
271 |
* Returns the load page size, as the number of elements to be retrieved in
|
272 |
* block by the data source. This value is only used as a hint to the
|
273 |
* underlying data source, as a way to tell how many Features may be read in a
|
274 |
* block.
|
275 |
*
|
276 |
* @return the load page size
|
277 |
*/
|
278 |
long getPageSize();
|
279 |
|
280 |
/**
|
281 |
* Sets the load page size, as the number of elements to be retrieved in block
|
282 |
* by the data source. This value is only used as a hint to the underlying
|
283 |
* data source, as a way to tell how many Features may be read in a block.
|
284 |
*
|
285 |
* @param pageSize the load page size
|
286 |
*/
|
287 |
void setPageSize(long pageSize); |
288 |
|
289 |
/**
|
290 |
* Returns true if a subquery should be used. It will only take effect
|
291 |
* when the sql perameter of the connection has a value.
|
292 |
* @return
|
293 |
*/
|
294 |
public boolean isUseSubquery(); |
295 |
|
296 |
/**
|
297 |
* Indicates whether to use a subquery or not in case the connection has
|
298 |
* an sql indicated. This flag will have no effect if the "sql" parameter
|
299 |
* in the connection has not been specified.
|
300 |
* By default it will be true and whenever an sql has been indicated in the
|
301 |
* connection, a subquery will be used to access the data. If false is assigned,
|
302 |
* the sql should return, in the same order, the rows required by the
|
303 |
* FeatureType of the store.
|
304 |
*
|
305 |
* @param useSubquery
|
306 |
*/
|
307 |
public void setUseSubquery(boolean useSubquery); |
308 |
|
309 |
/**
|
310 |
* Return the names of attributes for group the features.
|
311 |
*
|
312 |
* @return the list of names to group features.
|
313 |
*/
|
314 |
public List<String> getGroupByColumns(); |
315 |
|
316 |
public void removeGroupByColumn(String colname); |
317 |
|
318 |
public boolean isAGroupByColumn(String name); |
319 |
|
320 |
public boolean hasGroupByColumns(); |
321 |
|
322 |
/**
|
323 |
* Return the aggregate functions useds for every attribute of the feature.
|
324 |
* The map is indexed by the name of the attribute and contains the aggregate
|
325 |
* functions used by each attribute.
|
326 |
*
|
327 |
* @return a Map with the aggregate function by attribute
|
328 |
*/
|
329 |
public Map<String,String> getAggregateFunctions(); |
330 |
|
331 |
public void removeAggregateFunction(String colname); |
332 |
|
333 |
public void addAggregate(String funcName, String columnName); |
334 |
|
335 |
@Deprecated
|
336 |
public String getAggregate(String name); |
337 |
|
338 |
public String getAggregate(String tableName, String name); |
339 |
|
340 |
public boolean hasAggregateFunctions(); |
341 |
|
342 |
public void copyFrom(FeatureQuery query); |
343 |
|
344 |
public FeatureExtraColumns getExtraColumn();
|
345 |
|
346 |
public MutableSymbolTable getSymbolTable();
|
347 |
|
348 |
public void setSymbolTable(MutableSymbolTable symbolTable); |
349 |
|
350 |
/**
|
351 |
* Set a variable in the symbol table associated to this searchPanel.
|
352 |
*
|
353 |
* @param name
|
354 |
* @param value
|
355 |
*/
|
356 |
public void setVar(String name, Object value); |
357 |
|
358 |
public boolean hasLimit(); |
359 |
} |