Revision 35328

View differences:

branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/impl/DefaultFeatureQuery.java
26 26
 */
27 27
package org.gvsig.fmap.dal.feature.impl;
28 28

  
29
import java.util.ArrayList;
29 30
import java.util.HashMap;
30 31
import java.util.Iterator;
32
import java.util.List;
31 33
import java.util.Map;
32 34

  
33 35
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
......
79 81

  
80 82
    private String featureTypeId = null;
81 83

  
82
    private String[] attributeNames;
84
    private List attributeNames = new ArrayList();
83 85

  
84 86
    private Evaluator filter;
85 87

  
......
163 165
     */
164 166
    public DefaultFeatureQuery(String[] attributeNames) {
165 167
        super();
166
        this.attributeNames = attributeNames;
168
        setAttributeNames(attributeNames);
167 169
    }
168 170

  
169 171
    /**
......
179 181
     */
180 182
    public DefaultFeatureQuery(String[] attributeNames, Evaluator filter) {
181 183
        super();
182
        this.attributeNames = attributeNames;
184
        setAttributeNames(attributeNames);
183 185
        this.filter = filter;
184 186
    }
185 187

  
......
198 200
     */
199 201
    public DefaultFeatureQuery(String[] attributeNames, Evaluator filter,
200 202
        double scale) {
201
        this.attributeNames = attributeNames;
203
        setAttributeNames(attributeNames);
202 204
        this.filter = filter;
203 205
        this.setScale(scale);
204 206
    }
......
234 236
            attrs[i] = attr.getName();
235 237
            i++;
236 238
        }
237
        this.attributeNames = attrs;
238

  
239
        setAttributeNames(attrs);
239 240
    }
240 241

  
241 242
    public String[] getAttributeNames() {
242
        return attributeNames;
243
        return (String[])attributeNames.toArray(new String[attributeNames.size()]);
243 244
    }
244 245

  
245 246
    public void setAttributeNames(String[] attributeNames) {
246
        this.attributeNames = attributeNames;
247
        this.attributeNames.clear();
248
        for (int i=0 ; i<attributeNames.length ; i++){
249
            this.attributeNames.add(attributeNames[i]);
250
        }      
247 251
    }
252
    
253
    public void addAttributeName(String attributeName){
254
        //If the attribute exists finish the method
255
        for (int i=0 ; i<attributeNames.size() ; i++){
256
            if (attributeNames.get(i).equals(attributeName)){
257
                return;
258
            }            
259
        } 
260
        this.attributeNames.add(attributeName);
261
    }
248 262

  
249 263
    public Evaluator getFilter() {
250 264
        return filter;
......
252 266

  
253 267
    public void setFilter(Evaluator filter) {
254 268
        this.filter = filter;
269
        addFilterAttributes(filter);
255 270
        isAddFilter = false;
256 271
    }
257 272

  
258
    public void addFilter(Evaluator targetFilter) {
273
    public void addFilter(Evaluator evaluator) {
259 274
        if (isAddFilter){
260 275
            if (this.filter == null){
261
                this.filter = targetFilter;
276
                this.filter = evaluator;
262 277
            }else{
263
                if (targetFilter != null){
278
                if (evaluator != null){
264 279
                    if (this.filter instanceof AndEvaluator){
265
                        ((AndEvaluator)this.filter).addEvaluator(targetFilter);
280
                        ((AndEvaluator)this.filter).addEvaluator(evaluator);
266 281
                    }else{
267 282
                        this.filter = new AndEvaluator(this.filter);
268
                        ((AndEvaluator)this.filter).addEvaluator(targetFilter);
283
                        ((AndEvaluator)this.filter).addEvaluator(evaluator);
269 284
                    }
270 285
                }
271 286
            }
272 287
        }else{
273
            this.filter = targetFilter;
288
            this.filter = evaluator;
274 289
        }
290
        addFilterAttributes(evaluator);
275 291
        isAddFilter = true;
276 292
    }
293
    
294
    private void addFilterAttributes(Evaluator evaluator){
295
        if (evaluator != null){
296
            String[] fieldNames = evaluator.getFieldsInfo().getFieldNames();
297
            for (int i=0 ; i<fieldNames.length ; i++){
298
                addAttributeName(fieldNames[i]);
299
            }
300
        }
301
    }
277 302

  
278 303
    public FeatureQueryOrder getOrder() {
279 304
        return order;
......
296 321

  
297 322
        // Clone attribute names array
298 323
        if (attributeNames != null) {
299
            clone.attributeNames = new String[attributeNames.length];
300
            System.arraycopy(attributeNames, 0, clone.attributeNames, 0,
301
                attributeNames.length);
324
            clone.attributeNames = new ArrayList();
325
            for (int i=0 ; i<attributeNames.size() ; i++){
326
                clone.attributeNames.add(attributeNames.get(i));
327
            }       
302 328
        }
303 329

  
304 330
        // Clone order
......
358 384
        // FIXME: falta por terminar de implementar
359 385
        this.queryParameters = (Map) state.get("queryParameters");
360 386
        this.featureTypeId = state.getString("featureTypeId");
361
        this.attributeNames = (String[]) state.getArray("attributeNames", String.class);
387
        this.attributeNames = state.getList("attributeNames");
362 388
        this.filter = (Evaluator) state.get("filter");
363 389
        this.limit = state.getLong("limit");
364 390
        this.pageSize = state.getLong("pageSize");
branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/FeatureQuery.java
76 76
	 *            the attribute names to load
77 77
	 */
78 78
	void setAttributeNames(String[] attributeNames);
79
	
80
	/**
81
	 * Adds the name of an attribute that has to be used to load each
82
	 * {@link Feature}.
83
	 * 
84
	 * @param attributeName
85
	 *             the attribute name to load
86
	 */
87
	void addAttributeName(String attributeName);
79 88

  
80 89
	/**
81 90
	 * Sets the {@link FeatureType} of the {@link Feature}s to load. It may be

Also available in: Unified diff