Fixes #2233
authorn.hoffmann <n.hoffmann@localhost>
Mon, 14 Feb 2011 16:54:33 +0000 (16:54 +0000)
committern.hoffmann <n.hoffmann@localhost>
Mon, 14 Feb 2011 16:54:33 +0000 (16:54 +0000)
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/DescriptionServiceImpl.java
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/DescriptionServiceImplTest.java

index 86745f84243df3d6b3b1db3fc78bc0c1aca2dd4b..9903bbf3219ba29a4a422b1c1b3541b12eba3dfd 100644 (file)
@@ -457,20 +457,35 @@ public class DescriptionServiceImpl extends IdentifiableServiceBase<DescriptionB
        @Override
        public void moveDescriptionElementsToDescription(Collection<DescriptionElementBase> descriptionElements,
                                                                                                        DescriptionBase targetDescription, boolean isCopy) {
-               Iterator<DescriptionElementBase> iterator = descriptionElements.iterator();
-               while (iterator.hasNext()){
-                       DescriptionElementBase elementToRemove = iterator.next();
+               
+               for (DescriptionElementBase element : descriptionElements){
+                       DescriptionBase description = element.getInDescription();
+                       try {
+                               DescriptionElementBase newElement = (DescriptionElementBase)element.clone();
+                               targetDescription.addElement(newElement);       
+                       } catch (CloneNotSupportedException e) {
+                               new RuntimeException ("Clone not yet implemented for class " + element.getClass().getName(), e);
+                       }
                        if (! isCopy){
-                               iterator.remove();
-                       }else{
-                               try {
-                                       elementToRemove = (DescriptionElementBase)elementToRemove.clone();
-                               } catch (CloneNotSupportedException e) {
-                                       new RuntimeException ("Clone not yet implemented for class " + elementToRemove.getClass().getName(), e);
-                               }
+                               description.removeElement(element);
+//                             iterator.remove();
                        }
-                       targetDescription.addElement(elementToRemove);  
+                       
                }
+//             Iterator<DescriptionElementBase> iterator = descriptionElements.iterator();
+//             while (iterator.hasNext()){
+//                     DescriptionElementBase elementToRemove = iterator.next();
+//                     try {
+//                             elementToRemove = (DescriptionElementBase)elementToRemove.clone();
+//                     } catch (CloneNotSupportedException e) {
+//                             new RuntimeException ("Clone not yet implemented for class " + elementToRemove.getClass().getName(), e);
+//                     }
+//                     
+//                     targetDescription.addElement(elementToRemove);  
+//                     if (! isCopy){
+//                             iterator.remove();
+//                     }
+//             }
        }
 
 }
index 604019be3dddbf976f413309561e0bdd53fec19b..73faeb2f9b21659eba7a3dfcb2eb5b16728891cf 100644 (file)
@@ -156,6 +156,6 @@ public class DescriptionServiceImplTest extends CdmIntegrationTest {
                this.service.save(targetDescription);\r
                this.service.save(sourceDescription);\r
                \r
-\r
+               \r
        }\r
 }\r