svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.impl / src / main / java / org / gvsig / fmap / dal / feature / impl / DefaultFeatureQuery.java @ 43358
History | View | Annotate | Download (18.2 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 | package org.gvsig.fmap.dal.feature.impl; |
||
25 | |||
26 | import java.util.ArrayList; |
||
27 | import java.util.HashMap; |
||
28 | import java.util.List; |
||
29 | import java.util.Map; |
||
30 | 42971 | jjdelcerro | import java.util.logging.Level; |
31 | import java.util.logging.Logger; |
||
32 | 43358 | jjdelcerro | import org.apache.commons.lang3.ArrayUtils; |
33 | 42971 | jjdelcerro | import org.gvsig.fmap.dal.DALLocator; |
34 | 43358 | jjdelcerro | import org.gvsig.fmap.dal.DataTypes; |
35 | import org.gvsig.fmap.dal.exception.DataException; |
||
36 | 42971 | jjdelcerro | import org.gvsig.fmap.dal.exception.InitializeException; |
37 | 43358 | jjdelcerro | import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
38 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.feature.FeatureQuery; |
39 | import org.gvsig.fmap.dal.feature.FeatureQueryOrder; |
||
40 | 43358 | jjdelcerro | import org.gvsig.fmap.dal.feature.FeatureStore; |
41 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.feature.FeatureType; |
42 | import org.gvsig.tools.ToolsLocator; |
||
43 | import org.gvsig.tools.dynobject.DynStruct; |
||
44 | import org.gvsig.tools.evaluator.AndEvaluator; |
||
45 | import org.gvsig.tools.evaluator.Evaluator; |
||
46 | import org.gvsig.tools.evaluator.EvaluatorFieldsInfo; |
||
47 | import org.gvsig.tools.persistence.PersistentState; |
||
48 | import org.gvsig.tools.persistence.exception.PersistenceException; |
||
49 | |||
50 | /**
|
||
51 | * Defines the properties of a collection of Features, as a result of a query
|
||
52 | * through a FeatureStore.
|
||
53 | * <p>
|
||
54 | * A FeatureQuery is always defined by a FeatureType, or by the list of
|
||
55 | * attribute names of the FeatureStore to return.
|
||
56 | * </p>
|
||
57 | * <p>
|
||
58 | * The filter allows to select Features whose properties have values with the
|
||
59 | * characteristics defined by the filter.
|
||
60 | * </p>
|
||
61 | * <p>
|
||
62 | * The order is used to set the order of the result FeatureCollection, based on
|
||
63 | * the values of the properties of the Features.
|
||
64 | * </p>
|
||
65 | * <p>
|
||
66 | * The scale parameter can be used by the FeatureStore as a hint about the
|
||
67 | * quality or resolution of the data needed to view or operate with the data
|
||
68 | * returned. As an example, the FeatureStore may use the scale to return only a
|
||
69 | * representative subset of the data, or maybe to return Features with less
|
||
70 | * detail, like a point or a line instead of a polygon.
|
||
71 | * </p>
|
||
72 | * <p>
|
||
73 | * If an implementation of FeatureStore is able to get other parameters to
|
||
74 | * customize the behavior of the getDataCollection methods, there is an option
|
||
75 | * to set more parameters through the setAttribute method.
|
||
76 | * </p>
|
||
77 | 42975 | jjdelcerro | *
|
78 | 40435 | jjdelcerro | * @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team
|
79 | */
|
||
80 | public class DefaultFeatureQuery implements FeatureQuery { |
||
81 | |||
82 | public static final String SCALE_PARAM_NAME = "Scale"; |
||
83 | |||
84 | private Map queryParameters = new HashMap(); |
||
85 | |||
86 | private String featureTypeId = null; |
||
87 | |||
88 | private List attributeNames = new ArrayList(); |
||
89 | |||
90 | 41212 | jjdelcerro | private List constantsAttributeNames = new ArrayList(); |
91 | |||
92 | 40435 | jjdelcerro | private Evaluator filter;
|
93 | |||
94 | /**
|
||
95 | * This boolean value is used to know if the current filter
|
||
96 | * has been added using the {@link FeatureQuery#addFilter(Evaluator)}
|
||
97 | * method or the {@link FeatureQuery#setFilter(Evaluator)} method.
|
||
98 | */
|
||
99 | 42798 | jjdelcerro | // private boolean isAddFilter = true;
|
100 | 40435 | jjdelcerro | |
101 | private FeatureQueryOrder order = new FeatureQueryOrder(); |
||
102 | |||
103 | private long limit; |
||
104 | |||
105 | private long pageSize; |
||
106 | |||
107 | /**
|
||
108 | * Creates a FeatureQuery which will load all available Features of a type.
|
||
109 | 42975 | jjdelcerro | *
|
110 | 40435 | jjdelcerro | */
|
111 | public DefaultFeatureQuery() {
|
||
112 | super();
|
||
113 | } |
||
114 | |||
115 | /**
|
||
116 | * Creates a FeatureQuery which will load all available Features of a type.
|
||
117 | 42975 | jjdelcerro | *
|
118 | 40435 | jjdelcerro | * @param featureType
|
119 | * the type of Features of the query
|
||
120 | */
|
||
121 | public DefaultFeatureQuery(FeatureType featureType) {
|
||
122 | super();
|
||
123 | this.setFeatureType(featureType);
|
||
124 | } |
||
125 | |||
126 | /**
|
||
127 | * Creates a FeatureQuery with the type of features, a filter and the order
|
||
128 | * for the FeatureCollection.
|
||
129 | 42975 | jjdelcerro | *
|
130 | 40435 | jjdelcerro | * @param featureType
|
131 | * the type of Features of the query
|
||
132 | * @param filter
|
||
133 | * based on the properties of the Features
|
||
134 | */
|
||
135 | public DefaultFeatureQuery(FeatureType featureType, Evaluator filter) {
|
||
136 | super();
|
||
137 | this.setFeatureType(featureType);
|
||
138 | this.filter = filter;
|
||
139 | } |
||
140 | |||
141 | /**
|
||
142 | * Creates a FeatureQuery with the type of features, a filter, the order for
|
||
143 | * the FeatureCollection and the view scale.
|
||
144 | 42975 | jjdelcerro | *
|
145 | 40435 | jjdelcerro | * @param featureType
|
146 | * the type of Features of the query
|
||
147 | * @param filter
|
||
148 | * based on the properties of the Features
|
||
149 | * @param scale
|
||
150 | * to view the Features.
|
||
151 | */
|
||
152 | public DefaultFeatureQuery(FeatureType featureType, Evaluator filter,
|
||
153 | double scale) {
|
||
154 | this.setFeatureType(featureType);
|
||
155 | this.filter = filter;
|
||
156 | this.setScale(scale);
|
||
157 | } |
||
158 | |||
159 | /**
|
||
160 | * Creates a FeatureQuery which will load a list of attribute names of all
|
||
161 | * available Features.
|
||
162 | 42975 | jjdelcerro | *
|
163 | 40435 | jjdelcerro | * @param attributeNames
|
164 | * the list of attribute names to load
|
||
165 | */
|
||
166 | public DefaultFeatureQuery(String[] attributeNames) { |
||
167 | super();
|
||
168 | setAttributeNames(attributeNames); |
||
169 | } |
||
170 | |||
171 | /**
|
||
172 | * Creates a FeatureQuery with the list of attribute names of feature, a
|
||
173 | * filter and the order for the FeatureCollection.
|
||
174 | 42975 | jjdelcerro | *
|
175 | 40435 | jjdelcerro | * @param attributeNames
|
176 | * the list of attribute names to load
|
||
177 | * @param filter
|
||
178 | * based on the properties of the Features
|
||
179 | */
|
||
180 | public DefaultFeatureQuery(String[] attributeNames, Evaluator filter) { |
||
181 | super();
|
||
182 | setAttributeNames(attributeNames); |
||
183 | this.filter = filter;
|
||
184 | } |
||
185 | |||
186 | /**
|
||
187 | * Creates a FeatureQuery with the list of attribute names of feature, a
|
||
188 | * filter, the order for the FeatureCollection and the view scale.
|
||
189 | 42975 | jjdelcerro | *
|
190 | 40435 | jjdelcerro | * @param attributeNames
|
191 | * the list of attribute names to load
|
||
192 | * @param filter
|
||
193 | * based on the properties of the Features
|
||
194 | * @param scale
|
||
195 | * to view the Features.
|
||
196 | */
|
||
197 | public DefaultFeatureQuery(String[] attributeNames, Evaluator filter, |
||
198 | double scale) {
|
||
199 | setAttributeNames(attributeNames); |
||
200 | this.filter = filter;
|
||
201 | this.setScale(scale);
|
||
202 | } |
||
203 | |||
204 | 43358 | jjdelcerro | @Override
|
205 | 40435 | jjdelcerro | public double getScale() { |
206 | Double scale = (Double) this.getQueryParameter(SCALE_PARAM_NAME); |
||
207 | if (scale == null) { |
||
208 | return 0; |
||
209 | } |
||
210 | 43358 | jjdelcerro | return scale;
|
211 | 40435 | jjdelcerro | } |
212 | |||
213 | 43358 | jjdelcerro | @Override
|
214 | 40435 | jjdelcerro | public void setScale(double scale) { |
215 | 43358 | jjdelcerro | this.setQueryParameter(SCALE_PARAM_NAME, scale);
|
216 | 40435 | jjdelcerro | } |
217 | |||
218 | 43358 | jjdelcerro | @Override
|
219 | 40435 | jjdelcerro | public Object getQueryParameter(String name) { |
220 | return queryParameters.get(name);
|
||
221 | } |
||
222 | |||
223 | 43358 | jjdelcerro | @Override
|
224 | 40435 | jjdelcerro | public void setQueryParameter(String name, Object value) { |
225 | queryParameters.put(name, value); |
||
226 | } |
||
227 | |||
228 | 43358 | jjdelcerro | @Override
|
229 | 40435 | jjdelcerro | public void setFeatureType(FeatureType featureType) { |
230 | this.featureTypeId = featureType.getId();
|
||
231 | } |
||
232 | |||
233 | 43358 | jjdelcerro | @Override
|
234 | 40435 | jjdelcerro | public String[] getAttributeNames() { |
235 | return (String[])attributeNames.toArray(new String[attributeNames.size()]); |
||
236 | } |
||
237 | |||
238 | 43358 | jjdelcerro | @Override
|
239 | 40435 | jjdelcerro | public void setAttributeNames(String[] attributeNames) { |
240 | this.attributeNames.clear();
|
||
241 | if (attributeNames != null){ |
||
242 | for (int i=0 ; i<attributeNames.length ; i++){ |
||
243 | this.attributeNames.add(attributeNames[i]);
|
||
244 | 42975 | jjdelcerro | } |
245 | 40435 | jjdelcerro | } |
246 | } |
||
247 | 42975 | jjdelcerro | |
248 | 43358 | jjdelcerro | @Override
|
249 | 40435 | jjdelcerro | public void addAttributeName(String attributeName){ |
250 | //If the attribute exists finish the method
|
||
251 | for (int i=0 ; i<attributeNames.size() ; i++){ |
||
252 | if (attributeNames.get(i).equals(attributeName)){
|
||
253 | return;
|
||
254 | 42975 | jjdelcerro | } |
255 | } |
||
256 | 40435 | jjdelcerro | this.attributeNames.add(attributeName);
|
257 | } |
||
258 | |||
259 | 43358 | jjdelcerro | @Override
|
260 | public void addEssentialAttributeNames(FeatureStore store) { |
||
261 | FeatureType storeType; |
||
262 | try {
|
||
263 | storeType = store.getDefaultFeatureType(); |
||
264 | } catch (DataException ex) {
|
||
265 | throw new RuntimeException("Can't access to the default feature type of tghe store", ex); |
||
266 | } |
||
267 | FeatureAttributeDescriptor[] pks = storeType.getPrimaryKey();
|
||
268 | if( storeType.hasOID() || ArrayUtils.isEmpty(pks) ) {
|
||
269 | FeatureAttributeDescriptor attrInt = null;
|
||
270 | FeatureAttributeDescriptor attrStr = null;
|
||
271 | FeatureAttributeDescriptor attrNotGeom = null;
|
||
272 | for (FeatureAttributeDescriptor attr : storeType) {
|
||
273 | if( attrInt == null && (attr.getType()==DataTypes.INT || attr.getType()==DataTypes.LONG) ) { |
||
274 | attrInt = attr; |
||
275 | } else if( attrStr == null && attr.getType()==DataTypes.STRING ) { |
||
276 | attrStr = attr; |
||
277 | } else if( attrNotGeom == null && attr.getType()!=DataTypes.GEOMETRY ) { |
||
278 | attrNotGeom = attr; |
||
279 | } |
||
280 | } |
||
281 | if( attrInt != null ) { |
||
282 | this.addAttributeName(attrInt.getName());
|
||
283 | } else if( attrStr != null ) { |
||
284 | this.addAttributeName(attrStr.getName());
|
||
285 | } else if( attrNotGeom != null ) { |
||
286 | this.addAttributeName(attrNotGeom.getName());
|
||
287 | } else {
|
||
288 | this.addAttributeName(storeType.getAttributeDescriptor(0).getName()); |
||
289 | } |
||
290 | } else {
|
||
291 | for(FeatureAttributeDescriptor attr : pks ) {
|
||
292 | this.addAttributeName(attr.getName());
|
||
293 | } |
||
294 | } |
||
295 | } |
||
296 | |||
297 | @Override
|
||
298 | public void addPrimaryKeyAttributeNames(FeatureStore store) { |
||
299 | FeatureType storeType; |
||
300 | try {
|
||
301 | storeType = store.getDefaultFeatureType(); |
||
302 | } catch (DataException ex) {
|
||
303 | throw new RuntimeException("Can't access to the default feature type of tghe store", ex); |
||
304 | } |
||
305 | for(FeatureAttributeDescriptor attr : storeType.getPrimaryKey() ) {
|
||
306 | this.addAttributeName(attr.getName());
|
||
307 | } |
||
308 | } |
||
309 | |||
310 | @Override
|
||
311 | 41212 | jjdelcerro | public boolean hasAttributeNames() { |
312 | return !this.attributeNames.isEmpty(); |
||
313 | } |
||
314 | |||
315 | 43358 | jjdelcerro | @Override
|
316 | 41212 | jjdelcerro | public void clearAttributeNames() { |
317 | this.attributeNames = new ArrayList(); |
||
318 | } |
||
319 | |||
320 | 43358 | jjdelcerro | @Override
|
321 | 40435 | jjdelcerro | public Evaluator getFilter() {
|
322 | return filter;
|
||
323 | } |
||
324 | 42975 | jjdelcerro | |
325 | 42971 | jjdelcerro | @Override
|
326 | public void setFilter(String filter) { |
||
327 | try {
|
||
328 | this.setFilter(DALLocator.getDataManager().createExpresion(filter));
|
||
329 | } catch (Exception ex) { |
||
330 | throw new RuntimeException("Can't create filter from '"+filter+"'",ex); |
||
331 | } |
||
332 | } |
||
333 | 40435 | jjdelcerro | |
334 | 43358 | jjdelcerro | @Override
|
335 | 40435 | jjdelcerro | public void setFilter(Evaluator filter) { |
336 | this.filter = filter;
|
||
337 | addFilterAttributes(filter); |
||
338 | 42798 | jjdelcerro | // isAddFilter = false;
|
339 | 40435 | jjdelcerro | } |
340 | |||
341 | 42795 | jjdelcerro | @Override
|
342 | 42971 | jjdelcerro | public void addFilter(String filter) { |
343 | try {
|
||
344 | this.addFilter(DALLocator.getDataManager().createExpresion(filter));
|
||
345 | } catch (Exception ex) { |
||
346 | throw new RuntimeException("Can't create filter from '"+filter+"'",ex); |
||
347 | } |
||
348 | } |
||
349 | 42975 | jjdelcerro | |
350 | 42971 | jjdelcerro | @Override
|
351 | 40435 | jjdelcerro | public void addFilter(Evaluator evaluator) { |
352 | 42795 | jjdelcerro | if( evaluator == null ) { |
353 | return;
|
||
354 | } |
||
355 | 42798 | jjdelcerro | // if (isAddFilter){
|
356 | 40435 | jjdelcerro | if (this.filter == null){ |
357 | this.filter = evaluator;
|
||
358 | }else{
|
||
359 | if (evaluator != null){ |
||
360 | if (this.filter instanceof AndEvaluator){ |
||
361 | ((AndEvaluator)this.filter).addEvaluator(evaluator);
|
||
362 | }else{
|
||
363 | this.filter = new AndEvaluator(this.filter); |
||
364 | ((AndEvaluator)this.filter).addEvaluator(evaluator);
|
||
365 | } |
||
366 | } |
||
367 | } |
||
368 | 42798 | jjdelcerro | // }else{
|
369 | // this.filter = evaluator;
|
||
370 | // }
|
||
371 | 40435 | jjdelcerro | addFilterAttributes(evaluator); |
372 | 42798 | jjdelcerro | // isAddFilter = true;
|
373 | 40435 | jjdelcerro | } |
374 | 42975 | jjdelcerro | |
375 | 43358 | jjdelcerro | @Override
|
376 | 42975 | jjdelcerro | public void clearFilter() { |
377 | this.filter = null; |
||
378 | } |
||
379 | |||
380 | 40435 | jjdelcerro | private void addFilterAttributes(Evaluator evaluator){ |
381 | if (evaluator != null){ |
||
382 | EvaluatorFieldsInfo fieldsInfo = evaluator.getFieldsInfo(); |
||
383 | if (fieldsInfo == null){ |
||
384 | // FieldsInfo is not available in this evaluator
|
||
385 | return;
|
||
386 | } |
||
387 | String[] fieldNames = fieldsInfo.getFieldNames(); |
||
388 | if (fieldNames== null){ |
||
389 | // fieldNames is not available in this evaluator
|
||
390 | return;
|
||
391 | } |
||
392 | 42975 | jjdelcerro | |
393 | 40435 | jjdelcerro | for (int i=0 ; i<fieldNames.length ; i++){ |
394 | addAttributeName(fieldNames[i]); |
||
395 | } |
||
396 | } |
||
397 | } |
||
398 | |||
399 | 43358 | jjdelcerro | @Override
|
400 | 40435 | jjdelcerro | public FeatureQueryOrder getOrder() {
|
401 | return order;
|
||
402 | } |
||
403 | |||
404 | 43358 | jjdelcerro | @Override
|
405 | 40435 | jjdelcerro | public void setOrder(FeatureQueryOrder order) { |
406 | this.order = order;
|
||
407 | } |
||
408 | |||
409 | 43358 | jjdelcerro | @Override
|
410 | 40435 | jjdelcerro | public boolean hasFilter() { |
411 | return this.filter != null; |
||
412 | } |
||
413 | |||
414 | 43358 | jjdelcerro | @Override
|
415 | 40435 | jjdelcerro | public boolean hasOrder() { |
416 | return this.order != null && this.order.size() > 0; |
||
417 | } |
||
418 | |||
419 | 43358 | jjdelcerro | @Override
|
420 | 40435 | jjdelcerro | public Object clone() throws CloneNotSupportedException { |
421 | DefaultFeatureQuery clone = (DefaultFeatureQuery) super.clone();
|
||
422 | |||
423 | // Clone attribute names array
|
||
424 | if (attributeNames != null) { |
||
425 | clone.attributeNames = new ArrayList(); |
||
426 | for (int i=0 ; i<attributeNames.size() ; i++){ |
||
427 | clone.attributeNames.add(attributeNames.get(i)); |
||
428 | 42975 | jjdelcerro | } |
429 | 40435 | jjdelcerro | } |
430 | |||
431 | // Clone order
|
||
432 | if (order != null) { |
||
433 | clone.order = (FeatureQueryOrder) order.clone(); |
||
434 | } |
||
435 | |||
436 | return clone;
|
||
437 | } |
||
438 | |||
439 | 43358 | jjdelcerro | @Override
|
440 | 40435 | jjdelcerro | public FeatureQuery getCopy() {
|
441 | try {
|
||
442 | return (FeatureQuery) clone();
|
||
443 | } catch (CloneNotSupportedException e) { |
||
444 | // TODO Auto-generated catch block
|
||
445 | e.printStackTrace(); |
||
446 | return null; |
||
447 | } |
||
448 | // DefaultFeatureQuery aCopy = new DefaultFeatureQuery();
|
||
449 | //
|
||
450 | // aCopy.featureTypeId = this.featureTypeId;
|
||
451 | //
|
||
452 | // if (this.attributeNames != null) {
|
||
453 | // aCopy.attributeNames = (String[]) Arrays
|
||
454 | // .asList(this.attributeNames).toArray(new String[0]);
|
||
455 | // }
|
||
456 | //
|
||
457 | // aCopy.filter = this.filter;
|
||
458 | //
|
||
459 | // if (this.order != null) {
|
||
460 | // aCopy.order = this.order.getCopy();
|
||
461 | // }
|
||
462 | //
|
||
463 | // return aCopy;
|
||
464 | } |
||
465 | |||
466 | 43358 | jjdelcerro | @Override
|
467 | 40435 | jjdelcerro | public String getFeatureTypeId() { |
468 | return featureTypeId;
|
||
469 | } |
||
470 | |||
471 | 43358 | jjdelcerro | @Override
|
472 | 40435 | jjdelcerro | public void setFeatureTypeId(String featureTypeId) { |
473 | this.featureTypeId = featureTypeId;
|
||
474 | } |
||
475 | |||
476 | 43358 | jjdelcerro | @Override
|
477 | 40435 | jjdelcerro | public void saveToState(PersistentState state) throws PersistenceException { |
478 | // FIXME: falta por terminar de implementar
|
||
479 | state.set("queryParameters", this.queryParameters); |
||
480 | state.set("featureTypeId", this.featureTypeId); |
||
481 | state.set("attributeNames", this.attributeNames); |
||
482 | // state.set("filter", this.filter);
|
||
483 | state.set("limit", this.limit); |
||
484 | state.set("pageSize", this.pageSize); |
||
485 | |||
486 | } |
||
487 | |||
488 | 43358 | jjdelcerro | @Override
|
489 | 40435 | jjdelcerro | public void loadFromState(PersistentState state) throws PersistenceException { |
490 | // FIXME: falta por terminar de implementar
|
||
491 | this.queryParameters = (Map) state.get("queryParameters"); |
||
492 | this.featureTypeId = state.getString("featureTypeId"); |
||
493 | this.attributeNames = state.getList("attributeNames"); |
||
494 | this.filter = (Evaluator) state.get("filter"); |
||
495 | this.limit = state.getLong("limit"); |
||
496 | this.pageSize = state.getLong("pageSize"); |
||
497 | |||
498 | } |
||
499 | |||
500 | /**
|
||
501 | * Register the class on PersistenceManager
|
||
502 | 42975 | jjdelcerro | *
|
503 | 40435 | jjdelcerro | */
|
504 | public static void registerPersistent() { |
||
505 | DynStruct definition = |
||
506 | ToolsLocator.getPersistenceManager() |
||
507 | .addDefinition(DefaultFeatureQuery.class, |
||
508 | "DefaultFeatureQuery",
|
||
509 | "DefaultFeatureQuery Persistent definition",
|
||
510 | null,
|
||
511 | null);
|
||
512 | |||
513 | definition.addDynFieldMap("queryParameters")
|
||
514 | .setClassOfItems(Object.class)
|
||
515 | .setMandatory(true);
|
||
516 | |||
517 | definition.addDynFieldString("featureTypeId").setMandatory(false); |
||
518 | |||
519 | definition.addDynFieldList("attributeNames")
|
||
520 | .setClassOfItems(String.class)
|
||
521 | .setMandatory(false);
|
||
522 | |||
523 | definition.addDynFieldObject("filter")
|
||
524 | .setClassOfValue(Evaluator.class) |
||
525 | .setMandatory(false);
|
||
526 | |||
527 | definition.addDynFieldObject("order")
|
||
528 | .setClassOfValue(FeatureQueryOrder.class) |
||
529 | .setMandatory(false);
|
||
530 | |||
531 | definition.addDynFieldLong("limit").setMandatory(false); |
||
532 | |||
533 | definition.addDynFieldLong("pageSize").setMandatory(false); |
||
534 | |||
535 | } |
||
536 | |||
537 | 43358 | jjdelcerro | @Override
|
538 | 40435 | jjdelcerro | public long getLimit() { |
539 | return limit;
|
||
540 | } |
||
541 | |||
542 | 43358 | jjdelcerro | @Override
|
543 | 40435 | jjdelcerro | public long getPageSize() { |
544 | return pageSize;
|
||
545 | } |
||
546 | |||
547 | 43358 | jjdelcerro | @Override
|
548 | 40435 | jjdelcerro | public void setLimit(long limit) { |
549 | this.limit = limit;
|
||
550 | } |
||
551 | |||
552 | 43358 | jjdelcerro | @Override
|
553 | 40435 | jjdelcerro | public void setPageSize(long pageSize) { |
554 | this.pageSize = pageSize;
|
||
555 | } |
||
556 | |||
557 | 43358 | jjdelcerro | @Override
|
558 | 41212 | jjdelcerro | public String[] getConstantsAttributeNames() { |
559 | return (String[])constantsAttributeNames.toArray(new String[constantsAttributeNames.size()]); |
||
560 | } |
||
561 | |||
562 | 43358 | jjdelcerro | @Override
|
563 | 41212 | jjdelcerro | public void setConstantsAttributeNames(String[] constantsAttributeNames) { |
564 | this.constantsAttributeNames.clear();
|
||
565 | if (constantsAttributeNames != null){ |
||
566 | for (int i=0 ; i<constantsAttributeNames.length ; i++){ |
||
567 | this.constantsAttributeNames.add(constantsAttributeNames[i]);
|
||
568 | 42975 | jjdelcerro | } |
569 | 41212 | jjdelcerro | } |
570 | } |
||
571 | 42975 | jjdelcerro | |
572 | 43358 | jjdelcerro | @Override
|
573 | 41212 | jjdelcerro | public void addConstantAttributeName(String attributeName) { |
574 | //If the attribute exists finish the method
|
||
575 | for (int i=0 ; i<constantsAttributeNames.size() ; i++){ |
||
576 | if (constantsAttributeNames.get(i).equals(attributeName)){
|
||
577 | return;
|
||
578 | 42975 | jjdelcerro | } |
579 | } |
||
580 | 41212 | jjdelcerro | this.constantsAttributeNames.add(attributeName);
|
581 | } |
||
582 | |||
583 | 43358 | jjdelcerro | @Override
|
584 | 41212 | jjdelcerro | public boolean hasConstantsAttributeNames() { |
585 | return !this.constantsAttributeNames.isEmpty(); |
||
586 | } |
||
587 | |||
588 | 43358 | jjdelcerro | @Override
|
589 | 41212 | jjdelcerro | public void clearConstantsAttributeNames() { |
590 | this.constantsAttributeNames = new ArrayList(); |
||
591 | } |
||
592 | |||
593 | 40435 | jjdelcerro | } |