Revision 47362 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

View differences:

DistinctOn.java
184 184
					status.cancel();
185 185
					return null;
186 186
				}
187
				if (aggregateFeature != null) {
188
					if (Objects.equals(feature.get(uniqueFieldName), aggregateFeature.get(uniqueFieldName))) {
189
						for (Map.Entry<String, AggregateOperation> entry : aggregates.entrySet()) {
190
							String name = entry.getKey();
191
							AggregateOperation operation = entry.getValue();
192
							Object value = feature.get(name);
193
							if (operation.isApplicable(value)) {
194
								operation.perform(value);
195
							}
196
							aggregateFeature.set(name, operation.getValue());
197
						}
198
					} else {
199
                                            aggregateFeature.set(DISTINCT_ON_PRIMARY_KEY, counter++);
200
                                            storeResults.insert(aggregateFeature);
201
                                            aggregateFeature = null;
202
					}
203
				}
204

  
205 187
				if (aggregateFeature == null) {
206
					aggregateFeature = storeResults.createNewFeature(feature);
207
					for (Map.Entry<String, AggregateOperation> entry : aggregates.entrySet()) {
208
						String name = entry.getKey();
209
						AggregateOperation operation = entry.getValue();
210
						operation.reset();
211
						Object value = feature.get(name);
212
						if (operation.isApplicable(value)) {
213
							operation.perform(value);
214
						}
215
						aggregateFeature.set(name, operation.getValue());
216
					}
217
				}
188
                                    
189
                                    aggregateFeature = storeResults.createNewFeature(feature);
190
                                }
191
                                
192
                                if (!Objects.equals(feature.get(uniqueFieldName), aggregateFeature.get(uniqueFieldName))) {
193
                                    //Recoge lo agregado y lo inserta
194
                                    for (Map.Entry<String, AggregateOperation> entry : aggregates.entrySet()) {
195
                                        String name = entry.getKey();
196
                                        AggregateOperation operation = entry.getValue();
197
                                        aggregateFeature.set(name, operation.getValue());
198
                                    }
199
                                    aggregateFeature.set(DISTINCT_ON_PRIMARY_KEY, counter++);
200
                                    storeResults.insert(aggregateFeature);
201
                                    //Resetear las operaciones de agregado y la feature agregada
202
                                    for (Map.Entry<String, AggregateOperation> entry : aggregates.entrySet()) {
203
                                        AggregateOperation operation = entry.getValue();
204
                                        operation.reset();
205
                                    }
206
                                    aggregateFeature = storeResults.createNewFeature(feature);
207
                                }
208
                                //Evalua las funciones de agregado de la feature corriente
209
                                for (Map.Entry<String, AggregateOperation> entry : aggregates.entrySet()) {
210
                                        String name = entry.getKey();
211
                                        AggregateOperation operation = entry.getValue();
212
                                        Object value = feature.get(name);
213
                                        if (operation.isApplicable(value)) {
214
                                                operation.perform(value);
215
                                        }
216
                                }
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
////				}
218 256
				status.incrementCurrentValue();
219 257
			}
220 258
			if (aggregateFeature != null) {
221
                                aggregateFeature.set(DISTINCT_ON_PRIMARY_KEY, counter++);
222
				storeResults.insert(aggregateFeature);
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);
223 267
			}
224 268

  
225 269
			storeResults.finishEditing();

Also available in: Unified diff