ref #9481: move the descriptions to the new taxon to avoid DDS when deleting the...
[cdmlib.git] / cdmlib-services / src / main / java / eu / etaxonomy / cdm / api / service / TaxonServiceImpl.java
index 68e7ad98c6644083a4f70119d182b4ff9f3d6d19..8162c1fbf33f0b85c83f8e24c2e34ba7f774edca 100644 (file)
@@ -227,6 +227,14 @@ public class TaxonServiceImpl
             acceptedTaxon.removeSynonym(syn);
         }
         Taxon newTaxon = acceptedTaxon.clone();
+        newTaxon.getDescriptions().clear();
+        Set<TaxonDescription> descriptionsToCopy = new HashSet<>();
+        for (TaxonDescription desc: acceptedTaxon.getDescriptions()){
+            descriptionsToCopy.add(desc);
+        }
+        for (TaxonDescription description: descriptionsToCopy){
+            newTaxon.addDescription(description);
+        }
         newTaxon.setName(synonymName);
         newTaxon.setSec(synonym.getSec());
         newTaxon.setPublish(synonym.isPublish());