Fix infinite loop when moving terms with parent terms
authorPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 7 May 2019 14:17:20 +0000 (16:17 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 8 May 2019 09:46:15 +0000 (11:46 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/e4/DefinedTermDropAdapterE4.java

index fb77f25..6e7d916 100644 (file)
@@ -93,20 +93,16 @@ public class DefinedTermDropAdapterE4 extends EditViewerDropAdapter {
                 }
 
                 TermDto partOfDto = parentTerm.getPartOfDto();
-                while(partOfDto!=null){
-                    if(partOfDto.equals(droppedObject)){
-                        MessagingUtils.warningDialog(MOVE_FAILED, this.getClass(),
-                                MOVE_FAILED_MESSAGE);
-                        return false;
-                    }
+                if(partOfDto!=null && partOfDto.equals(droppedObject)){
+                    MessagingUtils.warningDialog(MOVE_FAILED, this.getClass(),
+                            MOVE_FAILED_MESSAGE);
+                    return false;
                 }
                 TermDto kindOfDto = parentTerm.getKindOfDto();
-                while(kindOfDto!=null){
-                    if(kindOfDto.equals(droppedObject)){
-                        MessagingUtils.warningDialog(MOVE_FAILED, this.getClass(),
-                                MOVE_FAILED_MESSAGE);
-                        return false;
-                    }
+                if(kindOfDto!=null && kindOfDto.equals(droppedObject)){
+                    MessagingUtils.warningDialog(MOVE_FAILED, this.getClass(),
+                            MOVE_FAILED_MESSAGE);
+                    return false;
                 }
             }
             else if(target instanceof TermVocabularyDto){