Revision 47368
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/searchPostProcess/distinctOn/DistinctOn.java | ||
---|---|---|
166 | 166 |
} else { |
167 | 167 |
features = inputStore.getFeatureSet(); |
168 | 168 |
} |
169 |
EditableFeature aggregateFeature = null;
|
|
169 |
Feature previousFeature = null;
|
|
170 | 170 |
|
171 | 171 |
status.message(i18n.getTranslation("_Processing_features")); |
172 | 172 |
status.setRangeOfValues(0, features.size()); |
... | ... | |
184 | 184 |
status.cancel(); |
185 | 185 |
return null; |
186 | 186 |
} |
187 |
if (aggregateFeature == null) { |
|
188 |
|
|
189 |
aggregateFeature = storeResults.createNewFeature(feature); |
|
187 |
if (previousFeature == null) { |
|
188 |
previousFeature = feature.getCopy(); |
|
190 | 189 |
} |
191 | 190 |
|
192 |
if (!Objects.equals(feature.get(uniqueFieldName), aggregateFeature.get(uniqueFieldName))) {
|
|
191 |
if (!Objects.equals(feature.get(uniqueFieldName), previousFeature.get(uniqueFieldName))) {
|
|
193 | 192 |
//Recoge lo agregado y lo inserta |
193 |
EditableFeature resultFeature = storeResults.createNewFeature(previousFeature); |
|
194 | 194 |
for (Map.Entry<String, AggregateOperation> entry : aggregates.entrySet()) { |
195 | 195 |
String name = entry.getKey(); |
196 | 196 |
AggregateOperation operation = entry.getValue(); |
197 |
aggregateFeature.set(name, operation.getValue());
|
|
197 |
resultFeature.set(name, operation.getValue());
|
|
198 | 198 |
} |
199 |
aggregateFeature.set(DISTINCT_ON_PRIMARY_KEY, counter++);
|
|
200 |
storeResults.insert(aggregateFeature);
|
|
199 |
resultFeature.set(DISTINCT_ON_PRIMARY_KEY, counter++);
|
|
200 |
storeResults.insert(resultFeature);
|
|
201 | 201 |
//Resetear las operaciones de agregado y la feature agregada |
202 | 202 |
for (Map.Entry<String, AggregateOperation> entry : aggregates.entrySet()) { |
203 | 203 |
AggregateOperation operation = entry.getValue(); |
204 | 204 |
operation.reset(); |
205 | 205 |
} |
206 |
aggregateFeature = storeResults.createNewFeature(feature);
|
|
206 |
previousFeature = feature.getCopy();
|
|
207 | 207 |
} |
208 | 208 |
//Evalua las funciones de agregado de la feature corriente |
209 | 209 |
for (Map.Entry<String, AggregateOperation> entry : aggregates.entrySet()) { |
... | ... | |
215 | 215 |
} |
216 | 216 |
} |
217 | 217 |
|
218 |
// |
|
219 |
// |
|
220 |
// |
|
221 |
//// if (aggregateFeature != null) { |
|
222 |
// if (Objects.equals(feature.get(uniqueFieldName), aggregateFeature.get(uniqueFieldName))) { |
|
223 |
// for (Map.Entry<String, AggregateOperation> entry : aggregates.entrySet()) { |
|
224 |
// String name = entry.getKey(); |
|
225 |
// AggregateOperation operation = entry.getValue(); |
|
226 |
// Object value = feature.get(name); |
|
227 |
// if (operation.isApplicable(value)) { |
|
228 |
// operation.perform(value); |
|
229 |
// } |
|
230 |
// } |
|
231 |
// } else { |
|
232 |
// for (Map.Entry<String, AggregateOperation> entry : aggregates.entrySet()) { |
|
233 |
// String name = entry.getKey(); |
|
234 |
// AggregateOperation operation = entry.getValue(); |
|
235 |
// aggregateFeature.set(name, operation.getValue()); |
|
236 |
// } |
|
237 |
// aggregateFeature.set(DISTINCT_ON_PRIMARY_KEY, counter++); |
|
238 |
// storeResults.insert(aggregateFeature); |
|
239 |
// aggregateFeature = null; |
|
240 |
// } |
|
241 |
//// } |
|
242 |
// |
|
243 |
//// if (aggregateFeature == null) { |
|
244 |
//// aggregateFeature = storeResults.createNewFeature(feature); |
|
245 |
//// for (Map.Entry<String, AggregateOperation> entry : aggregates.entrySet()) { |
|
246 |
//// String name = entry.getKey(); |
|
247 |
//// AggregateOperation operation = entry.getValue(); |
|
248 |
//// operation.reset(); |
|
249 |
//// Object value = feature.get(name); |
|
250 |
//// if (operation.isApplicable(value)) { |
|
251 |
//// operation.perform(value); |
|
252 |
//// } |
|
253 |
//// aggregateFeature.set(name, operation.getValue()); |
|
254 |
//// } |
|
255 |
//// } |
|
256 | 218 |
status.incrementCurrentValue(); |
257 | 219 |
} |
258 |
if (aggregateFeature != null) { |
|
259 |
//Recoge lo agregado y lo inserta |
|
260 |
for (Map.Entry<String, AggregateOperation> entry : aggregates.entrySet()) { |
|
261 |
String name = entry.getKey(); |
|
262 |
AggregateOperation operation = entry.getValue(); |
|
263 |
aggregateFeature.set(name, operation.getValue()); |
|
264 |
} |
|
265 |
aggregateFeature.set(DISTINCT_ON_PRIMARY_KEY, counter++); |
|
266 |
storeResults.insert(aggregateFeature); |
|
267 |
} |
|
220 |
//Recoge lo agregado y lo inserta |
|
221 |
EditableFeature resultFeature = storeResults.createNewFeature(previousFeature); |
|
222 |
for (Map.Entry<String, AggregateOperation> entry : aggregates.entrySet()) { |
|
223 |
String name = entry.getKey(); |
|
224 |
AggregateOperation operation = entry.getValue(); |
|
225 |
resultFeature.set(name, operation.getValue()); |
|
226 |
} |
|
227 |
resultFeature.set(DISTINCT_ON_PRIMARY_KEY, counter++); |
|
228 |
storeResults.insert(resultFeature); |
|
268 | 229 |
|
269 | 230 |
storeResults.finishEditing(); |
270 | 231 |
storeResults.setTemporary(true); |
Also available in: Unified diff