ref #7597 Fix deletion of aggregated descriptions
authorPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 13 Aug 2019 07:13:29 +0000 (09:13 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 13 Aug 2019 07:13:29 +0000 (09:13 +0200)
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/DescriptiveDataSetService.java

index d8e524a4358b9266135330c0e1bbc55d7f5296b1..e5739a395a5498c7c290c72ca2d14f41a1750960 100644 (file)
@@ -410,15 +410,17 @@ public class DescriptiveDataSetService
             });
         });
 
-        // delete all aggregation description of this dataset (MarkerType.COMPUTED)
+        // delete all aggregation description of this dataset for this taxon (MarkerType.COMPUTED)
         List<TaxonDescription> toRemove = dataSet.getDescriptions().stream()
         .filter(aggDesc->aggDesc instanceof TaxonDescription)
         .filter(desc -> desc.getMarkers().stream().anyMatch(marker -> marker.getMarkerType().equals(MarkerType.COMPUTED())))
         .map(aggDesc->(TaxonDescription)aggDesc)
         .collect(Collectors.toList());
         for (TaxonDescription taxonDescription : toRemove) {
-            dataSet.removeDescription(taxonDescription);
-            taxon.removeDescription(taxonDescription);
+            if(taxon.getDescriptions().contains(taxonDescription)){
+                dataSet.removeDescription(taxonDescription);
+                taxon.removeDescription(taxonDescription);
+            }
         }
 
         // create new aggregation