Revision 42975

View differences:

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
58 58
 * customize the behavior of the getDataCollection methods, there is an option
59 59
 * to set more parameters through the setAttribute method.
60 60
 * </p>
61
 * 
61
 *
62 62
 * @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team
63 63
 */
64 64
public interface FeatureQuery extends DataQuery, Cloneable {
65 65

  
66 66
	/**
67 67
	 * Returns the names of the attributes to load from each {@link Feature}.
68
	 * 
68
	 *
69 69
	 * @return the attribute names to load
70 70
	 */
71 71
	String[] getAttributeNames();
72 72

  
73 73
	/**
74 74
	 * Sets the names of the attributes to load from each {@link Feature}.
75
	 * 
75
	 *
76 76
	 * @param attributeNames
77 77
	 *            the attribute names to load
78 78
	 */
79 79
	void setAttributeNames(String[] attributeNames);
80
	
80

  
81 81
	/**
82 82
	 * Adds the name of an attribute that has to be used to load each
83 83
	 * {@link Feature}.
84
	 * 
84
	 *
85 85
	 * @param attributeName
86 86
	 *             the attribute name to load
87 87
	 */
......
89 89

  
90 90
        /**
91 91
         * Return true if has set attribute names
92
         * 
92
         *
93 93
         * @return true if has attribute names, otherwise false
94 94
         */
95 95
        boolean hasAttributeNames();
96
        
96

  
97 97
        /**
98 98
         * Remove all the attribute names specifieds.
99 99
         */
......
102 102
        /**
103 103
	 * Returns the names of the attributes that are constants in each {@link Feature}.
104 104
	 * These attributes will not be charged.
105
         * 
105
         *
106 106
	 * @return the attribute names that are constant
107 107
	 */
108 108
	String[] getConstantsAttributeNames();
109 109

  
110 110
	/**
111 111
	 * Set of attribute names to be treated as constants for each {@link Feature}.
112
	 * 
112
	 *
113 113
	 * @param attributeNames
114 114
	 *            the attribute names to be constants
115 115
	 */
116 116
	void setConstantsAttributeNames(String[] attributeNames);
117
	
117

  
118 118
	/**
119
	 * Add an attribute name that will be treated as constant for each 
119
	 * Add an attribute name that will be treated as constant for each
120 120
	 * {@link Feature}.
121
	 * 
121
	 *
122 122
	 * @param attributeName
123 123
	 *             the attribute name to be treated as constant
124 124
	 */
......
126 126

  
127 127
        /**
128 128
         * Return true if has set constants attribute names
129
         * 
129
         *
130 130
         * @return true if has constants attribute names, otherwise false
131 131
         */
132 132
        boolean hasConstantsAttributeNames();
133
        
133

  
134 134
        /**
135 135
         * Remove all the names specified as constants attributes.
136 136
         */
137 137
        void clearConstantsAttributeNames();
138
        
138

  
139 139
	/**
140 140
	 * Sets the {@link FeatureType} of the {@link Feature}s to load. It may be
141 141
	 * used as an alternative way to set a subset of the list of attribute names
142 142
	 * to load, by creating a sub-FeatureType.
143
	 * 
143
	 *
144 144
	 * @param featureType
145 145
	 *            the feature type of the data to load
146 146
	 */
......
148 148

  
149 149
	/**
150 150
	 * Returns the {@link FeatureType} id of the {@link Feature}s to load.
151
	 * 
151
	 *
152 152
	 * @return the {@link FeatureType} id of the {@link Feature}s to load
153 153
	 */
154 154
	String getFeatureTypeId();
......
156 156
	/**
157 157
	 * Sets the {@link FeatureType} id of the {@link Feature}s to load. This way
158 158
	 * all {@link Feature} attributes will be loaded.
159
	 * 
159
	 *
160 160
	 * @param featureTypeId
161 161
	 *            the {@link FeatureType} id of the {@link Feature}s to load
162 162
	 */
......
164 164

  
165 165
	/**
166 166
	 * Returns the filter to apply to the {@link Feature}s to load.
167
	 * 
167
	 *
168 168
	 * @return the filter
169 169
	 */
170 170
	Evaluator getFilter();
171 171

  
172 172
	/**
173 173
	 * Sets the filter to apply to the {@link Feature}s to load.
174
	 * 
174
	 *
175 175
	 * @param filter
176 176
	 *            the filter to apply to the {@link Feature}s to load
177 177
	 */
178 178
	void setFilter(Evaluator filter);
179
        
179

  
180 180
        void setFilter(String filter);
181
	
181

  
182 182
	/**
183 183
	 * Adds a filter to apply to the {@link Feature}s to load. A query
184 184
	 * can have more that one filter and all of them are applied when
185 185
	 * the query is applied.
186 186
         * If filter is null do nothing.
187
	 * 
187
	 *
188 188
	 * @param filter
189 189
	 *             a filter to apply to the {@link Feature}s to load
190 190
	 */
191 191
	void addFilter(Evaluator filter);
192 192

  
193 193
        void addFilter(String filter);
194

  
195
        void clearFilter();
194 196
        
195 197
	/**
196 198
	 * Returns if a filter has been defined for the query.
197
	 * 
199
	 *
198 200
	 * @return if a filter has been defined for the query
199 201
	 */
200 202
	boolean hasFilter();
201 203

  
202 204
	/**
203 205
	 * Returns the order of the {@link Feature}s to load.
204
	 * 
206
	 *
205 207
	 * @return the order of the {@link Feature}s to load
206 208
	 */
207 209
	FeatureQueryOrder getOrder();
208 210

  
209 211
	/**
210 212
	 * Sets the order of the {@link Feature}s to load.
211
	 * 
213
	 *
212 214
	 * @param order
213 215
	 *            the order of the {@link Feature}s to load
214 216
	 */
......
216 218

  
217 219
	/**
218 220
	 * Returns if an order has been set for the elements returned by the query.
219
	 * 
221
	 *
220 222
	 * @return if an order has been set for the elements returned by the query
221 223
	 */
222 224
	boolean hasOrder();
......
234 236
	 * source, or only used as a hint, so don't rely on it being used, as you
235 237
	 * may actually get more values than the limit.
236 238
	 * </p>
237
	 * 
239
	 *
238 240
	 * @return the maximum number of elements to return with this query
239 241
	 */
240 242
	long getLimit();
......
246 248
	 * source, or only used as a hint, so don't rely on it being used, as you
247 249
	 * may actually get more values than the limit.
248 250
	 * </p>
249
	 * 
251
	 *
250 252
	 * @param limit
251 253
	 *            the maximum number of elements to return with this query
252 254
	 */
......
257 259
	 * block by the data source. This value is only used as a hint to the
258 260
	 * underlying data source, as a way to tell how many Features may be read in
259 261
	 * a block.
260
	 * 
262
	 *
261 263
	 * @return the load page size
262 264
	 */
263 265
	long getPageSize();
......
267 269
	 * block by the data source. This value is only used as a hint to the
268 270
	 * underlying data source, as a way to tell how many Features may be read in
269 271
	 * a block.
270
	 * 
272
	 *
271 273
	 * @param pageSize
272 274
	 *            the load page size
273 275
	 */
274 276

  
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
69 69
 * customize the behavior of the getDataCollection methods, there is an option
70 70
 * to set more parameters through the setAttribute method.
71 71
 * </p>
72
 * 
72
 *
73 73
 * @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team
74 74
 */
75 75
public class DefaultFeatureQuery implements FeatureQuery {
......
101 101

  
102 102
    /**
103 103
     * Creates a FeatureQuery which will load all available Features of a type.
104
     * 
104
     *
105 105
     * @param featureType
106 106
     *            the type of Features of the query
107 107
     */
......
111 111

  
112 112
    /**
113 113
     * Creates a FeatureQuery which will load all available Features of a type.
114
     * 
114
     *
115 115
     * @param featureType
116 116
     *            the type of Features of the query
117 117
     */
......
123 123
    /**
124 124
     * Creates a FeatureQuery with the type of features, a filter and the order
125 125
     * for the FeatureCollection.
126
     * 
126
     *
127 127
     * @param featureType
128 128
     *            the type of Features of the query
129 129
     * @param filter
......
140 140
    /**
141 141
     * Creates a FeatureQuery with the type of features, a filter, the order for
142 142
     * the FeatureCollection and the view scale.
143
     * 
143
     *
144 144
     * @param featureType
145 145
     *            the type of Features of the query
146 146
     * @param filter
......
160 160
    /**
161 161
     * Creates a FeatureQuery which will load a list of attribute names of all
162 162
     * available Features.
163
     * 
163
     *
164 164
     * @param attributeNames
165 165
     *            the list of attribute names to load
166 166
     */
......
172 172
    /**
173 173
     * Creates a FeatureQuery with the list of attribute names of feature, a
174 174
     * filter and the order for the FeatureCollection.
175
     * 
175
     *
176 176
     * @param attributeNames
177 177
     *            the list of attribute names to load
178 178
     * @param filter
......
189 189
    /**
190 190
     * Creates a FeatureQuery with the list of attribute names of feature, a
191 191
     * filter, the order for the FeatureCollection and the view scale.
192
     * 
192
     *
193 193
     * @param attributeNames
194 194
     *            the list of attribute names to load
195 195
     * @param filter
......
239 239
        if (attributeNames != null){
240 240
            for (int i=0 ; i<attributeNames.length ; i++){
241 241
                this.attributeNames.add(attributeNames[i]);
242
            }   
242
            }
243 243
        }
244 244
    }
245
    
245

  
246 246
    public void addAttributeName(String attributeName){
247 247
        //If the attribute exists finish the method
248 248
        for (int i=0 ; i<attributeNames.size() ; i++){
249 249
            if (attributeNames.get(i).equals(attributeName)){
250 250
                return;
251
            }            
252
        } 
251
            }
252
        }
253 253
        this.attributeNames.add(attributeName);
254 254
    }
255 255

  
......
264 264
    public Evaluator getFilter() {
265 265
        return filter;
266 266
    }
267
    
267

  
268 268
    @Override
269 269
    public void setFilter(String filter) {
270 270
        try {
......
288 288
            throw new RuntimeException("Can't create filter from '"+filter+"'",ex);
289 289
        }
290 290
    }
291
    
291

  
292 292
    @Override
293 293
    public void addFilter(Evaluator evaluator) {
294 294
        if( evaluator == null ) {
......
313 313
        addFilterAttributes(evaluator);
314 314
//        isAddFilter = true;
315 315
    }
316
    
316

  
317
    public void clearFilter() {
318
      this.filter = null;
319
    }
320

  
317 321
    private void addFilterAttributes(Evaluator evaluator){
318 322
        if (evaluator != null){
319 323
            EvaluatorFieldsInfo fieldsInfo = evaluator.getFieldsInfo();
......
326 330
                // fieldNames is not available in this evaluator
327 331
                return;
328 332
            }
329
            
333

  
330 334
            for (int i=0 ; i<fieldNames.length ; i++){
331 335
                addAttributeName(fieldNames[i]);
332 336
            }
......
357 361
            clone.attributeNames = new ArrayList();
358 362
            for (int i=0 ; i<attributeNames.size() ; i++){
359 363
                clone.attributeNames.add(attributeNames.get(i));
360
            }       
364
            }
361 365
        }
362 366

  
363 367
        // Clone order
......
426 430

  
427 431
    /**
428 432
     * Register the class on PersistenceManager
429
     * 
433
     *
430 434
     */
431 435
    public static void registerPersistent() {
432 436
        DynStruct definition =
......
486 490
        if (constantsAttributeNames != null){
487 491
            for (int i=0 ; i<constantsAttributeNames.length ; i++){
488 492
                this.constantsAttributeNames.add(constantsAttributeNames[i]);
489
            }   
493
            }
490 494
        }
491 495
    }
492
    
496

  
493 497
    public void addConstantAttributeName(String attributeName) {
494 498
        //If the attribute exists finish the method
495 499
        for (int i=0 ; i<constantsAttributeNames.size() ; i++){
496 500
            if (constantsAttributeNames.get(i).equals(attributeName)){
497 501
                return;
498
            }            
499
        } 
502
            }
503
        }
500 504
        this.constantsAttributeNames.add(attributeName);
501 505
    }
502 506

  
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/featureset/DefaultFeatureSet.java
139 139

  
140 140
    private void fixQueryForProvider(FeatureQuery theQueryForProvider,
141 141
        DefaultFeatureStoreTransforms transformsToUse) throws DataException {
142
        theQueryForProvider.setAttributeNames(null);
142
        theQueryForProvider.clearAttributeNames();
143 143
        FeatureType ftype =
144 144
            transformsToUse.getSourceFeatureTypeFrom(this.defatulFeatureType);
145 145
        theQueryForProvider.setFeatureTypeId(ftype.getId());
146 146
        this.defatulFeatureTypeForProvider = ftype;
147 147

  
148 148
        if (transformsToUse.isTransformsOriginalValues()) {
149
            theQueryForProvider.setFilter(null);
149
            theQueryForProvider.clearFilter();
150 150
            FeatureQueryOrder fqo = theQueryForProvider.getOrder();
151 151
            if (fqo != null) {
152 152
                fqo.clear();
......
166 166
            }
167 167

  
168 168
            if (!canUseFilter) {
169
                theQueryForProvider.setFilter(null);
169
                theQueryForProvider.clearFilter();
170 170
            }
171 171

  
172 172
        }
173 173

  

Also available in: Unified diff