Revision 4d8fec30
Added by Andreas Müller over 2 years ago
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/description/DistributionAggregation.java | ||
---|---|---|
24 | 24 |
import org.hibernate.search.Search; |
25 | 25 |
import org.springframework.transaction.TransactionStatus; |
26 | 26 |
|
27 |
import eu.etaxonomy.cdm.common.CdmUtils; |
|
27 | 28 |
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor; |
28 | 29 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
29 | 30 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
... | ... | |
233 | 234 |
} |
234 | 235 |
|
235 | 236 |
@Override |
236 |
protected void mergeAggregationResultIntoTargetDescription(TaxonDescription targetDescription,
|
|
237 |
protected boolean mergeAggregationResultIntoTargetDescription(TaxonDescription targetDescription,
|
|
237 | 238 |
ResultHolder resultHolder) { |
238 | 239 |
|
240 |
boolean updated = false; |
|
241 |
|
|
239 | 242 |
Class<? extends DescriptionElementBase> debClass = Distribution.class; |
240 | 243 |
Map<NamedArea, Distribution> accumulatedStatusMap = ((DistributionResultHolder)resultHolder).accumulatedStatusMap; |
241 | 244 |
|
... | ... | |
256 | 259 |
// create a new distribution element |
257 | 260 |
targetDistribution = newElement; |
258 | 261 |
targetDescription.addElement(targetDistribution); |
262 |
updated = true; |
|
259 | 263 |
}else{ |
260 |
mergeDescriptionElement(targetDistribution, newElement); |
|
264 |
updated |= mergeDescriptionElement(targetDistribution, newElement);
|
|
261 | 265 |
elementsToRemove.remove(targetDistribution); //we keep the distribution for reuse |
262 | 266 |
} |
263 |
mergeSourcesForDescriptionElements(targetDistribution, accumulatedStatusMap.get(area).getSources()); |
|
267 |
updated |= mergeSourcesForDescriptionElements(targetDistribution, accumulatedStatusMap.get(area).getSources());
|
|
264 | 268 |
} |
265 | 269 |
|
266 |
this.handleDescriptionElementsToRemove(targetDescription, elementsToRemove); |
|
270 |
updated |= this.handleDescriptionElementsToRemove(targetDescription, elementsToRemove); |
|
271 |
return updated; |
|
267 | 272 |
} |
268 | 273 |
|
269 | 274 |
@Override |
270 |
protected <S extends DescriptionElementBase> void mergeDescriptionElement(S targetElement,
|
|
275 |
protected <S extends DescriptionElementBase> boolean mergeDescriptionElement(S targetElement,
|
|
271 | 276 |
S newElement) { |
277 |
boolean updated = false; |
|
272 | 278 |
if (!(targetElement instanceof Distribution)){ |
273 | 279 |
throw new AggregationException("Unexpected class: " + targetElement.getClass().getName()); |
274 | 280 |
}else{ |
275 | 281 |
Distribution targetDistribution = (Distribution)targetElement; |
276 | 282 |
Distribution newDistribution = (Distribution)newElement; |
277 |
targetDistribution.setStatus(newDistribution.getStatus()); |
|
283 |
if (!CdmUtils.nullSafeEqual(targetDistribution.getStatus(), newDistribution.getStatus())){ |
|
284 |
targetDistribution.setStatus(newDistribution.getStatus()); |
|
285 |
updated = true; |
|
286 |
} |
|
278 | 287 |
} |
288 |
return updated; |
|
279 | 289 |
} |
280 | 290 |
|
281 | 291 |
@Override |
Also available in: Unified diff
fix #9858 add updatedObjects to aggregation result for aggregated descriptions